FFmpeg 優化點播延時

場景
    探測ES流,avformat_open_input會非常快的返回,PS反而是一個例外。通過調用av_log_set_callback設置日誌寫文件的方式,
在調用avformat_open_input函數探測PS輸入格式時候,
會打印如下的日誌:
Probing mp3 score:1 size:2048
Probing mp3 score:1 size:4096
Probing mp3 score:1 size:8192
Probing mp3 score:1 size:16384
Probing h264 score:51 size:32768
Format h264 probed with size=32768 and score=51
Input #0, h264, from '':
  Duration: N/A, bitrate: N/A
    Stream #0:0, 0, 1/1200000: Video: h264 (Baseline), yuvj420p, 1920x1080, 25 fps, 0.04 tbr, 1200k tbn
deprecated pixel format used, make sure you did set range correctly
non-existing PPS 0 referenced
non-existing PPS 0 referenced
nal_unit_type: 1, nal_ref_idc: 3
non-existing PPS 0 referenced
non-existing PPS 0 referenced
decode_slice_header error
non-existing PPS 0 referenced
non-existing PPS 0 referenced
non-existing PPS 0 referenced
no frame!

通過跟蹤源碼Probing h264 score:51 size:32768日誌打印在調用
av_probe_input_format3函數會打印
name h264
long_name raw H.264 video
raw_codec_id 28
說明如果指定了AVInputFormat結構體,就可以節省探測碼流格式的時間

ffmpeg 針對指定的h264 es流延時優化
參考http://blog.csdn.net/rain_2011_kai/article/details/7746805文章,
是否只需要知道發送端發送的視屏的解碼器ID,視頻幀的長和寬,就可以直接
直接省略掉ffmpeg庫的視頻流探測接口,avformat_open_input函數
和avformat_find_stream_info函數耗時超過500毫秒

手動指定解碼格式 效果不明顯
+buffer0x00000000002cbdc0  <字符串中的字符無效。>unsigned char *

+buf_end0x00000000002d3626  <字符串中的字符無效。>unsigned char *


30822


pos 262349

buffer  2932160

buf_end 2962982

buffsize 35840

buf_end-buffer 30822

pos的值從哪裏來,值得考慮

pFormatContext->pb->pos = pFormatContext->pb->buf_end;

在已有的版本是編譯不過的,因爲pos是一個64位整型,buf_end是一個字符指針

但是從上面還是看不出它們之間的關係,儘管手動指定解碼格式,但是效果並不理想


還有在這裏讀取一幀的數據

m_pVideoc->io_ctx = avio_alloc_context(m_pAvioBuf, BUF_SIZE, 0, this, ReadStreamData, NULL, NULL);

設置BUF_SIZE的大小爲4*1024,實際上是否有效果,尚未可知
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章