一、前言
DirectShow采集出来的视频, 采集格式(例如: mjepg)和我们需要的视频格式(i420)并不一致,因此需要解码
二、libyuv下载
git clone https://chromium.googlesource.com/external/libyuv
三、libjpeg-turbo下载
git clone https://github.com/libjpeg-turbo/libjpeg-turbo.git
四、libjpeg编译可以参考 BUILDING.md
环境:
- VS2019
- CMake
- YASM
启动vs工具 编译:
cd libjpeg-turbo
cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Release
nmake
编译生成
jpeg-static.lib Static link library for the libjpeg API
jpeg{version}.dll DLL for the libjpeg API
jpeg.lib Import library for the libjpeg API
turbojpeg-static.lib Static link library for the TurboJPEG API
turbojpeg.dll DLL for the TurboJPEG API
turbojpeg.lib Import library for the TurboJPEG API
五、打开libyuv CMakeLists.txt
1、默认libyuv是没有配置JPEG的
2、libyuv目录下创建libjpeg,拷贝库和头文件
-libjpeg
-jpeglib.h
-jconfig.h
-jmorecfg.h
-lib
-jpeg.lib
-jpeg62.dll
3、修改CMakeLists.txt
A、SET ( ly_lib_shared ${ly_lib_name}_shared )后面添加
SET ( JPEG_INCLUDE_DIR ${ly_base_dir}/libjpeg)
SET ( JPEG_LIBRARY jpeg)
B、ADD_LIBRARY ( ${ly_lib_static} STATIC ${ly_source_files} ) 后面添加
TARGET_LINK_LIBRARIES (${ly_lib_static} ${JPEG_LIBRARY})
C、ADD_LIBRARY ( ${ly_lib_shared} SHARED ${ly_source_files} )后面添加
TARGET_LINK_LIBRARIES (${ly_lib_shared} ${JPEG_LIBRARY})
D、去掉
target_compile_options(${ly_lib_static} PRIVATE
-Wno-sign-compare
-Wno-unused-function
-Wunused-variable
-Wuninitialized)
如图:
4、编译libyuv
md out
cd out
cmake ..
手动打开 YUV.sln
编译生成 yuv.lib
注:编译出来的是yuv.lib,建议直接修改为libyuv.lib和工程名称一致
六、打包库
-libyuv
-include // 这里是libyuv的include文件夹
-lib // libyuv.lib jpeg.lib
-dll // jpeg62.dll