diff options
author | Anton Khirnov <anton@khirnov.net> | 2013-04-04 22:57:58 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2013-04-11 12:30:44 +0200 |
commit | 9e6b5e61a0c91e25e298d0a21b189c4c95443795 (patch) | |
tree | c3c777417919c3db65daf0a8c5be563796e09752 | |
parent | ac9362c5d985ca37d4debb4e0e12497d248ec9d1 (diff) | |
download | ffmpeg-9e6b5e61a0c91e25e298d0a21b189c4c95443795.tar.gz |
img2enc: add an option for overwriting one file with subsequent images
Based on a patch by Michael Niedermayer <michaelni@gmx.at>.
-rw-r--r-- | doc/muxers.texi | 6 | ||||
-rw-r--r-- | libavformat/img2enc.c | 8 |
2 files changed, 12 insertions, 2 deletions
diff --git a/doc/muxers.texi b/doc/muxers.texi index b2390e21c2..3f84450cfa 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -171,6 +171,12 @@ avconv -i in.avi -f image2 -frames:v 1 img.jpeg @table @option @item -start_number @var{number} Start the sequence from @var{number}. + +@item -update @var{number} +If @var{number} is nonzero, the filename will always be interpreted as just a +filename, not a pattern, and this file will be continuously overwritten with new +images. + @end table @section MOV/MP4/ISMV diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c index aed61d97f9..7b94869c56 100644 --- a/libavformat/img2enc.c +++ b/libavformat/img2enc.c @@ -33,6 +33,7 @@ typedef struct { int img_number; int is_pipe; char path[1024]; + int update; } VideoMuxData; static int write_header(AVFormatContext *s) @@ -59,8 +60,10 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) int i; if (!img->is_pipe) { - if (av_get_frame_filename(filename, sizeof(filename), - img->path, img->img_number) < 0 && img->img_number > 1) { + if (img->update) { + av_strlcpy(filename, img->path, sizeof(filename)); + } else if (av_get_frame_filename(filename, sizeof(filename), img->path, img->img_number) < 0 && + img->img_number > 1) { av_log(s, AV_LOG_ERROR, "Could not get frame filename number %d from pattern '%s'\n", img->img_number, img->path); @@ -128,6 +131,7 @@ error: #define ENC AV_OPT_FLAG_ENCODING_PARAM static const AVOption muxoptions[] = { { "start_number", "first number in the sequence", OFFSET(img_number), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, INT_MAX, ENC }, + { "update", "continuously overwrite one file", OFFSET(update), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, ENC }, { NULL }, }; |