ffmpeg decoding slow calling without avformat_find_stream_info

China☆狼群 提交于 2021-02-08 00:22:27

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/33405335/ffmpeg-decoding-slow-calling-without-avformat-find-stream-info

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!