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

Submitted by Steven Liu on March 18, 2017, 4 a.m.

Details

Message ID 20170318040032.8953-1-lq@chinaffmpeg.org
State New
Headers show

Commit Message

Steven Liu March 18, 2017, 4 a.m.
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

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 doc/demuxers.texi       | 5 +++++
 libavformat/concatdec.c | 5 +++++
 2 files changed, 10 insertions(+)

Comments

Marton Balint March 18, 2017, 10:52 a.m.
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.

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@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.
> 
> +@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)
Steven Liu March 18, 2017, 12:18 p.m.
2017-03-18 18:52 GMT+08:00 Marton Balint <cus@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@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.
>>
>> +@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@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
Nicolas George March 18, 2017, 12:35 p.m.
L'octidi 28 ventôse, an CCXXV, Steven Liu a écrit :
> 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

Please try actual seeking to random points of this virtual file. I
expect you will find that it does not work reliably.

Regards,
Steven Liu March 18, 2017, 12:45 p.m.
Nicolas George <george@nsup.org>于2017年3月18日 周六下午8:35写道:

> L'octidi 28 ventôse, an CCXXV, Steven Liu a écrit :
> > 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
>
> Please try actual seeking to random points of this virtual file. I
> expect you will find that it does not work reliably.
>
> Regards,
>
> --
>   Nicolas George
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


mhmm dose there have any way to support the stream loop all the file list?

> <http://ffmpeg.org/mailman/listinfo/ffmpeg-devel>
>
wm4 March 18, 2017, 1:01 p.m.
On Sat, 18 Mar 2017 12:45:34 +0000
Steven Liu <lingjiujianke@gmail.com> wrote:

> Nicolas George <george@nsup.org>于2017年3月18日 周六下午8:35写道:
> 
> > L'octidi 28 ventôse, an CCXXV, Steven Liu a écrit :  
> > > 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  
> >
> > Please try actual seeking to random points of this virtual file. I
> > expect you will find that it does not work reliably.
> >
> > Regards,
> >
> > --
> >   Nicolas George
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel  
> 
> 
> mhmm dose there have any way to support the stream loop all the file list?

Is this for some adaptive streaming thing, like maybe DASH?
Steven Liu March 18, 2017, 1:05 p.m.
2017-03-18 21:01 GMT+08:00 wm4 <nfxjfg@googlemail.com>:

> On Sat, 18 Mar 2017 12:45:34 +0000
> Steven Liu <lingjiujianke@gmail.com> wrote:
>
> > Nicolas George <george@nsup.org>于2017年3月18日 周六下午8:35写道:
> >
> > > L'octidi 28 ventôse, an CCXXV, Steven Liu a écrit :
> > > > 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
> > >
> > > Please try actual seeking to random points of this virtual file. I
> > > expect you will find that it does not work reliably.
> > >
> > > Regards,
> > >
> > > --
> > >   Nicolas George
> > > _______________________________________________
> > > ffmpeg-devel mailing list
> > > ffmpeg-devel@ffmpeg.org
> > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> >
> > mhmm dose there have any way to support the stream loop all the file
> list?
>
> Is this for some adaptive streaming thing, like maybe DASH?
>

No, Just input many files into a list ,and loop to read and concat them to
publish rtmp.
maybe the option name from concat_seekable to concat_reset will better?

> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
Nicolas George March 18, 2017, 1:33 p.m.
L'octidi 28 ventôse, an CCXXV, Steven Liu a écrit :
> mhmm dose there have any way to support the stream loop all the file list?

I think the second paragraph of Marton's mail addressed exactly that.

Regards,
Steven Liu March 18, 2017, 2:10 p.m.
2017-03-18 21:33 GMT+08:00 Nicolas George <george@nsup.org>:

> L'octidi 28 ventôse, an CCXXV, Steven Liu a écrit :
> > mhmm dose there have any way to support the stream loop all the file
> list?
>
> I think the second paragraph of Marton's mail addressed exactly that.
>
Yes, I think so too :D

>
> Regards,
>
> --
>   Nicolas George
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
Steven Liu March 18, 2017, 2:14 p.m.
2017-03-18 21:33 GMT+08:00 Nicolas George <george@nsup.org>:

> L'octidi 28 ventôse, an CCXXV, Steven Liu a écrit :
> > mhmm dose there have any way to support the stream loop all the file
> list?
>
> I think the second paragraph of Marton's mail addressed exactly that.
>
Hi  Nicolas George,

        Can the concat support network stream?
        I use it only support local files now, maybe better support network
stream and local files complex.

Regards,
>
> --
>   Nicolas George
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
Nicolas George March 19, 2017, 9:58 a.m.
L'octidi 28 ventôse, an CCXXV, Steven Liu a écrit :
>         Can the concat support network stream?

As you can see, the concat demuxer does not contain any code specific to
the protocol, or even to the demuxer. It should therefore work with any
demuxer, and in turn protocol, provided it is reliable enough.

Regards,

Patch hide | download patch | download mbox

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.
 
+@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 }
 };