如何强制ffmpeg编码时输出一个关键帧

来源:互联网 发布:网络歌手紫菱个人资料 编辑:程序博客网 时间:2024/06/03 15:57

原文地址:http://www.ffmpeg.com.cn/index.php/%E5%A6%82%E4%BD%95%E5%BC%BA%E5%88%B6ffmpeg%E7%BC%96%E7%A0%81%E6%97%B6%E8%BE%93%E5%87%BA%E4%B8%80%E4%B8%AA%E5%85%B3%E9%94%AE%E5%B8%A7

 

如何强制ffmpeg编码时输出一个关键帧

AVCodecContext *c     //编码器环境句柄AVFrame* f                 //需要编码的一帧视频
在编码前设置f->pict_type=FF_I_TYPE; f->key_frame=1; 
然后编码*outsize = avcodec_encode_video(c, temp, outbuf_size, f);
则编码之后通过如下参数判断是否为关键帧:key_frame=c->coded_frame->key_frame; pict_type=c->coded_frame->pict_type;