[FFmpeg-cvslog] img2enc: add option to use strftime() for filename

Ramiro Polla git at videolan.org
Fri Jul 19 02:10:12 CEST 2013


ffmpeg | branch: master | Ramiro Polla <ramiro.polla at gmail.com> | Thu Jul 18 19:17:11 2013 -0300| [454c89dde3afd8f84d2631dd87da47bf23de3fe3] | committer: Michael Niedermayer

img2enc: add option to use strftime() for filename

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=454c89dde3afd8f84d2631dd87da47bf23de3fe3
---

 libavformat/img2enc.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
index 11e5801..7b10623 100644
--- a/libavformat/img2enc.c
+++ b/libavformat/img2enc.c
@@ -37,6 +37,7 @@ typedef struct {
     int split_planes;       /**< use independent file for each Y, U, V plane */
     char path[1024];
     int update;
+    int use_strftime;
 } VideoMuxData;
 
 static int write_header(AVFormatContext *s)
@@ -77,6 +78,15 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
     if (!img->is_pipe) {
         if (img->update) {
             av_strlcpy(filename, img->path, sizeof(filename));
+        } else if (img->use_strftime) {
+            time_t now0;
+            struct tm *tm;
+            time(&now0);
+            tm = localtime(&now0);
+            if (!strftime(filename, sizeof(filename), img->path, tm)) {
+                av_log(s, AV_LOG_ERROR, "Could not get frame filename with strftime\n");
+                return AVERROR(EINVAL);
+            }
         } 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,
@@ -133,6 +143,7 @@ static const AVOption muxoptions[] = {
     { "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 },
+    { "strftime",     "use strftime for filename", OFFSET(use_strftime), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, ENC },
     { NULL },
 };
 



More information about the ffmpeg-cvslog mailing list