ffmpeg解码慢速调用而无需avformat_find_stream_info [英] ffmpeg decoding slow calling without avformat_find_stream_info
问题描述
我正在使用ffmpeg在Android上解码h264 rtp流.我发现一个奇怪的问题:如果不调用avformat_find_stream_info
,则解码P frame
会花费数十微秒,相比之下,在解码前调用avformat_find_stream_info
会将P frame
的解码时间平均缩短到不到1毫秒.但是,avformat_find_stream_info
本身在网络流上很耗时.我有什么办法可以使无需调用 avformat_find_stream_info
而快速解码?
调用 avformat_find_stream_info 时,此功能将扫描流URL(或本地文件),以检查给定URL中的有效流. /p>
换句话说,这意味着它将解码来自给定输入URL的少量数据包,因此您可以使用在 avformat_find_stream_info 中初始化的AVCodecContext快速解码数据包.
我没有测试它,但是如果不调用 avformat_find_stream_info 就无法对其进行解码,通常情况下,或者每次解码数据包时都会对其进行初始化.
无论如何,这就是 avformat_find_stream_info 消耗网络流量的原因.因为,正如我所说,它会拉出前几个数据包.
如果您真的想快速解码数据包而不调用此函数,则应自己手动初始化AVCodecContext.
I am decoding h264 rtp stream with ffmpeg on android. I found a strange problem: if I don't call avformat_find_stream_info
,decoding P frame
takes tens of micro seconds, by contrast, calling avformat_find_stream_info
before decoding will reduce P frame
decoding time to less than 1 ms on average. However, avformat_find_stream_info
itself is time consuming on network streams. Are there anything I can do to make decoding fast without calling avformat_find_stream_info
?
When avformat_find_stream_info is called, streaming URL(or local file) is scanned by this function to check valid streams in given URL.
That means, in other words, it will decode few packets from given input URL so you can decode packets fast with AVCodecContext, which is initialized in avformat_find_stream_info.
I didn't test it but It cannot be decoded without calling avformat_find_stream_info In general situation, or maybe it is initialized every time when packet is decoded.
Anyway, that's why avformat_find_stream_info consumes network traffic. because, as i said, it pulls first few packets.
If you really want to decode packets fast without calling this function, you should initialize AVCodecContext yourself, manually.
这篇关于ffmpeg解码慢速调用而无需avformat_find_stream_info的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!