SVC編碼軟件JSVM跳過幀數問題警告的分析

問題:

由於JSVM軟件問題,導致編碼的264文件在用DASH-SVC-toolchain在切割DASH流Segment的時候會報警告。

在DASH-SVC-toolchain的demultiplex.py文件中有這樣的說明:

 

也就是jsvm編碼的264碼流的第二個I幀在錯誤的位置,之前寫過一個自動化切割腳本,從跳過幀數0開始搜索,直到不報錯後保存不報錯的切割DASH流。但是發現不同的視頻有不同的跳過幀數,有的視頻可能沒有完全無警告的跳過幀數。

關鍵問題在於jsvm對“幀的設置”。

背景知識

一部視頻中一般會有I、B、P這三類幀,起到一定的壓縮左右

  1. I幀指的是intra picture,僅採用幀內壓縮,可以獨立解碼的幀,所以壓縮效率最低
  2. P幀指的是前向預測編碼幀,由前面的P幀或者I幀預測而來,解碼必須參照前面的幀,所以壓縮效率較高
  3. B幀指的是雙向預測編碼幀,它根據相鄰的前一幀、本幀以及後一幀數據的不同點來壓縮本幀,也即僅記錄本幀與前後幀的差值。所以壓縮效率最高

 

JSVM參數分析

視頻參數配置文件中的

Intraperiod 指的是I幀間隔

IntraPeriod

Unsigned Int, default: 2^32-1 (equal to 1)

Specifies the intra period for the encoded video sequence. When IntraPeriod is equal to –1 (2^32-1), only the very first picture is intra coded. Otherwise, every IntraPeriod picture (at the frame rate FrameRate) is intra-coded. The parameter IntraPeriod shall be equal to –1 or equal to a multiple of GOPSize.

 

Gopsize是一組B幀和P幀的長度

GOPSize

Unsigned Int, default: 1

Specifies the GOP size that shall be used for encoding a video sequence. A GOP (group of pictures) consists of a key picture, which is generally coded as P picture, and several hierarchically coded B pictures that are located between the key pictures. The parameter GOPSize must be equal to a power of 2. The GOP size is specified at the frame rate given by FrameRate. Thus, depending on the value of FrameRateOut in the layer configuration file, the actual GOP size for a layer might be smaller. For example, if FrameRate is equal to 30, GOPSize is equal to 16, and FrameRateOut is equal to 7.5, the actual GOP size that is employed for encoding the specific layer is equal to 4. The GOP size of all layers is selected in a way that the key pictures for all layers are temporally aligned. Hence, depending on the parameters FrameRateOut in the layer configuration files, the allowed range for GOPSize might be restricted. The maximum allowed value is 64.

 

 

 

 

 

FFmpeg參數分析

參數設置:(fps=30爲例)

FFmpeg視頻處理:

./ffmpeg -i $video_name -g $segment_period -bf 0 temp.mp4

 

FFmpeg裏的GOP和JSVM裏的GOP略有不同,提供的設置如下:

  1. -g 設置GOP大小(經測試,這裏的GOP指的是I幀間隔)
  2. -bf 設置連續出現B幀的數量

 

設置舉例:

-g:4

-bf:2

IBBPIBBPIBBPIBBPIBBP

 

-g:13

-bf:3

IBBBPBBBPBBBPIBBBPBBBPBBBP

 

 

目前問題及解決方案

JSVM的IDR幀位置經常出錯,導致DASH-SVC-Toolchain切割碼流報警告,而且沒有規律,而且GOPsize無法從視頻文件中讀取。只有IDR幀在Segment的最開始位置才能保證獨立解碼。所以編碼好的DASH流若想獨立解碼,幀的位置問題一定要注意!

雖然無法讀取GOPsize,但可以嘗試取消B幀(GOPsize=1),讓視頻中只存在I幀和P幀,這樣的壞處是會讓比特率增加,但是我發現此時對碼流進行切割無需跳過任何幀數,目前切割的視頻都沒有任何錯誤,且沒跳過任何幀。

 

 

JSVM配置文件:

視頻信息文件

IntraPeriod             60              # Intra Period

GOPSize                1          # GOP Size (at maximum frame rate)

 

層次配置文件

IDRPeriod           60

 

腳本設計

寫了一個批量SVC編碼的腳本,截止目前已經編碼好50部視頻,跳過幀數爲0且不出現任何警告。

運行截圖 

 

 

歡迎SVC編碼研究者探討和交流~ 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章