在 Visual Studio C++ 上使用 ffmpeg 库对视频进行编码时出现断言错误
Assertion error when encoding video using ffmpeg library on visual studio c++
我有一个项目,我需要从rtsp链接接收数据,解码,调整视频大小,对其进行编码并保存到.mp4文件中。
- I 使用 ffmpeg 来自 http://ffmpeg.zeranoe.com/builds/
- 我正在使用Visual Studio 2010,在Windows 7和Windows 8上运行。
- 这是我正在使用的rtsp链接:rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov
- 我解码并保存到 ppm 文件还可以。但编码不是。
- 我按照那里的教程:http://dranger.com/ffmpeg/tutorial01.html
这是我的代码:
AVPacket destPacket;
av_init_packet(&destPacket);
destPacket.data = NULL;
destPacket.size = 0;
while(av_read_frame(i_format_context, &packet)>=0) {
if(packet.stream_index==video_stream_index) {
int rest = avcodec_decode_video2(copyInputCodec, pFrame, &frameFinished, &packet);
if(frameFinished) {
av_init_packet(&destPacket);
destPacket.data = NULL;
destPacket.size = 0;
av_free_packet(&destPacket);
//deocde here
int ret_scale = sws_scale(sws_ctx,pFrame->data,pFrame->linesize,0,copyInputCodec->height,encodeFrame->data,encodeFrame->linesize);
encodeFrame->pts=i;
int ret_enc = avcodec_encode_video2(copyOutputCodec,&destPacket,encodeFrame,&encodeFinishsed);//<--- Problem here.
getchar();
}
}
}
这是输出错误
[swscaler @ 00607880] 警告:数据未对齐!这可能导致 Speedlo SS Assertion avctx->codec->encode2 failed at/home/kyle/software/ffmpeg/source/ffmp eg-git/libavcodec/utils.c:2134
我尝试运行许多示例代码来编码视频,结果是一样的。
感谢您的帮助。
PS:对不起我的英语水平。
这里实际上有两个问题:
- 警告:根据 https://github.com/FFmpeg/FFmpeg/blob/master/libswscale/swscale.c(第 413-424 行),您的图片尺寸应可除以 16
- 断言:https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/utils.c 行 2134 - 看起来您尚未配置编码器
相关文章:
- 使用 MATLAB 编码器生成C++代码:编译错误"undefined reference to `rgb2gray_tbb_real64'"
- 为什么我在编码中总是出现性能错误?
- C++ 分段错误:11 错误,同时编码将两个数字相加的链接列表
- Opus编码和解码没有错误,但值不同
- 合成错误不知道为什么会发生这种情况,请检查一下并告诉我这是我的编码还是视觉工作室
- 错误:调用'begin(long double [nPoints])'没有匹配函数;使用硬编码的 int 与整数变量初始化向量
- 有没有办法将 vector<unsigned char> 插入 postgresql 表中,具有 bytea 属性,没有 UTF8 编码错误?
- Rapidjson 解析错误:字符串 (207) 中的编码无效
- UWP和SerialSample字节编码错误
- 读取 CSV 文件(UNICODE 编码)C++时出现编码错误
- C++正在创建二进制搜索树:EXC_BAD_ACCESS错误.算法错误还是编码错误
- C++if语句编码错误
- C++中的奇怪编码错误
- 可撕裂机器人手臂编码错误
- 使用C++从MySQL数据库获取字符串时编码错误
- 在Visual Studio中编码错误比涡轮增压C++ - C
- 函数返回基类而不是派生类,这是编码错误还是Visual c++ bug ?
- SNMP:无法创建/设置变量,编码错误
- linux上的文本编码错误
- POCO C++SAX解析器:如果xml文档编码是ANSI,那么下一条语句不是读取并抛出编码错误异常