ffmpeg打開視頻解碼器失敗:Could not find codec parameters for stream 0 (Video: h264): unspecified size


在使用ffmpeg進行拉流分離音視頻數據再解碼播放操作的時候;

有時候經常會報錯:

Could not find codec parameters for stream 0 (Video: h264): unspecified size

ffmpeg默認使用udp方式傳輸,在使用:avformat_find_stream_info 會出現返回 codec_id ==AV_CODEC_ID_NONE 的情況;

如果id = none 的情況在 打開解碼器的時候肯定會報錯,所以在 執行 avformat_find_stream_info  的時候有必要判斷一下視頻信息的有效性!

在 avformat_open_input打開流地址之前 強制ffmpeg 以tcp傳輸 ,可以解決上面返回 none的情況。

AVDictionary* options = NULL;
av_dict_set(&options, "rtsp_transport", "tcp", 0);

avformat_open_input(....);

 

參考:

http://blog.sina.com.cn/s/blog_4462d1710101k4ld.html

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM