[Libav-user] avformat_find_stream_info/avformat_open_input speed

Nikola Spiric nikola.spiric.ns at gmail.com
Mon May 15 12:09:23 EEST 2017


I've been using FFMPEG as a demultiplexer. Meaning I'm only using it to 
analyze an MPEG2 transport stream ( retrieving basic information such as 
video width/height/H.264 extradata etc), and extract frames to be 
decoded by another API.

However avformat_find_stream_info and avformat_open_input take way too 
long (about 5 seconds for 2K streams). These functions seem to consume 
way too much data than necessary (around 4MB).

I tried reducing "probesize" and "analyzeduration" parameters with mixed 
results. Sometimes it indeed does speed up mentioned function calls; 
however they often just result in the functions failing (i.e. they don't 
get enough data to provide me with all the information I need).

So my question is: Is there a way to tell FFMPEG to stop analyzing the 
stream once it gathers all the basic information (video width/height, 
h.264/HEVC extra data or audio sample rate/number of channels) ?

I really need a way of speeding up these two function calls (5 seconds 
is not acceptable for my needs).

Thanks in advance,

More information about the Libav-user mailing list