2014-02-18 52 views

回答

7

如果您使用最新的ffmpeg版本很簡單,只要:

ffprobe -show_frames file.hevc 

查找開始的行pkt_size

例子:

$ ~/src/ffmpeg/ffprobe -show_frames BQMall_832x480_60_QP22.hevc | grep pkt_size 
pkt_size=67941 
pkt_size=12235 
pkt_size=13024 
pkt_size=13026 
pkt_size=12534 
pkt_size=13778 
pkt_size=13589 
pkt_size=13039 
pkt_size=12035 
pkt_size=12582 
pkt_size=13186 
pkt_size=15519 
pkt_size=15930 
pkt_size=15616 
pkt_size=15311 
pkt_size=15430 
pkt_size=14608 
pkt_size=14423 
pkt_size=16044 
pkt_size=18246 

ffprobe是很酷,在一起與gnuplot你可以產生良好的框架大小的情節,例如是這樣的:

enter image description here

目前因爲ffprope無法檢測到正確的slize類型,但是,希望能固定在未來

代碼上面做它不HEVC工作是:

#!/bin/bash 

# If not in path 
FFPROBE=/home/xxxx/src/ffmpeg/ffprobe 
# If in path 
#FFPROBE=ffprobe 

cat <<EOF > /tmp/plot.txt 
# GNUPLOT "plot.txt" 
#Use the 3 lines below to store plot to file 
#set terminal png size 1280,720 
#set term png 
#set output "bitrate.png" 

set title "$(basename $1)" 
set ylabel "Bytes per frame" 
set xrange [-2:*] 
set lmargin 12 
set rmargin 2 
set grid 
set pointsize 2 
set label 1 "I frames" 
set label 1 at graph .85, .96 tc lt 1 
set label 2 "P frames" 
set label 2 at graph .85, .92 tc lt 2 
set label 3 "B frames" 
set label 3 at graph .85, .88 tc lt 3 
plot '/tmp/column.dat' using 3:1:2 notitle with i lc rgb variable 
EOF 

awk ' 
BEGIN{ 
    FS="=" 
    OFS="\t" 
    fnum=0 
} 
/pkt_size/ {size=$2} 
/pict_type/{ 
    sub(/I/, "167116800", $2) 
    sub(/P/, "65280", $2) 
    sub(/B/, "255", $2) 
    sub(/\?/, "65280", $2) 
    type=$2 
} 
/coded_picture_number/{ 
# sub(/0/, fnum, $2) 
    num=$2 
# fnum=fnum+1 
    print size, type, num 
}' <(${FFPROBE} -show_frames $1 2>/dev/null) > /tmp/column.dat 

gnuplot -persist /tmp/plot.txt 

更新

好人在JCT-VC已經考慮到了這一點,並且在reference software中,你會得到一個名爲annexBbytecountStatic的二進制文件,它可以做到這一點。只需用一個純粹的hevc-bitstream調用它作爲唯一的參數。使用相同的文件上面的例子:

$ ./annexBbytecountStaticd BQMall_832x480_60_QP22.hevc | grep NumBytesInNALunit 
    NumBytesInNALunit: 25 
    NumBytesInNALunit: 31 
    NumBytesInNALunit: 10 
    NumBytesInNALunit: 67858 
    NumBytesInNALunit: 12231 
    NumBytesInNALunit: 13020 
    NumBytesInNALunit: 13022 
    NumBytesInNALunit: 12530 
    NumBytesInNALunit: 13774 
    NumBytesInNALunit: 13585 
    NumBytesInNALunit: 13035 
    NumBytesInNALunit: 12031 
    NumBytesInNALunit: 12578 
    NumBytesInNALunit: 13182 
    NumBytesInNALunit: 15515 
    NumBytesInNALunit: 15926 
    NumBytesInNALunit: 15612 
    NumBytesInNALunit: 15307 
    NumBytesInNALunit: 15426 
    NumBytesInNALunit: 14604 
    NumBytesInNALunit: 14419 
    NumBytesInNALunit: 16040 
    NumBytesInNALunit: 18243 
    NumBytesInNALunit: 338004 
    NumBytesInNALunit: 270121 
    NumBytesInNALunit: 0 
    NumBytesInNALunit: 67883 

+0

@Frednik皮赫爾有沒有辦法找出這些數據包,我們開始使用annexBbytecountStatic的時間順序? – zinon

+0

或者,有沒有辦法找到我們什麼時候改變幀/切片? – zinon

+0

對不起,但你能更具體嗎?更改幀的時間取決於編碼的幀率,30 fps表示每1/30秒顯示一幀。 「通常」1幀= 1片,但一幀可以由幾個片組成。您也可以將一個框架分成垂直的瓷磚,每個瓷磚又可以包含多個切片... –