一、实验要求
- 将自行选择或老师给的两个264文件进行解码,得到相应的YUV文件
- 将上述两个视频序列编码为.264文件
-
固定码率,以不同的GOP长度及形状编码 GOP=15,2B帧;GOP=12,2B帧,GOP=9,2B帧 GOP=4,1B帧;GOP=12,无B帧;GOP=1,全I帧
-
相同的GOP长度及形状,不同的码率 例:1000kb/s, 800kb/s,400kb/s,…
- 用码流分析软件检查所生成的码流中各种编码模式和运动矢量等信息
- 用播放器观看所生成码流的质量
- 生成率失真曲线
二、实验内容
1、解码264文件,得到相应的YUV文件
修改ldecod方案中的decoder.cfg文件中的参数
InputFile = "demo.264" # H.264/AVC coded bitstream
OutputFile = "demo.yuv" # Output file, YUV/RGB
RefFile = "demo_rec.yuv" # Ref sequence (for SNR)
SourceWidth = 854 # Source frame width
SourceHeight = 480 # Source frame height
SourceResize = 0 # Resize source size for output
OutputWidth = 854 # Output frame width
OutputHeight = 480 # Output frame height
运行程序,得到结果如下图
2、将上述两个视频序列编码为.264文件
1.固定码率,以不同的GOP长度及形状编码
(1)GOP=15,2B帧
修改encoder.cfg的下列信息:
FramesToBeEncoded = 60
IntraPeriod = 15 # Period of I-pictures (0=only first)
NumberBFrames = 2 # Number of B coded frames inserted (0=not used)
HierarchicalCoding = 0
OutputFile = "!out_demo.264" # Bitstream
InputFile = "!demo.yuv" # Input sequence
SourceWidth = 854 # Source frame width
SourceHeight = 480 # Source frame height
SourceResize = 0 # Resize source size for output
OutputWidth = 854 # Output frame width
OutputHeight = 480 # Output frame height
运行程序得到如下结果
用Elecard StreamEye Tools进行验证:
可以发现IBBPBBPBBPBBPBBP为一个GOP
(2)GOP=1,全I帧
#########################################################################################
InputFile = "demo.yuv" # Input sequence
InputHeaderLength = 0 # If the inputfile has a header, state it's length in byte here
StartFrame = 0 # Start frame for encoding. (0-N)
FramesToBeEncoded = 30 # Number of frames to be coded
...
SourceWidth = 854 # Source frame width
SourceHeight = 480 # Source frame height
SourceResize = 0 # Resize source size for output
OutputWidth = 854 # Output frame width
OutputHeight = 480 # Output frame height
...
ReconFile = "test_rec.yuv" # Reconstruction YUV file
OutputFile = "demo3.264" # Bitstream
#########################################################################################
# Encoder Control
#########################################################################################
...
IntraPeriod = 1 # Period of I-pictures (0=only first)
...
#########################################################################################
# B Slices
#########################################################################################
NumberBFrames = 0 # Number of B coded frames inserted (0=not
disable, N <= NumberReferenceFrames)
...
HierarchicalCoding = 0 # B hierarchical coding (0= off, 1= 2 layers, 2= 2 full hierarchy, 3 = explicit)
...
得到结果
2.相同的GOP长度及形状,不同的码率
GOP=15,2B帧,修改码率
增加调节以下参数
RateControlEnable = 1 # 0 Disable, 1 Enable
Bitrate = 1000000 # Bitrate(bps)