解決 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");
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章