FFmpeg添加x265/hevc编码器支持

    FFmpeg添加了对流行hevc编码器x265的支持极大的方便了编解码场景的融合应用。以下记录说明在windows下编译带libx265编码器的FFmpeg。


环境 

    Windows7 + VisualStudio2015


FFmpeg编译环境搭建

    请参考我的博文Windows下编译FFmpeg


X265编译

    请参考我的博文Windows下编译x265


libx265环境配置

   由于FFmpeg的Configure是采用pkg-config来查找依赖库libs和头文件includes的,因此需要配置x265的pc文件让configure找到所依赖的环境。

   启动msys.bat(编译FFmpeg搭建MinGW环境命令行),在/local/lib/pkgconfig文件夹下创建文件x265.pc

prefix=/local/
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: x265
Description: H.265/HEVC video encoder
Version: 2.8
Libs: -L${libdir} -lx265
Libs.private: 
Cflags: -I${includedir}
  1. 配置依赖库libs

   拷贝x265编译结果中的libx265.lib和x265-static.lib至/local/lib文件夹下。并复制libx265.lib为x265.lib

  2. 配置头文件

   拷贝x265.h和x265_config.h至/local/include文件夹下

  3. 配置动态链接库

   拷贝libx265.dll和x265.exe至/local/bin文件夹下


编译安装

   export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/local/lib/pkgconfig

   执行pkg-config --list-all确保已经正确查找到x265

   ./configure --toolchain=msvc --enable-gpl --enable-libx265

   make -j4

   make install 


使用测试

  测试264 ts流转265 ts流, 采用默认参数

  ffmpeg -i bq.ts -vcodec hevc h265.ts

  打印如下:

x265 [info]: HEVC encoder version 2.8+21-gccd9e41ba
x265 [info]: build info [Windows][MSVC 1900][32 bit] 8bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX FMA3 B
MI2 AVX2
x265 [info]: Main profile, Level-3 (Main tier)
x265 [info]: Thread pool created using 4 threads
x265 [info]: Slices                              : 1
x265 [info]: frame threads / pool features       : 2 / wpp(9 rows)
x265 [warning]: Source height < 720p; disabling lookahead-slices
x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
x265 [info]: ME / range / subpel / merge         : hex / 57 / 2 / 2
x265 [info]: Keyframe min / max / scenecut / bias: 25 / 250 / 40 / 5.00
x265 [info]: Lookahead / bframes / badapt        : 20 / 4 / 2
x265 [info]: b-pyramid / weightp / weightb       : 1 / 1 / 0
x265 [info]: References / ref-limit  cu / depth  : 3 / on / on
x265 [info]: AQ: mode / str / qg-size / cu-tree  : 1 / 1.0 / 32 / 1
x265 [info]: Rate Control / qCompress            : CRF-28.0 / 0.60
x265 [info]: tools: rd=3 psy-rd=2.00 rskip signhide tmvp strong-intra-smoothing
x265 [info]: tools: deblock sao
Output #0, mpegts, to 'h265_2.ts':
  Metadata:
    encoder         : Lavf58.17.100
    Stream #0:0: Video: hevc (libx265), yuv420p, 528x576 [SAR 16:11 DAR 4:3], q=
2-31, 25 fps, 90k tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.20.102 libx265
    Stream #0:1: Audio: mp2, 48000 Hz, stereo, s16, 384 kb/s
    Metadata:
      encoder         : Lavc58.20.102 mp2
frame=   29 fps= 27 q=-0.0 size=      32kB time=00:00:01.35 bitrate= 191.6kbits/
frame=   32 fps= 17 q=-0.0 size=      51kB time=00:00:01.50 bitrate= 276.4kbits/
frame=   33 fps= 13 q=-0.0 size=      57kB time=00:00:01.50 bitrate= 309.4kbits/

frame=   34 fps= 11 q=-0.0 size=      65kB time=00:00:01.52 bitrate= 349.9kbits/


    

猜你喜欢

转载自blog.csdn.net/smallhujiu/article/details/80753765