[Libav-user] avformat_find_stream_info/avformat_open_input speed

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Libav-user] avformat_find_stream_info/avformat_open_input speed

Nikola Spiric
Hello,

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,
Nikola
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Libav-user] avformat_find_stream_info/avformat_open_input speed

Nikola Spiric
Hello,

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,
Nikola

_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: avformat_find_stream_info/avformat_open_input speed

Carl Eugen Hoyos-2
In reply to this post by Nikola Spiric
2017-05-15 11:09 GMT+02:00 Nikola Spiric <[hidden email]>:

> 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).

Yes, there is no free lunch.
You will have to find values that work for you and are smaller than
the default.

> 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) ?

How do you know you have gathered "all the basic information" of
a transport stream?
(There was a sample stream for which -probesize 2G was not enough
so we increased the range for the option.)

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

5 seconds seem extremely long on current hardware.

Carl Eugen
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: avformat_find_stream_info/avformat_open_input speed

Nikola Spiric
Hello Carl,

Thanks for the response !

Yes, there is no free lunch.
You will have to find values that work for you and are smaller than
the default.
The problem is that I'm working with a RTP multicast streams; not static files. So what I see happening a lot is the following:

  • I set values that are smaller than the default
  • The values work in most cases; however some times they do not. When this happens; what is the best course of action ? Can I just increase the values and try again without wasting too much time ?

How do you know you have gathered "all the basic information" of
a transport stream?
(There was a sample stream for which -probesize 2G was not enough
so we increased the range for the option.)
I guess I could have been clearer, sorry. What I meant was; is there a way of telling FFMPEG to imminently stop analyzing the stream (even if the "probesize" number of bytes haven't been used up yet) once it gathers enough information about the stream ?

So for instance if the probesize is set to 4MB; if my understanding is correct FFMPEG will finish avformat_find_stream_info/avfromat_open_input only when it reads all 4MB of data. Isn't there a way to stop it from reading the rest if for instance, only 1MB was enough to get the metadata from the stream ?

So I guess what I'm trying to say is; I would like it to stop analyzing the stream:

  • In case of audio, as soon as it detects the codec type, sample rate and number of channels.
  • In case of video, as soon as it detects the codec type, video resolution and "extradata" in case of H264/H265

Best regards,
Nikola


On 17-May-17 10:05, Carl Eugen Hoyos wrote:
2017-05-15 11:09 GMT+02:00 Nikola Spiric [hidden email]:

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).
Yes, there is no free lunch.
You will have to find values that work for you and are smaller than
the default.

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) ?
How do you know you have gathered "all the basic information" of
a transport stream?
(There was a sample stream for which -probesize 2G was not enough
so we increased the range for the option.)

I really need a way of speeding up these two function calls (5
seconds is not acceptable for my needs).
5 seconds seem extremely long on current hardware.

Carl Eugen
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user


_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: avformat_find_stream_info/avformat_open_input speed

Carl Eugen Hoyos-2
2017-05-18 2:44 GMT+02:00 Nikola Spiric <[hidden email]>:

> > How do you know you have gathered "all the basic information" of
> > a transport stream?
> > (There was a sample stream for which -probesize 2G was not enough
> > so we increased the range for the option.)
>
> I guess I could have been clearer, sorry. What I meant was; is there a way
> of telling FFMPEG to imminently stop analyzing the stream (even if the
> "probesize" number of bytes haven't been used up yet) once it gathers
> enough information about the stream ?

Sorry for the misunderstanding, what I tried to explain above was that
you cannot generally know when "enough information" about a
transport stream has been gathered.
You can only search for as long as was asked for.

Please consider setting your mailer to text.only, Carl Eugen
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Loading...