diff --git a/doc/muxers.texi b/doc/muxers.texi index 9d119c39a1..f1274948f8 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -245,9 +245,11 @@ ffmpeg -i in.avi -f image2 -frames:v 1 img.jpeg Start the sequence from @var{number}. Default value is 1. Must be a positive number. -@item updatefirst 1|0 -If set to 1, update the first written image file again and -again. Default value is 0. +@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 The image muxer supports the .Y.U.V image file format. This format is diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c index 67b5819dc9..fb297da20b 100644 --- a/libavformat/img2enc.c +++ b/libavformat/img2enc.c @@ -36,7 +36,7 @@ typedef struct { int is_pipe; int split_planes; /**< use independent file for each Y, U, V plane */ char path[1024]; - int updatefirst; + int update; } VideoMuxData; static int write_header(AVFormatContext *s) @@ -75,8 +75,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 && !img->updatefirst) { + 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' (either set updatefirst or use a pattern like %%03d within the filename pattern)\n", img->img_number, img->path); @@ -128,7 +130,8 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) #define OFFSET(x) offsetof(VideoMuxData, x) #define ENC AV_OPT_FLAG_ENCODING_PARAM static const AVOption muxoptions[] = { - { "updatefirst", "update the first image file", OFFSET(updatefirst), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, ENC }, + { "updatefirst", "continuously overwrite one file", OFFSET(update), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, ENC }, + { "update", "continuously overwrite one file", OFFSET(update), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, ENC }, { "start_number", "set first number in the sequence", OFFSET(img_number), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, INT_MAX, ENC }, { NULL }, };