Could not find codec parameters for stream 0 (Video: h264, none)
這個方法沒成功:
在使用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(....);