在Linux下运行HM(第3天)

参考这位大神:VioletHan
https

知识积累

GOP(Group of Pictures)

  • GOP(Group of Pictures)策略影响编码质量,所谓GOP,意思是画面组,一个GOP就是一组连续的画面。
    GOP是序列中的一个图片集,用来辅助随机存取。GOP的第一个图像必须为I帧,这样就能保证GOP不需要参考其他图像,可以独立解码。
    MPEG编码将画面(即帧)分为I、P、B三种,I是内部编码帧,P是前向预测帧,B是双向内插帧。简单地讲,I帧是一个完整的画面,而P帧和B帧记录的是相对于I帧的变化。没有I帧,P帧和B帧就无法解码,这就是MPEG格式难以精确剪辑的原因,也是我们之所以要微调头和尾的原因。
    参考GOP结构和参数(CSDN博客)
  • HM 参考手册中有详细的说明(以下内容来自参考手册):
    3.1
    GOP structure table
    Defines the cyclic GOP structure that will be used repeatedly throughout the sequence. The table should contain GOPSize lines, named Frame1, Frame2, etc. The frames are listed in decoding order, so Frame1 is the first frame in decoding order, Frame2 is the second and so on. Among other things, the table specifies all reference pictures kept by the decoder for each frame. This includes pictures that are used for reference for the current picture as well as pictures that will be used for reference in the future(定义将在整个序列中重复使用的循环GOP结构。 该表应包含GOPSize行,分别命名为Frame1,Frame2等。这些帧按解码顺序列出,因此,Frame1是解码顺序中的第一个帧,Frame2是第二个帧,依此类推。 该表格尤其指定了解码器为每个帧保存的所有参考图片。 这包括用于当前图片参考的图片以及将来将用于参考的图片)。. The encoder will not automatically calculate which pictures have to be kept for future references,they must be specified编码器不会自动计算必须保留哪些图片以备将来参考,它们必须被指定).Note that some specified reference frames for pictures encoded in the very first GOP after an IDR frame might not be available(请注意,某些特定的参考帧是在GOP之后的第一个GOP中编码的图片的IDR框架可能不可用) .This is handled automatically by the encoder, so the reference pictures can be given in the GOP structure table as if there were infinitely many identical GOPs before the current one. Each line in the table contains the parameters used for the corresponding frame, separated by whitespace(这是由编码器自动处理的,因此参考图片可以在GOP结构表中给出,就像在当前GOP之前存在无限多个相同的GOP一样。 表中的每一行均包含用于相应框架的参数,并用空格分隔):
    参考:殷汶杰的工作台的博客-GOP in HEVC

上机实践

学习使用ffmpeg

参考链接: https://blog.csdn.net/violethan7/article/details/80635973

software-manual

除了HM的帮助文档给了我们详细的说明之外,在shell终端中也可以随时查看HM的帮助文档!
在这里插入图片描述
重点提示:

  -c                             configuration file name
  -w,   --WarnUnknowParameter    warn for unknown configuration parameters
                                 instead of failing
  -i,   --InputFile              Original YUV input file name
  -b,   --BitstreamFile          Bitstream output file name
  -o,   --ReconFile              Reconstructed YUV output file name
  -wdt, --SourceWidth            Source picture width
  -hgt, --SourceHeight           Source picture height
        --InputBitDepth          Bit-depth of input file

翻译:

-c                               配置文件名
   -w,--WarnUnknowParameter     警告未知的配置参数而不是失败
   -i,-InputFile YUV            原始输入文件名
   -b,--BitstreamFile           位流输出文件名
   -o,--ReconFile               重构的YUV输出文件名
   -wdt,--SourceWidth           源图片宽度
   -hgt,--SourceHeight          源图片高度
         --InputBitDepth         输入文件的位深
  • 有一个小小的疑问:
    windows下的HM配置文件与Linux下的配置文件相同吗?
    暂时回答不了这个问题,学长在windows下写的配置文件,好像不符合linux上的规范,所以暂时不用配置文件了,日后学的多了再试一试!
    答案是:一样的,学长写的cfg在linux上也可以用
  • 有位大神说:
    在这里插入图片描述
  • 还可以使用python进行批处理!

TAppEncoderStatic

多次失败,终于成功了一次

yupengfei@yupengfei-X550VX:~/CTC/ClassF$ ~/HM-16.9/bin/TAppEncoderStatic   -c ./encoder_intra_main.cfg  -i ./SlideEditing.yuv  -b ~/HM-16.9/bin/str.bin -c ./SlideEditing.cfg 

HM software: Encoder Version [16.9] (including RExt)[Linux][GCC 9.3.0][64 bit] 

******************************************************************
** WARNING: --SEIDecodedPictureHash is now disabled by default. **
**          Automatic verification of decoded pictures by a     **
**          decoder requires this option to be enabled.         **
******************************************************************
***************************************************************************
** WARNING: For conforming bitstreams a valid Level value must be set!   **
***************************************************************************

Input          File                    : ./SlideEditing.yuv
Bitstream      File                    : /home/yupengfei/HM-16.9/bin/str.bin
Reconstruction File                    : rec.yuv
Real     Format                        : 1280x720 30Hz
Internal Format                        : 1280x720 30Hz
Sequence PSNR output                   : Linear average only
Sequence MSE output                    : Disabled
Frame MSE output                       : Disabled
Cabac-zero-word-padding                : Enabled
Frame/Field                            : Frame based coding
Frame index                            : 0 - 299 (300 frames)
Profile                                : main
CU size / depth / total-depth          : 64 / 4 / 4
RQT trans. size (min / max)            : 4 / 32
Max RQT depth inter                    : 3
Max RQT depth intra                    : 3
Min PCM size                           : 8
Motion search range                    : 64
Intra period                           : 1
Decoding refresh type                  : 0
QP                                     : 32.00
Max dQP signaling depth                : 0
Cb QP Offset                           : 0
Cr QP Offset                           : 0
QP adaptation                          : 0 (range=0)
GOP size                               : 1
Input bit depth                        : (Y:8, C:8)
MSB-extended bit depth                 : (Y:8, C:8)
Internal bit depth                     : (Y:8, C:8)
PCM sample bit depth                   : (Y:8, C:8)
Intra reference smoothing              : Enabled
diff_cu_chroma_qp_offset_depth         : -1
extended_precision_processing_flag     : Disabled
implicit_rdpcm_enabled_flag            : Disabled
explicit_rdpcm_enabled_flag            : Disabled
transform_skip_rotation_enabled_flag   : Disabled
transform_skip_context_enabled_flag    : Disabled
cross_component_prediction_enabled_flag: Disabled
high_precision_offsets_enabled_flag    : Disabled
persistent_rice_adaptation_enabled_flag: Disabled
cabac_bypass_alignment_enabled_flag    : Disabled
log2_sao_offset_scale_luma             : 0
log2_sao_offset_scale_chroma           : 0
Cost function:                         : Lossy coding (default)
RateControl                            : 0
WPMethod                               : 0
Max Num Merge Candidates               : 5

TOOL CFG: IBD:0 HAD:1 RDQ:1 RDQTS:1 RDpenalty:0 SQP:0 ASR:0 MinSearchWindow:8 RestrictMESampling:0 FEN:1 ECU:0 FDM:1 CFM:0 ESD:0 RQT:1 TransformSkip:1 TransformSkipFast:1 TransformSkipLog2MaxSize:2 Slice: M=0 SliceSegment: M=0 CIP:0 SAO:1 PCM:0 TransQuantBypassEnabled:0 WPP:0 WPB:0 PME:2  WaveFrontSynchro:0 WaveFrontSubstreams:1 ScalingList:0 TMVPMode:1 AQpS:0 SignBitHidingFlag:1 RecalQP:0

Non-environment-variable-controlled macros set as follows: 

                                RExt__DECODER_DEBUG_BIT_STATISTICS =   0
                                      RExt__HIGH_BIT_DEPTH_SUPPORT =   0
                            RExt__HIGH_PRECISION_FORWARD_TRANSFORM =   0
                                        O0043_BEST_EFFORT_DECODING =   0
                                         ME_ENABLE_ROUNDING_OF_MVS =   1
        U0040_MODIFIED_WEIGHTEDPREDICTION_WITH_BIPRED_AND_CLIPPING =   1

                   Input ChromaFormatIDC =   4:2:0
       Output (internal) ChromaFormatIDC =   4:2:0

SUMMARY --------------------------------------------------------
	Total Frames |   Bitrate     Y-PSNR    U-PSNR    V-PSNR    YUV-PSNR 
	      300    a   19053.3104   37.7260   38.8933   39.0388   38.0909


I Slices--------------------------------------------------------
	Total Frames |   Bitrate     Y-PSNR    U-PSNR    V-PSNR    YUV-PSNR 
	      300    i   19053.3104   37.7260   38.8933   39.0388   38.0909


P Slices--------------------------------------------------------
	Total Frames |   Bitrate     Y-PSNR    U-PSNR    V-PSNR    YUV-PSNR 
	        0    p         -nan      -nan      -nan      -nan      -nan


B Slices--------------------------------------------------------
	Total Frames |   Bitrate     Y-PSNR    U-PSNR    V-PSNR    YUV-PSNR 
	        0    b         -nan      -nan      -nan      -nan      -nan

RVM: 0.000
Bytes written to file: 23817849 (19054.279 kbps)

 Total Time:     1778.367 sec.

  • -i 输入文件、-b 输出文件、-c 配置文件
    在这里插入图片描述

使用ffplay 播放码流文件

yupengfei@yupengfei-X550VX:~/HM-16.9/bin$ ffplay str.bin
ffplay version 4.2.2-1ubuntu1 Copyright (c) 2003-2019 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-3ubuntu1)
  configuration: --prefix=/usr --extra-version=1ubuntu1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
[hevc @ 0x7f5a84000bc0] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, hevc, from 'str.bin':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: hevc (Main), yuv420p(tv), 1280x720, 25 fps, 25 tbr, 1200k tbn, 25 tbc
    nan M-V:    nan fd=   0 aq=    0KB vq= 2126KB sq=    0B f=0/0   

在这里插入图片描述

TAppEncoderStatic

yupengfei@yupengfei-X550VX:~/HM-16.9/bin$ ./TAppDecoderStaticd -b str.bin -o test.yuv

解码成功
在这里插入图片描述
在这里插入图片描述

使用ffplay播放解码后的yuv文件

yupengfei@yupengfei-X550VX:~/HM-16.9/bin$ ffplay -f rawvideo -video_size 1280x720 -pix_fmt yuv420p test.yuv 

  • 播放成功
  • 解码后的视频与原先编码的视频相同
    在这里插入图片描述

小结

  • 在学长的耐心指导下完成了一次完整的“CTC”操作,但对其中的参数掌握还是极为有限,只掌握了最基本的参数的使用。
  • 最后安利一波:在Linux下运行程序真的好流畅!!!欢迎入坑!

小小的改进

为养成好的shell脚本习惯,对shell命令进行了小小的改进:

yupengfei@yupengfei-X550VX:~$ ~/HM-16.9/bin/TAppEncoderStatic   -c ~/HM-16.9/cfg/encoder_intra_main.cfg  -i ~/CTC/ClassF/ChinaSpeed.yuv  -b ~/CTC/ClassF/ChinaSpeed_bin.bin  -c ~/jiamenhu/cfg/ChinaSpeed.cfg 

程序依旧可以运行!

备注:
ffplay播放yuv的命令格式

ffplay -f rawvideo -video_size 1024x768 -pix_fmt yuv420p -i  ~/CTCtest/ChinaSpeed_test.yuv

猜你喜欢

转载自blog.csdn.net/Master_Yu_Daye/article/details/107370443
今日推荐