Mercurial > mplayer.hg
annotate libmpcodecs/vf_screenshot.c @ 37143:88b4aa330150
Ensure dimensions are set before opening libavcodec encoder.
This is a requirement that was added some time ago, we
so far relied on a hack in libavcodec, but that isn't
really a good idea.
Only lightly tested.
author | reimar |
---|---|
date | Sun, 13 Jul 2014 21:39:32 +0000 |
parents | 0fa1993a31c3 |
children |
rev | line source |
---|---|
30421
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30150
diff
changeset
|
1 /* |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30150
diff
changeset
|
2 * This file is part of MPlayer. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30150
diff
changeset
|
3 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30150
diff
changeset
|
4 * MPlayer is free software; you can redistribute it and/or modify |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30150
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30150
diff
changeset
|
6 * the Free Software Foundation; either version 2 of the License, or |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30150
diff
changeset
|
7 * (at your option) any later version. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30150
diff
changeset
|
8 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30150
diff
changeset
|
9 * MPlayer is distributed in the hope that it will be useful, |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30150
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30150
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30150
diff
changeset
|
12 * GNU General Public License for more details. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30150
diff
changeset
|
13 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30150
diff
changeset
|
14 * You should have received a copy of the GNU General Public License along |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30150
diff
changeset
|
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30150
diff
changeset
|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30150
diff
changeset
|
17 */ |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30150
diff
changeset
|
18 |
17012 | 19 #include "config.h" |
16446 | 20 |
21 #include <stdio.h> | |
22 #include <stdlib.h> | |
23 #include <string.h> | |
24 #include <inttypes.h> | |
25 | |
26 #include <sys/types.h> | |
27 #include <sys/stat.h> | |
28 #include <unistd.h> | |
29 | |
17012 | 30 #include "mp_msg.h" |
16446 | 31 |
32 #include "img_format.h" | |
33 #include "mp_image.h" | |
34 #include "vf.h" | |
35 #include "vf_scale.h" | |
36 | |
35712
d206960484fe
Add a number of missing libavutil header #includes.
diego
parents:
35114
diff
changeset
|
37 #include "libavutil/mem.h" |
18861 | 38 #include "libswscale/swscale.h" |
24731 | 39 #include "libavcodec/avcodec.h" |
40 | |
16446 | 41 struct vf_priv_s { |
42 int frameno; | |
36752
af146b0d33f0
Allow specifying custom path and name for screenshot files.
reimar
parents:
36751
diff
changeset
|
43 char fname[PATH_MAX]; |
af146b0d33f0
Allow specifying custom path and name for screenshot files.
reimar
parents:
36751
diff
changeset
|
44 char *prefix; |
19833 | 45 /// shot stores current screenshot mode: |
46 /// 0: don't take screenshots | |
47 /// 1: take single screenshot, reset to 0 afterwards | |
48 /// 2: take screenshots of each frame | |
16450 | 49 int shot, store_slices; |
36753
b3afe52119c4
vf_screenshot: Switch to avcodec_encode_video2 API.
reimar
parents:
36752
diff
changeset
|
50 int dw, dh; |
b3afe52119c4
vf_screenshot: Switch to avcodec_encode_video2 API.
reimar
parents:
36752
diff
changeset
|
51 AVFrame *pic; |
16446 | 52 struct SwsContext *ctx; |
24731 | 53 AVCodecContext *avctx; |
54 uint8_t *outbuffer; | |
55 int outbuffer_size; | |
16446 | 56 }; |
57 | |
58 //===========================================================================// | |
59 | |
36309 | 60 static void draw_slice(struct vf_instance *vf, unsigned char** src, |
61 int* stride, int w,int h, int x, int y) | |
62 { | |
63 if (vf->priv->store_slices) { | |
36753
b3afe52119c4
vf_screenshot: Switch to avcodec_encode_video2 API.
reimar
parents:
36752
diff
changeset
|
64 sws_scale(vf->priv->ctx, src, stride, y, h, vf->priv->pic->data, vf->priv->pic->linesize); |
36309 | 65 } |
66 vf_next_draw_slice(vf,src,stride,w,h,x,y); | |
67 } | |
68 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
69 static int config(struct vf_instance *vf, |
27947 | 70 int width, int height, int d_width, int d_height, |
71 unsigned int flags, unsigned int outfmt) | |
16446 | 72 { |
36309 | 73 int res; |
36757
18518cb8a99e
vf_screenshot: Fix memory leak on resolution/aspect changes.
reimar
parents:
36756
diff
changeset
|
74 if (vf->priv->ctx) sws_freeContext(vf->priv->ctx); |
16464
0a828abf1f0f
Fix multiple issues: No picture at all, broken pictures, only every second
reimar
parents:
16457
diff
changeset
|
75 vf->priv->ctx=sws_getContextFromCmdLine(width, height, outfmt, |
27947 | 76 d_width, d_height, IMGFMT_RGB24); |
16446 | 77 |
36755 | 78 av_fast_malloc(&vf->priv->outbuffer, &vf->priv->outbuffer_size, d_width * d_height * 3 * 2); |
37143
88b4aa330150
Ensure dimensions are set before opening libavcodec encoder.
reimar
parents:
36758
diff
changeset
|
79 if (!vf->priv->avctx) { |
88b4aa330150
Ensure dimensions are set before opening libavcodec encoder.
reimar
parents:
36758
diff
changeset
|
80 vf->priv->avctx = avcodec_alloc_context3(NULL); |
88b4aa330150
Ensure dimensions are set before opening libavcodec encoder.
reimar
parents:
36758
diff
changeset
|
81 vf->priv->avctx->pix_fmt = PIX_FMT_RGB24; |
88b4aa330150
Ensure dimensions are set before opening libavcodec encoder.
reimar
parents:
36758
diff
changeset
|
82 vf->priv->avctx->width = d_width; |
88b4aa330150
Ensure dimensions are set before opening libavcodec encoder.
reimar
parents:
36758
diff
changeset
|
83 vf->priv->avctx->height = d_height; |
88b4aa330150
Ensure dimensions are set before opening libavcodec encoder.
reimar
parents:
36758
diff
changeset
|
84 vf->priv->avctx->compression_level = 0; |
88b4aa330150
Ensure dimensions are set before opening libavcodec encoder.
reimar
parents:
36758
diff
changeset
|
85 if (avcodec_open2(vf->priv->avctx, avcodec_find_encoder(AV_CODEC_ID_PNG), NULL)) { |
88b4aa330150
Ensure dimensions are set before opening libavcodec encoder.
reimar
parents:
36758
diff
changeset
|
86 mp_msg(MSGT_VFILTER, MSGL_FATAL, "Could not open libavcodec PNG encoder\n"); |
88b4aa330150
Ensure dimensions are set before opening libavcodec encoder.
reimar
parents:
36758
diff
changeset
|
87 return 0; |
88b4aa330150
Ensure dimensions are set before opening libavcodec encoder.
reimar
parents:
36758
diff
changeset
|
88 } |
88b4aa330150
Ensure dimensions are set before opening libavcodec encoder.
reimar
parents:
36758
diff
changeset
|
89 } |
16446 | 90 vf->priv->dw = d_width; |
91 vf->priv->dh = d_height; | |
36753
b3afe52119c4
vf_screenshot: Switch to avcodec_encode_video2 API.
reimar
parents:
36752
diff
changeset
|
92 vf->priv->pic->linesize[0] = (3*vf->priv->dw+15)&~15; |
16446 | 93 |
36753
b3afe52119c4
vf_screenshot: Switch to avcodec_encode_video2 API.
reimar
parents:
36752
diff
changeset
|
94 av_freep(&vf->priv->pic->data[0]); // probably reconfigured |
16446 | 95 |
36309 | 96 res = vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); |
97 // Our draw_slice only works properly if the | |
98 // following filter can do slices. | |
99 vf->draw_slice=vf->next->draw_slice ? draw_slice : NULL; | |
100 return res; | |
16446 | 101 } |
102 | |
24731 | 103 static void write_png(struct vf_priv_s *priv) |
16446 | 104 { |
24731 | 105 char *fname = priv->fname; |
16446 | 106 FILE * fp; |
36753
b3afe52119c4
vf_screenshot: Switch to avcodec_encode_video2 API.
reimar
parents:
36752
diff
changeset
|
107 AVPacket pkt; |
b3afe52119c4
vf_screenshot: Switch to avcodec_encode_video2 API.
reimar
parents:
36752
diff
changeset
|
108 int res, got_pkt; |
16446 | 109 |
110 fp = fopen (fname, "wb"); | |
111 if (fp == NULL) { | |
27947 | 112 mp_msg(MSGT_VFILTER,MSGL_ERR,"\nPNG Error opening %s for writing!\n", fname); |
113 return; | |
16446 | 114 } |
27947 | 115 |
36753
b3afe52119c4
vf_screenshot: Switch to avcodec_encode_video2 API.
reimar
parents:
36752
diff
changeset
|
116 av_init_packet(&pkt); |
b3afe52119c4
vf_screenshot: Switch to avcodec_encode_video2 API.
reimar
parents:
36752
diff
changeset
|
117 pkt.data = priv->outbuffer; |
b3afe52119c4
vf_screenshot: Switch to avcodec_encode_video2 API.
reimar
parents:
36752
diff
changeset
|
118 pkt.size = priv->outbuffer_size; |
b3afe52119c4
vf_screenshot: Switch to avcodec_encode_video2 API.
reimar
parents:
36752
diff
changeset
|
119 res = avcodec_encode_video2(priv->avctx, &pkt, priv->pic, &got_pkt); |
b3afe52119c4
vf_screenshot: Switch to avcodec_encode_video2 API.
reimar
parents:
36752
diff
changeset
|
120 if (res >= 0 && got_pkt && pkt.size > 0) |
b3afe52119c4
vf_screenshot: Switch to avcodec_encode_video2 API.
reimar
parents:
36752
diff
changeset
|
121 fwrite(priv->outbuffer, pkt.size, 1, fp); |
16446 | 122 |
123 fclose (fp); | |
124 } | |
125 | |
126 static int fexists(char *fname) | |
127 { | |
128 struct stat dummy; | |
36750 | 129 return stat(fname, &dummy) == 0; |
16446 | 130 } |
131 | |
16450 | 132 static void gen_fname(struct vf_priv_s* priv) |
16446 | 133 { |
16450 | 134 do { |
36752
af146b0d33f0
Allow specifying custom path and name for screenshot files.
reimar
parents:
36751
diff
changeset
|
135 snprintf(priv->fname, sizeof(priv->fname), "%s%04d.png", priv->prefix, ++priv->frameno); |
16450 | 136 } while (fexists(priv->fname) && priv->frameno < 100000); |
16457 | 137 if (fexists(priv->fname)) { |
27947 | 138 priv->fname[0] = '\0'; |
139 return; | |
16457 | 140 } |
16450 | 141 |
142 mp_msg(MSGT_VFILTER,MSGL_INFO,"*** screenshot '%s' ***\n",priv->fname); | |
143 | |
144 } | |
145 | |
16464
0a828abf1f0f
Fix multiple issues: No picture at all, broken pictures, only every second
reimar
parents:
16457
diff
changeset
|
146 static void scale_image(struct vf_priv_s* priv, mp_image_t *mpi) |
16450 | 147 { |
36753
b3afe52119c4
vf_screenshot: Switch to avcodec_encode_video2 API.
reimar
parents:
36752
diff
changeset
|
148 if (!priv->pic->data[0]) |
b3afe52119c4
vf_screenshot: Switch to avcodec_encode_video2 API.
reimar
parents:
36752
diff
changeset
|
149 priv->pic->data[0] = av_malloc(priv->pic->linesize[0]*priv->dh); |
27947 | 150 |
36753
b3afe52119c4
vf_screenshot: Switch to avcodec_encode_video2 API.
reimar
parents:
36752
diff
changeset
|
151 sws_scale(priv->ctx, mpi->planes, mpi->stride, 0, priv->dh, priv->pic->data, priv->pic->linesize); |
16450 | 152 } |
16446 | 153 |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
154 static void start_slice(struct vf_instance *vf, mp_image_t *mpi) |
27948 | 155 { |
35114
bec9e755fb9b
Fix handling of out-of-order slice rendered frames.
reimar
parents:
34659
diff
changeset
|
156 mpi->priv= |
16464
0a828abf1f0f
Fix multiple issues: No picture at all, broken pictures, only every second
reimar
parents:
16457
diff
changeset
|
157 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, |
27947 | 158 mpi->type, mpi->flags, mpi->width, mpi->height); |
16450 | 159 if (vf->priv->shot) { |
27947 | 160 vf->priv->store_slices = 1; |
36753
b3afe52119c4
vf_screenshot: Switch to avcodec_encode_video2 API.
reimar
parents:
36752
diff
changeset
|
161 if (!vf->priv->pic->data[0]) |
b3afe52119c4
vf_screenshot: Switch to avcodec_encode_video2 API.
reimar
parents:
36752
diff
changeset
|
162 vf->priv->pic->data[0] = av_malloc(vf->priv->pic->linesize[0]*vf->priv->dh); |
16450 | 163 } |
27947 | 164 |
16450 | 165 } |
166 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
167 static void get_image(struct vf_instance *vf, mp_image_t *mpi) |
27948 | 168 { |
16464
0a828abf1f0f
Fix multiple issues: No picture at all, broken pictures, only every second
reimar
parents:
16457
diff
changeset
|
169 // FIXME: should vf.c really call get_image when using slices?? |
0a828abf1f0f
Fix multiple issues: No picture at all, broken pictures, only every second
reimar
parents:
16457
diff
changeset
|
170 if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK) |
0a828abf1f0f
Fix multiple issues: No picture at all, broken pictures, only every second
reimar
parents:
16457
diff
changeset
|
171 return; |
27947 | 172 vf->dmpi= vf_get_image(vf->next, mpi->imgfmt, |
173 mpi->type, mpi->flags/* | MP_IMGFLAG_READABLE*/, mpi->width, mpi->height); | |
16456 | 174 |
16450 | 175 mpi->planes[0]=vf->dmpi->planes[0]; |
176 mpi->stride[0]=vf->dmpi->stride[0]; | |
177 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
27947 | 178 mpi->planes[1]=vf->dmpi->planes[1]; |
179 mpi->planes[2]=vf->dmpi->planes[2]; | |
180 mpi->stride[1]=vf->dmpi->stride[1]; | |
181 mpi->stride[2]=vf->dmpi->stride[2]; | |
16450 | 182 } |
183 mpi->width=vf->dmpi->width; | |
184 | |
185 mpi->flags|=MP_IMGFLAG_DIRECT; | |
27947 | 186 |
36758 | 187 mpi->priv=vf->dmpi; |
16446 | 188 } |
189 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
190 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts) |
16446 | 191 { |
16464
0a828abf1f0f
Fix multiple issues: No picture at all, broken pictures, only every second
reimar
parents:
16457
diff
changeset
|
192 mp_image_t *dmpi = (mp_image_t *)mpi->priv; |
27947 | 193 |
35114
bec9e755fb9b
Fix handling of out-of-order slice rendered frames.
reimar
parents:
34659
diff
changeset
|
194 if(!(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK))){ |
27947 | 195 dmpi=vf_get_image(vf->next,mpi->imgfmt, |
196 MP_IMGTYPE_EXPORT, 0, | |
197 mpi->width, mpi->height); | |
198 vf_clone_mpi_attributes(dmpi, mpi); | |
199 dmpi->planes[0]=mpi->planes[0]; | |
200 dmpi->planes[1]=mpi->planes[1]; | |
201 dmpi->planes[2]=mpi->planes[2]; | |
202 dmpi->stride[0]=mpi->stride[0]; | |
203 dmpi->stride[1]=mpi->stride[1]; | |
204 dmpi->stride[2]=mpi->stride[2]; | |
205 dmpi->width=mpi->width; | |
206 dmpi->height=mpi->height; | |
16450 | 207 } |
16446 | 208 |
209 if(vf->priv->shot) { | |
36756
6e78b4f9569f
vf_screenshot: Simplify repeat screenshot handling logic.
reimar
parents:
36755
diff
changeset
|
210 vf->priv->shot &= ~1; |
27947 | 211 gen_fname(vf->priv); |
212 if (vf->priv->fname[0]) { | |
213 if (!vf->priv->store_slices) | |
214 scale_image(vf->priv, dmpi); | |
215 write_png(vf->priv); | |
216 } | |
217 vf->priv->store_slices = 0; | |
16446 | 218 } |
219 | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
220 return vf_next_put_image(vf, dmpi, pts); |
16446 | 221 } |
222 | |
29702
28fb967d78d8
Mark some functions that do not need external visibility as static.
diego
parents:
29064
diff
changeset
|
223 static int control (vf_instance_t *vf, int request, void *data) |
16446 | 224 { |
19833 | 225 /** data contains an integer argument |
226 * 0: take screenshot with the next frame | |
227 * 1: take screenshots with each frame until the same command is given once again | |
228 **/ | |
16446 | 229 if(request==VFCTRL_SCREENSHOT) { |
27947 | 230 if (data && *(int*)data) { // repeated screenshot mode |
36756
6e78b4f9569f
vf_screenshot: Simplify repeat screenshot handling logic.
reimar
parents:
36755
diff
changeset
|
231 vf->priv->shot ^= 2; |
27947 | 232 } else { // single screenshot |
36756
6e78b4f9569f
vf_screenshot: Simplify repeat screenshot handling logic.
reimar
parents:
36755
diff
changeset
|
233 vf->priv->shot |= 1; |
27947 | 234 } |
16446 | 235 return CONTROL_TRUE; |
236 } | |
237 return vf_next_control (vf, request, data); | |
238 } | |
239 | |
240 | |
241 //===========================================================================// | |
242 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
243 static int query_format(struct vf_instance *vf, unsigned int fmt) |
16446 | 244 { |
245 switch(fmt){ | |
246 case IMGFMT_YV12: | |
247 case IMGFMT_I420: | |
248 case IMGFMT_IYUV: | |
249 case IMGFMT_UYVY: | |
250 case IMGFMT_YUY2: | |
251 case IMGFMT_BGR32: | |
252 case IMGFMT_BGR24: | |
253 case IMGFMT_BGR16: | |
254 case IMGFMT_BGR15: | |
31082
92f88bb315c5
Add support for 12-bit color mode on framebuffer devices.
cehoyos
parents:
31003
diff
changeset
|
255 case IMGFMT_BGR12: |
16446 | 256 case IMGFMT_RGB32: |
257 case IMGFMT_RGB24: | |
27947 | 258 case IMGFMT_Y800: |
259 case IMGFMT_Y8: | |
260 case IMGFMT_YVU9: | |
261 case IMGFMT_IF09: | |
262 case IMGFMT_444P: | |
263 case IMGFMT_422P: | |
264 case IMGFMT_411P: | |
265 return vf_next_query_format(vf, fmt); | |
16446 | 266 } |
267 return 0; | |
268 } | |
269 | |
27949
88d793e52bd9
cosmetics: Move up uninit() to avoid a forward declaration.
diego
parents:
27948
diff
changeset
|
270 static void uninit(vf_instance_t *vf) |
88d793e52bd9
cosmetics: Move up uninit() to avoid a forward declaration.
diego
parents:
27948
diff
changeset
|
271 { |
30143 | 272 avcodec_close(vf->priv->avctx); |
27949
88d793e52bd9
cosmetics: Move up uninit() to avoid a forward declaration.
diego
parents:
27948
diff
changeset
|
273 av_freep(&vf->priv->avctx); |
88d793e52bd9
cosmetics: Move up uninit() to avoid a forward declaration.
diego
parents:
27948
diff
changeset
|
274 if(vf->priv->ctx) sws_freeContext(vf->priv->ctx); |
36753
b3afe52119c4
vf_screenshot: Switch to avcodec_encode_video2 API.
reimar
parents:
36752
diff
changeset
|
275 av_freep(&vf->priv->pic->data[0]); |
b3afe52119c4
vf_screenshot: Switch to avcodec_encode_video2 API.
reimar
parents:
36752
diff
changeset
|
276 av_frame_free(&vf->priv->pic); |
36755 | 277 av_freep(&vf->priv->outbuffer); |
36752
af146b0d33f0
Allow specifying custom path and name for screenshot files.
reimar
parents:
36751
diff
changeset
|
278 free(vf->priv->prefix); |
27949
88d793e52bd9
cosmetics: Move up uninit() to avoid a forward declaration.
diego
parents:
27948
diff
changeset
|
279 free(vf->priv); |
88d793e52bd9
cosmetics: Move up uninit() to avoid a forward declaration.
diego
parents:
27948
diff
changeset
|
280 } |
88d793e52bd9
cosmetics: Move up uninit() to avoid a forward declaration.
diego
parents:
27948
diff
changeset
|
281 |
30638
a7b908875c14
Rename open() vf initialization function to vf_open().
diego
parents:
30421
diff
changeset
|
282 static int vf_open(vf_instance_t *vf, char *args) |
16446 | 283 { |
284 vf->config=config; | |
285 vf->control=control; | |
286 vf->put_image=put_image; | |
287 vf->query_format=query_format; | |
16450 | 288 vf->start_slice=start_slice; |
289 vf->draw_slice=draw_slice; | |
290 vf->get_image=get_image; | |
16874 | 291 vf->uninit=uninit; |
36754 | 292 vf->priv = calloc(1, sizeof(struct vf_priv_s)); |
36753
b3afe52119c4
vf_screenshot: Switch to avcodec_encode_video2 API.
reimar
parents:
36752
diff
changeset
|
293 vf->priv->pic = av_frame_alloc(); |
36752
af146b0d33f0
Allow specifying custom path and name for screenshot files.
reimar
parents:
36751
diff
changeset
|
294 vf->priv->prefix = strdup(args ? args : "shot"); |
24731 | 295 avcodec_register_all(); |
37143
88b4aa330150
Ensure dimensions are set before opening libavcodec encoder.
reimar
parents:
36758
diff
changeset
|
296 if (!avcodec_find_encoder(AV_CODEC_ID_PNG)) { |
88b4aa330150
Ensure dimensions are set before opening libavcodec encoder.
reimar
parents:
36758
diff
changeset
|
297 mp_msg(MSGT_VFILTER, MSGL_FATAL, "Could not find libavcodec PNG encoder\n"); |
24731 | 298 return 0; |
299 } | |
16446 | 300 return 1; |
301 } | |
302 | |
303 | |
25221 | 304 const vf_info_t vf_info_screenshot = { |
16446 | 305 "screenshot to file", |
306 "screenshot", | |
307 "A'rpi, Jindrich Makovicka", | |
308 "", | |
30638
a7b908875c14
Rename open() vf initialization function to vf_open().
diego
parents:
30421
diff
changeset
|
309 vf_open, |
16446 | 310 NULL |
311 }; | |
312 | |
313 //===========================================================================// |