diff options
author | Marton Balint <cus@passwd.hu> | 2015-10-24 18:16:11 +0300 |
---|---|---|
committer | Marton Balint <cus@passwd.hu> | 2015-11-25 02:34:29 +0300 |
commit | 65406b0bedb4cbd9ce82aae45994362ec5b01df1 (patch) | |
tree | 24692774fb7c79a9cb682ee89ac33a84d9c0419d | |
parent | ba9191ab3a51e2127ecf915dc0d803500b7cbcf0 (diff) |
concatdec: add option for adding segment start time and duration metadata
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Marton Balint <cus@passwd.hu>
-rw-r--r-- | doc/demuxers.texi | 8 | ||||
-rw-r--r-- | libavformat/concatdec.c | 10 |
2 files changed, 18 insertions, 0 deletions
diff --git a/doc/demuxers.texi b/doc/demuxers.texi index 34bfc9bf38..349b531357 100644 --- a/doc/demuxers.texi +++ b/doc/demuxers.texi @@ -204,6 +204,14 @@ Currently, the only conversion is adding the h264_mp4toannexb bitstream filter to H.264 streams in MP4 format. This is necessary in particular if there are resolution changes. +@item segment_time_metadata +If set to 1, every packet will contain the @var{lavf.concat.start_time} and the +@var{lavf.concat.duration} packet metadata values which are the start_time and +the duration of the respective file segments in the concatenated output +expressed in microseconds. The duration metadata is only set if it is known +based on the concat file. +The default is 0. + @end table @section flv diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c index 169394122f..297947ccb8 100644 --- a/libavformat/concatdec.c +++ b/libavformat/concatdec.c @@ -62,6 +62,7 @@ typedef struct { int eof; ConcatMatchMode stream_match_mode; unsigned auto_convert; + int segment_time_metadata; } ConcatContext; static int concat_probe(AVProbeData *probe) @@ -318,6 +319,13 @@ static int open_file(AVFormatContext *avf, unsigned fileno) file->file_inpoint = (file->inpoint == AV_NOPTS_VALUE) ? file->file_start_time : file->inpoint; if (file->duration == AV_NOPTS_VALUE && file->outpoint != AV_NOPTS_VALUE) file->duration = file->outpoint - file->file_inpoint; + + if (cat->segment_time_metadata) { + av_dict_set_int(&file->metadata, "lavf.concatdec.start_time", file->start_time, 0); + if (file->duration != AV_NOPTS_VALUE) + av_dict_set_int(&file->metadata, "lavf.concatdec.duration", file->duration, 0); + } + if ((ret = match_streams(avf)) < 0) return ret; if (file->inpoint != AV_NOPTS_VALUE) { @@ -701,6 +709,8 @@ static const AVOption options[] = { OFFSET(safe), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, DEC }, { "auto_convert", "automatically convert bitstream format", OFFSET(auto_convert), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, DEC }, + { "segment_time_metadata", "output file segment start time and duration as packet metadata", + OFFSET(segment_time_metadata), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DEC }, { NULL } }; |