[FFmpeg-devel] [PATCHv2 4/4] avformat/concatdec: always re-calculate start time and duration

Nicolas George george at nsup.org
Fri Jan 4 15:41:17 EET 2019


Marton Balint (12018-12-30):
> This allows the underlying files to change their duration on subsequent
> avformat context opens.
> 
> An example use case where this matters:
> 
> ffconcat version 1.0
> file dummy.mxf
> file dummy.mxf
> 
> ffmpeg -re -stream_loop -1 -i dummy.ffconcat -f sdl2 none
> 
> The user can seamlessly change the input by atomically replacing dummy.mxf.
> 
> v2: Set ConcatFile duration in read_header for all segments with known
> durations because from now on we always recalculate the start time in
> open_file, and an instant seek could have caused unset ConcatFile durations.
> 
> Signed-off-by: Marton Balint <cus at passwd.hu>
> ---
>  libavformat/concatdec.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)

I am sorry, but it still feels like a fragile solution, and I think it
can leave the context in an inconsistent state. Maybe it works now, but
it is a bad surprise left for somebody who wants to extend this demuxer
in another way later.

Also, I think the duration detected from the file should never override
the duration provided by the script.

What about this:

	if the user_duration is set to a special value then
	  each time the file is opened and closed
	    if the duration has changed
	      update the duration
	      update the start time of all subsequent files

?

The "user_duration is set to a special value" condition also addresses
another concern I have: this feature conflicts with the (net yet
implemented) option of keeping the files open, as a LRU-style
optimization for when much seeking is expected.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20190104/a88151eb/attachment.sig>


More information about the ffmpeg-devel mailing list