[Libav-user] Reducing latency of file opening (when playing from http)

Kalileo kalileo at universalx.net
Sun May 12 22:17:45 CEST 2013


On May 12, 2013, at 22:43 , Carl Eugen Hoyos wrote:

> Kalileo <kalileo at ...> writes:
> 
>> This is also what I noticed, when playing with 
>> probesize and analyzeduration trying to get the 
>> player to start more quickly (using mpegts 
>> (h264/aac) streams served through a memory buffer).
> 
> Since I did not really understand the paragraph I cut:
> Do you mean that although you used -probesize and 
> -analyzeduration, the time to probe a file did not 
> change?

That was my impression, yes.

> If yes, this sounds like a serious bug that should be 
> investigated.
> (Needs command line, console output etc.)

I'm not talking about ffmpeg command line, but about using the ffmpeg libraries in own code. 

> 
>> This leads to the question why does a known stream 
> 
> (What is a "known" stream?)

That is a stream from which I know exactly all parameters, codecs, container, all details.
Which means I should be able to set these details, instead of probing them.

> 
>> need to get probed / analyzed at all?
> 
> I may miss something but I wonder how you want to 
> demux a transport stream without some probing / 
> there are many tickets from people who miss their 
> subtitle streams when opening their file…

Sure, however if it is a stream which I created, encoded, then I should not need to probe, I know already how I encoded it.

> 
> Additionally, user streams without PAT and/or PMT 
> are not unusual (there used to be a bug in *zap 
> for many years), so careful probing in transport 
> streams is particularly important afaict.

Yes, understood. The streams I'm using do have PAT/PMT, and the first chunk of the stream which I feed to the player always starts with PAT/PMT, and the first video frame after that is a key frame.

Therefore I think it should be possible to manually set all what  avformat_find_stream_info is setting, and to skip feeding the stream to  avformat_find_stream_info.

In my case the input is mpegts in chunks starting with PAT/PMT, which I encode myself, so I know all encoding details. The steps are:

 avio_alloc_context()
 av_find_input_format()
 avformat_alloc_context()
 avformat_open_input()
 avformat_find_stream_info()  <== this should be not needed if I set all required codec params.

and then for video and again for audio:
 avcodec_find_decoder()
 avcodec_open2()


However if I don't run avformat_find_stream_info() it sometimes works and sometimes not. Obviously I miss something what  avformat_find_stream_info() is doing.

Just to avoid any misunderstanding, it all works fine, and now I try to optimize it, to speed it up, and to avoid the delay caused by avformat_find_stream_info() by removing the requirement to run it.





More information about the Libav-user mailing list