[FFmpeg-cvslog] lavf/concatdec: add the "duration" directive.

Nicolas George git at videolan.org
Sun Feb 24 13:14:33 CET 2013


ffmpeg | branch: master | Nicolas George <nicolas.george at normalesup.org> | Wed Feb 13 17:25:56 2013 +0100| [ea2de3d09614fcfe53b9406cce57a1bf8cf6d5cd] | committer: Nicolas George

lavf/concatdec: add the "duration" directive.

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

 doc/demuxers.texi       |    7 +++++++
 libavformat/concatdec.c |   15 +++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index e4c358c..c8eec21 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -56,6 +56,8 @@ following directive is recognized:
 Path to a file to read; special characters and spaces must be escaped with
 backslash or single quotes.
 
+All subsequent directives apply to that file.
+
 @item @code{ffconcat version 1.0}
 Identify the script type and version. It also sets the @option{safe} option
 to 1 if it was to its default -1.
@@ -64,6 +66,11 @@ To make FFmpeg recognize the format automatically, this directive must
 appears exactly as is (no extra space or byte-order-mark) on the very first
 line of the script.
 
+ at item @code{duration @var{dur}}
+Duration of the file. This information can be specified from the file;
+specifying it here may be more efficient or help if the information from the
+file is not available or accurate.
+
 @end table
 
 @subsection Options
diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index f1fb169..2858bef 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -20,6 +20,7 @@
 
 #include "libavutil/avstring.h"
 #include "libavutil/opt.h"
+#include "libavutil/parseutils.h"
 #include "avformat.h"
 #include "internal.h"
 
@@ -174,6 +175,20 @@ static int concat_read_header(AVFormatContext *avf)
             }
             if ((ret = add_file(avf, filename, &file, &nb_files_alloc)) < 0)
                 FAIL(ret);
+        } else if (!strcmp(keyword, "duration")) {
+            char *dur_str = get_keyword(&cursor);
+            int64_t dur;
+            if (!file) {
+                av_log(avf, AV_LOG_ERROR, "Line %d: duration without file\n",
+                       line);
+                FAIL(AVERROR_INVALIDDATA);
+            }
+            if ((ret = av_parse_time(&dur, dur_str, 1)) < 0) {
+                av_log(avf, AV_LOG_ERROR, "Line %d: invalid duration '%s'\n",
+                       line, dur_str);
+                FAIL(ret);
+            }
+            file->duration = dur;
         } else if (!strcmp(keyword, "ffconcat")) {
             char *ver_kw  = get_keyword(&cursor);
             char *ver_val = get_keyword(&cursor);



More information about the ffmpeg-cvslog mailing list