Based on a patch by Michael Niedermayer <michaelni@gmx.at>.
Anton Khirnov authored on 2013/04/05 05:57:58... | ... |
@@ -171,6 +171,12 @@ avconv -i in.avi -f image2 -frames:v 1 img.jpeg |
171 | 171 |
@table @option |
172 | 172 |
@item -start_number @var{number} |
173 | 173 |
Start the sequence from @var{number}. |
174 |
+ |
|
175 |
+@item -update @var{number} |
|
176 |
+If @var{number} is nonzero, the filename will always be interpreted as just a |
|
177 |
+filename, not a pattern, and this file will be continuously overwritten with new |
|
178 |
+images. |
|
179 |
+ |
|
174 | 180 |
@end table |
175 | 181 |
|
176 | 182 |
@section MOV/MP4/ISMV |
... | ... |
@@ -33,6 +33,7 @@ typedef struct { |
33 | 33 |
int img_number; |
34 | 34 |
int is_pipe; |
35 | 35 |
char path[1024]; |
36 |
+ int update; |
|
36 | 37 |
} VideoMuxData; |
37 | 38 |
|
38 | 39 |
static int write_header(AVFormatContext *s) |
... | ... |
@@ -59,8 +60,10 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) |
59 | 59 |
int i; |
60 | 60 |
|
61 | 61 |
if (!img->is_pipe) { |
62 |
- if (av_get_frame_filename(filename, sizeof(filename), |
|
63 |
- img->path, img->img_number) < 0 && img->img_number > 1) { |
|
62 |
+ if (img->update) { |
|
63 |
+ av_strlcpy(filename, img->path, sizeof(filename)); |
|
64 |
+ } else if (av_get_frame_filename(filename, sizeof(filename), img->path, img->img_number) < 0 && |
|
65 |
+ img->img_number > 1) { |
|
64 | 66 |
av_log(s, AV_LOG_ERROR, |
65 | 67 |
"Could not get frame filename number %d from pattern '%s'\n", |
66 | 68 |
img->img_number, img->path); |
... | ... |
@@ -128,6 +131,7 @@ error: |
128 | 128 |
#define ENC AV_OPT_FLAG_ENCODING_PARAM |
129 | 129 |
static const AVOption muxoptions[] = { |
130 | 130 |
{ "start_number", "first number in the sequence", OFFSET(img_number), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, INT_MAX, ENC }, |
131 |
+ { "update", "continuously overwrite one file", OFFSET(update), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, ENC }, |
|
131 | 132 |
{ NULL }, |
132 | 133 |
}; |
133 | 134 |
|