[FFmpeg-devel] [PATCH] avformat/concatdec: add concat_seekable operation

Steven Liu lingjiujianke at gmail.com
Sat Mar 18 14:18:02 EET 2017


2017-03-18 18:52 GMT+08:00 Marton Balint <cus at passwd.hu>:

>
> On Sat, 18 Mar 2017, Steven Liu wrote:
>
> when use stream_loop to control the loop times, the seekable is
>> set to 0 default, and must set duration or inpoint and outpoint
>> into the concat list, now use this option can support use stream_loop
>> to control the loop times of the concat list
>>
>
> I am not sure I understand the use case. But how can you support seek in a
> file, which you do not know how long is? You simply won't know which
> segment you want to seek in.
>
you can try it:
echo "file 'inputfile1.mp4'" > concat input.concatfile
echo "file 'inputfile2.mp4'" >> concat input.concatfile
ffmpeg -stream_loop -1 -f concat input.concatfile -c copy output.ts
it only 1 once to read the list, but the -stream_loop -1 is unlimited times.
the i saw the code only set the seekable when the list file has set
duration, or inpoint and outpoint,
so this patch is used to set seekable to true, only set by user.

>
> The only thing you might support is seeking into 0. Nothing else, so all
> other seek commands must fail. But you don't need a separate option to
> support that, you simply can add that feature.
>
> Regards,
> Marton
>
>
>
>> Signed-off-by: Steven Liu <lq at chinaffmpeg.org>
>> ---
>> doc/demuxers.texi       | 5 +++++
>> libavformat/concatdec.c | 5 +++++
>> 2 files changed, 10 insertions(+)
>>
>> diff --git a/doc/demuxers.texi b/doc/demuxers.texi
>> index 29a23d4..eb0e67d 100644
>> --- a/doc/demuxers.texi
>> +++ b/doc/demuxers.texi
>> @@ -207,6 +207,11 @@ 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.
>>
>> + at item concat_seekable
>> +If set to 1, the seek operation will be enabled, user can use
>> stream_loop to control
>> +loop times.
>> +The default is 0.
>> +
>> @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
>> diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
>> index 8649916..0a61af1 100644
>> --- a/libavformat/concatdec.c
>> +++ b/libavformat/concatdec.c
>> @@ -493,6 +493,9 @@ static int concat_read_header(AVFormatContext *avf)
>>         cat->seekable = 1;
>>     }
>>
>> +    if (cat->seekable) {
>> +        cat->seekable = 1;
>> +    }
>>     cat->stream_match_mode = avf->nb_streams ? MATCH_EXACT_ID :
>>                                                MATCH_ONE_TO_ONE;
>>     if ((ret = open_file(avf, 0)) < 0)
>> @@ -771,6 +774,8 @@ static const AVOption options[] = {
>>       OFFSET(auto_convert), AV_OPT_TYPE_BOOL, {.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 },
>> +    { "concat_seekable", "set seekable status of concat list",
>> +      OFFSET(seekable), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DEC },
>>     { NULL }
>> };
>>
>> --
>> 2.10.1 (Apple Git-78)
>>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


More information about the ffmpeg-devel mailing list