问题
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