H264视频中的编码图像被跳过和/或丢失
Encoded images into H264 video are skipped and/or missing?
我正在尝试将图像编码为H264 MP4视频。我遇到的问题是,一些图像被跳过,或者在视频的末尾只是丢失了。我需要视频来播放我编码的每一个图像,因为它是一个动画。
如有任何关于正确设置编码器的帮助,我们将不胜感激!
编码器设置:
AVCodecContext *c;
...
c->codec_id = AV_CODEC_ID_H264;
c->bit_rate = mOutputWidth*mOutputHeight*4;//400000;
/* Resolution must be a multiple of two. */
c->width = mOutputWidth;
c->height = mOutputHeight;
/* timebase: This is the fundamental unit of time (in seconds) in terms
* of which frame timestamps are represented. For fixed-fps content,
* timebase should be 1/framerate and timestamp increments should be
* identical to 1. */
c->time_base.den = mFps;
c->time_base.num = 1;
c->gop_size = 12; /* emit one intra frame every twelve frames at most */
c->pix_fmt = AV_PIX_FMT_YUV420P;
...
av_dict_set(&pOptions, "preset", "medium", 0);
av_dict_set(&pOptions, "tune", "animation", 0);
/* open the codec */
ret = avcodec_open2(c, codec, &pOptions);
if (ret < 0) {
LOGE("Could not open video codec: %s", av_err2str(ret));
return -1;
}
2013年7月24日更新:
通过设置gop_size=FPS
并重复写入最后一个视频帧,我能够获得更好的视频。FPS+1
次似乎解决了所有问题。对我来说,这样做似乎很奇怪,但可能是视频编码世界的标准?对此有任何提示反馈吗?
据我所知,你有一组图像,你想用它们制作一个视频。如果是这种情况,并且您不关心视频的大小,则可以尝试禁用帧间预测。也许编码器发现有些图像是不需要的,并跳过它们。
可以通过将gop_size
设置为0来禁用帧间预测。
相关文章:
- 使用 IMFSinkWriter 编码的视频的播放速度会根据宽度而变化
- 将原始视频图像转换为VPX编码器的I420
- 在何处更改参考代码以从 HEVC 编码的视频中提取运动矢量
- 如何使用FFMPEG从编码的视频中提取AVPACKET的重要信息
- ffmpeg/c++ 使用 ffmpeg 对视频帧的附加信息进行编码
- 如何使用FFMPEG与C拦截编码的视频数据
- 如何在libvpx(webm)中编码灰度视频
- LIBAV视频编码速率控制.cpp:766.
- Windows媒体基础使用原始图像对视频进行编码
- 正在加入编码视频帧
- 有没有c++库可以对flv视频进行编码
- OpenCV:H.264编码视频的文件大小
- 使用 Live555 从连接到 H264 编码器的 IP 摄像机流式传输实时视频
- QMultimedia - 支持哪些视频/音频编码和容器
- 如何根据C++程序中生成的多个图像对视频进行编码,而不将单独的帧图像写入磁盘
- H264视频中的编码图像被跳过和/或丢失
- WebM编码器示例-如何将一系列图像编码为WebM视频
- 用于嵌入式系统的开源视频编码器
- 在哪里可以获得关于创建mpeg-1视频编码器的教程
- 基于DCT的视频编码过程