问题描述:
首先,根据官方文档进行H264插件加载的方法如下:
================================================
H.264 Visual Studio
Simon Horne - Feb 2010
================================================
How to compile H.264 for Microsoft Visual Studio
To compile FFMPEG dlls you must use MinGW...
Follow the instructions found here
http://ffmpeg.arrozcru.org/wiki
Special Notes:
You must build the dlls you cannot use FFMPEG statically.
Make sure you read this
http://ffmpeg.arrozcru.org/wiki/index.php?title=MSVC
Once you have successfully compiled FFMPEG the following files will be in the
..msys\local\bin directory.
avcodec-xx.dll
avutil-xx.dll
avcodec-xx.lib
(the numbers may vary depending on the version compiled)
In VS2008 add the following path to Visual Studio include directory path
..msys\local\include
and the following to the Visual Studio lib directory path
..msys\local\bin
To compile X264 use MinGW and follow the instructions here.
http://ffmpeg.arrozcru.org/wiki/index.php?title=X264
Note: You must use x264 ver 80 or greater.
./configure --enable-shared
This will produce a
libx264-xx.dll
in ..msys\local\bin directory and
libx264-xx.dll.a
in ..msys\local\lib
add following to the Visual Studio lib directory path
..msys\local\lib
Now you are ready to compile the plugin under Visual Studio.
You must also compile the h264_helper project.
Once compiled you will need to place these files in the c:\ptlib_plugin directory.
h264-x264_ptplugin.dll
x264plugin_helper.exe
avcodec-xx.dll
avutil-xx.dll
libx264-xx.dll
Don't forget to set the environmental variables
PTLIBPLUGINDIR = c:\ptlib_plugin
To stream codec trace information
PTLIB_TRACE_CODECS = 6
================================================
翻译过来即主要步骤为:
1)编译ffmpeg得到avcodec-xx.dll 和 avutil-xx.dll;【仅支持avcodec-52.dll或avcodec-51.dll,对应avcodec-52依赖于avutil-50.dll,对应avcodec-51依赖于avutil-49.dll,此步骤可直接在网上下载对应dll即可,无需编译ffmpeg源码】
2)编译x264得到libx264-xx.dll;
3)编译“\mod_h323_deps-master\h323plus\plugins\video\H.264\h264-x264_2008.sln”得到h264-x264_ptplugin.dll;【此步骤需依赖于ffmpeg的头文件,还必须是老版本的,我使用的是“FFmpeg-n0.5.14”头文件】
4)编译“\mod_h323_deps-master\h323plus\plugins\video\H.264\gpl\h264_helper_2008.vcproj”得到x264plugin_helper.exe;【此步骤在编译时会遇到一些问题,我这边把“X264_LINK_STATIC”的定义注释掉了,如下图所示,并将依赖库由“libx264.dll.a”修改为“libx264.lib”】
然而后来发现把x264_LINK_STATIC去掉之后,虽然可以编译通过,但调用x264内函数时总是出现pipe管道通信Reading失败的错误,最后必须将X264_LINK_STATIC定义还原,同样将依赖库由“libx264.dll.a”修改为“libx264.lib”,若使用的时win32的编译方式则对应x264也必须对应是32位的库,否则同样会出现pipe管道通信Reading失败的错误。
5)将以下几个文件拷贝到“c:\ptlib_plugin”路径内;
h264-x264_ptplugin.dll
x264plugin_helper.exe
avcodec-xx.dll
avutil-xx.dll
libx264-xx.dll
6)设置环境变量:PTLIBPLUGINDIR = c:\ptlib_plugin
7)设置码流编解码跟踪信息:PTLIB_TRACE_CODECS = 6
如下图所示进行设置
按上述步骤加载H264插件,出现无法加载“avcodec-52.dll”的问题:
问题分析:
通过跟踪源代码发现,LoadLibrary("c:\ptlib_plugin\avcodec-52")无法打开
解决方法:
设置系统环境变量,LoadLibrary("avcodec-52")可以正常打开。