[FFmpeg-devel] [PATCH] lavf/segment: do not set default value for segment_time option

Stefano Sabatini stefasab at gmail.com
Sun Mar 15 12:22:59 CET 2015


Also allows a negative value to allow to never split the input.

This changes the default behavior, to never split the input if an
explicit value is not set.

TODO: bump micro.
---
 doc/muxers.texi       | 11 +++++++----
 libavformat/segment.c |  9 ++++-----
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index a8225fc..fe419ac 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -966,8 +966,11 @@ If not specified the type is guessed from the list file name suffix.
 
 @item segment_time @var{time}
 Set segment duration to @var{time}, the value must be a duration
-specification. Default value is "2". See also the
- at option{segment_times} option.
+specification. A value of 0 means that it will try to split the
+segment as soon as possible. A negative value make the muxer never
+splits. If not specified, assumes a negative value.
+
+See also the @option{segment_times} option.
 
 Note that splitting may not be accurate, unless you force the
 reference stream key-frames at the given time. See the introductory
@@ -1049,7 +1052,7 @@ Remux the content of file @file{in.mkv} to a list of segments
 @file{out-000.nut}, @file{out-001.nut}, etc., and write the list of
 generated segments to @file{out.list}:
 @example
-ffmpeg -i in.mkv -codec copy -map 0 -f segment -segment_list out.list out%03d.nut
+ffmpeg -i in.mkv -codec copy -map 0 -f segment -segment_time 2 -segment_list out.list out%03d.nut
 @end example
 
 @item
@@ -1088,7 +1091,7 @@ ffmpeg -i in.mkv -codec copy -map 0 -f segment -segment_list out.csv -segment_fr
 Convert the @file{in.mkv} to TS segments using the @code{libx264}
 and @code{libfaac} encoders:
 @example
-ffmpeg -i in.mkv -map 0 -codec:v libx264 -codec:a libfaac -f ssegment -segment_list out.list out%03d.ts
+ffmpeg -i in.mkv -map 0 -codec:v libx264 -codec:a libfaac -f ssegment -segment_time 2 -segment_list out.list out%03d.ts
 @end example
 
 @item
diff --git a/libavformat/segment.c b/libavformat/segment.c
index b65a2eb..8255843 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -606,16 +606,15 @@ static int seg_write_header(AVFormatContext *s)
     } else if (seg->frames_str) {
         if ((ret = parse_frames(s, &seg->frames, &seg->nb_frames, seg->frames_str)) < 0)
             return ret;
-    } else {
-        /* set default value if not specified */
-        if (!seg->time_str)
-            seg->time_str = av_strdup("2");
+    } else if (seg->time_str) {
         if ((ret = av_parse_time(&seg->time, seg->time_str, 1)) < 0) {
             av_log(s, AV_LOG_ERROR,
                    "Invalid time duration specification '%s' for segment_time option\n",
                    seg->time_str);
             return ret;
         }
+    } else {
+        seg->time = -1;
     }
 
     if (seg->format_options_str) {
@@ -738,7 +737,7 @@ static int seg_write_packet(AVFormatContext *s, AVPacket *pkt)
     } else if (seg->frames) {
         start_frame = seg->segment_count < seg->nb_frames ?
             seg->frames[seg->segment_count] : INT_MAX;
-    } else {
+    } else if (seg->time >= 0) {
         if (seg->use_clocktime) {
             int64_t avgt = av_gettime();
             time_t sec = avgt / 1000000;
-- 
1.8.3.2



More information about the ffmpeg-devel mailing list