ffmpeg avformat_open_input返回失败的解决办法
2014-02-21 14:10
1466 查看
很多朋友在使用新版本的ffmpeg时,都遇到了avformat_open_input返回失败的问题。
在下也遇到了此问题。在stackoverflow上搜了一下,解决方法如下。
在调用avformat_open_input之前,先调用如下接口初始化一下即可。
这算是新版本ffmpeg代码流程的一个变化了。
老版本的ffmpeg,代码流程如下:
avcodec_register_all();
av_open_input_file(&pFormatCtx, "/path/to/video/file", NULL, 0, NULL);
而新版本中,代码流程如下:
av_register_all();
avformat_open_input(&pFormatCtx, "/path/to/video/file", NULL, NULL);
最后,我们要使用ffmpeg的过程中,遇到返回值失败时,可以尝试将失败原因打印出来。
方法如下:
if( err_code=avformat_open_input(&pFormatCtx, test_file, NULL, NULL) )
{
av_strerror(err_code, buf, 1024);
printf("Couldn't open file %s: %d(%s)", test_file,
err_code, buf);
return -1;
}
最后再列几个变化了的接口:
老版本:
avcodec_open
avcodec_decode_video
img_convert
新版本:
avcodec_open2
avcodec_decode_video2
sws_scale
在下也遇到了此问题。在stackoverflow上搜了一下,解决方法如下。
在调用avformat_open_input之前,先调用如下接口初始化一下即可。
av_register_all();
这算是新版本ffmpeg代码流程的一个变化了。
老版本的ffmpeg,代码流程如下:
avcodec_register_all();
av_open_input_file(&pFormatCtx, "/path/to/video/file", NULL, 0, NULL);
而新版本中,代码流程如下:
av_register_all();
avformat_open_input(&pFormatCtx, "/path/to/video/file", NULL, NULL);
最后,我们要使用ffmpeg的过程中,遇到返回值失败时,可以尝试将失败原因打印出来。
方法如下:
if( err_code=avformat_open_input(&pFormatCtx, test_file, NULL, NULL) )
{
av_strerror(err_code, buf, 1024);
printf("Couldn't open file %s: %d(%s)", test_file,
err_code, buf);
return -1;
}
最后再列几个变化了的接口:
老版本:
avcodec_open
avcodec_decode_video
img_convert
新版本:
avcodec_open2
avcodec_decode_video2
sws_scale
相关文章推荐
- ffmpeg avformat_open_input返回失败的解决办法
- ffmpeg avformat_open_input返回失败的解决办法
- ffmpeg avformat_open_input返回失败的解决办法
- ffmpeg avformat_open_input返回失败的解决办法
- ffmpeg调用 avformat_open_input失败,返回 -2
- ffmpeg调用 avformat_open_input失败,返回 -2
- 解决avformat_open_input()不返回
- FFmpeg avformat_open_input函数打开acc,h264失败的错误问题
- android ndk ffmpeg 用avformat_input_file 打开rtsp流,返回错误信息-5的解决方法
- 开始写博客!!今天第一个:FFmpeg解码网络rtsp流的一般流程和这几天遇到的问题,尤其是avformat_input_open解析错误的网络串流长时间不返回!
- ffmpeg avformat_open_input详解
- SSL_connect失败返回-1的一种情况解决办法
- 图解FFMPEG打开媒体的函数avformat_open_input
- FFmpeg中函数avformat_open_input()(含URL解析文件格式)
- FFMPEG-avformat_open_input
- FFmpeg源代码简单分析:avformat_open_input()
- FFmpeg源代码简单分析:avformat_open_input
- 高德地图Android错误码1008、32和7;错误提示invalid_user_scode;返回key鉴权失败的解决办法
- linux下执行php文件Could not open input file的解决办法
- 图解FFMPEG打开媒体的函数avformat_open_input&avformat_find_stream_info