[FFmpeg-devel] [PATCH]lavf/img2enc: Allow to reverse frame order

Carl Eugen Hoyos cehoyos at ag.or.at
Tue Feb 23 16:39:02 CET 2016


Hi!

As requested on ffmpeg-user.

Please comment, Carl Eugen
-------------- next part --------------
diff --git a/doc/muxers.texi b/doc/muxers.texi
index f2ad7fe..6ccbab1 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -522,6 +522,10 @@ overwritten with new images. Default value is 0.
 @item strftime
 If set to 1, expand the filename with date and time information from
 @code{strftime()}. Default value is 0.
+
+ at item reverse
+If set to 1, the sequence number will be decreased for every image.
+It is recommended to set a (high) @option(start_number) when using this option.
 @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 ebbac2b..f664cb7 100644
--- a/libavformat/img2enc.c
+++ b/libavformat/img2enc.c
@@ -44,6 +44,7 @@ typedef struct VideoMuxData {
     int use_strftime;
     const char *muxer;
     int use_rename;
+    int reverse;
 } VideoMuxData;
 
 static int write_header(AVFormatContext *s)
@@ -182,7 +183,11 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
         }
     }
 
-    img->img_number++;
+    if (img->reverse) {
+        img->img_number--;
+    } else {
+        img->img_number++;
+    }
     return 0;
 }
 
@@ -205,6 +210,7 @@ static const AVOption muxoptions[] = {
     { "start_number", "set first number in the sequence", OFFSET(img_number), AV_OPT_TYPE_INT,  { .i64 = 1 }, 0, INT_MAX, ENC },
     { "strftime",     "use strftime for filename", OFFSET(use_strftime),  AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC },
     { "atomic_writing", "write files atomically (using temporary files and renames)", OFFSET(use_rename), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC },
+    { "reverse", "decrease the sequence number with every image", OFFSET(reverse), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC },
     { NULL },
 };
 


More information about the ffmpeg-devel mailing list