video - 查找编码比特流中的帧大小

标签 video video-processing hevc h.265

我正在使用 HM 12.1 引用代码。我必须从编码的 h.265 位流中找到以字节或 KB 为单位的帧大小。我对视频处理非常陌生,我陷入了困境。请帮忙!

最佳答案

如果您使用最新版本的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

目前它不适用于 HEVC,因为 ffprope 无法检测到正确的尺寸类型,但希望将来能够修复

执行上述操作的代码是:

#!/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
<小时/>

关于video - 查找编码比特流中的帧大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21848514/

相关文章:

video - 视频开始时的默认质量

swift - DJI Bridge App 教程 Swift 无视频流 - Phantom 4 Pro

javascript - editly - 创建视频后在哪里可以获得返回值?

ios - 在 IOS 应用程序中使用 FFMPEG 的可靠性?

FFmpeg -x265-params 不识别 qp 值

ffmpeg - 从视频中删除所有非关键帧而不重新编码

JavaFx Webview 未在本地主机服务器上加载 html5 视频

video - 在iFrame中显示YouTube视频

python - 如何使用 Python 流式传输来自多个 IP 摄像机的视频

FFMPEG:HEVC 解码器中的帧参数初始化