解决 av_read_frame() 文件尾(end of file)

一、问题描述

使用ffmpeg API进行h264编码时,av_read_frame()从缓存读取数据,会出现读取到文件尾的情况,截图如下:
读取文件尾截图

二、解决方案

  1. 预处理
    可参考:https://blog.csdn.net/Martin_chen2/article/details/103069058
  2. 修改探针大小
// 打开输入流时,修改探针probesize的大小
pVideoFormatCtx->probesize = BYTES_PER_FRAME * 8;
pVideoFormatCtx->pb = avio;
if (avformat_open_input(&pVideoFormatCtx, "", piFmt, NULL) < 0) {
    LOGD("avformat open failed.\n");
    return -1;
} else {
    LOGD("open stream success!\n");
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章