在win10上编译webRTC(问题篇)

参考链接:https://webrtc.org.cn/mirror/

主要是记录《在win10上编译webRTC(编译篇)》中,遇到的问题,以及解决方案。仅作为记录用。

问题一

在编译生成的时候出现:

ERROR at //build/config/win/visual_studio_version.gni:27:7: Script returned non-zero exit code.....

原因:第一行忘记输入。

问题二

Exception: dbgcore.dll not found in "C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\dbgcore.dll"

原因:VS2017的SDK不对。

解决方案:https://developer.microsoft.com/en-us/windows/downloads/sdk-archive/

set DEPOT_TOOLS_WIN_TOOLCHAIN=0

gn gen out/Release "--args=is_debug=false"

ninja -C out/Release

 

问题三

import win32file #pylint:disable=import-error

ImportError:No module named win32file

ninja:build stopped:subcommand failed.

原因:python版本不对。因为我电脑上之前有3.7, 后来又安装了2.7,即使启动项改成了2,也不行。

解决方案:卸载电脑上所有的python,新下载python,下载了32位的。重新安装,然后配置路径。

https://www.python.org/downloads/windows/

然后下面这个下载好之后,把*.exe 放到上面python2的安装路径下,直接运行就OK了。

https://sourceforge.net/projects/pywin32/files/pywin32/Build%20221/

问题四

这个问题很棘手!!!

编译好的server.exe 和client.exe ,用两台笔记本,连接局域网,一台同时启动server和client,另一台启动client,同时连接到server , 点击client窗口出现的设备名称,即可打开两台设备,进行音视频通信。但是,刚几秒,就出bug了。如下:

void vp8_transform_intra_mby() 报错!

原因猜测:视频编码采用VP8,出现的问题,如果采用openh264会这么样呢?所以参考下面的文件,修改一下。

解决bug,参考链接:https://www.jianshu.com/p/e98b9365bc68

另外,根据《4个你为什么要在WebRTC服务中选择H.264的原因》  的分析,虽然是4年前的分析,放在现在,也还是很有道理。

h264Debug32版本的解决方案:

第一次:需要支持H264的h264Debug_32

set DEPOT_TOOLS_WIN_TOOLCHAIN=0

set GYP_MSVS_VERSION=2017 //2017是指定vs版本

gn gen out/h264Debug_32 --ide=vs2017 --args=" proprietary_codecs=true   is_debug=true target_cpu=\"x86\" is_clang=false ffmpeg_branding=\"Chrome\"  rtc_use_h264=true rtc_include_tests=false treat_warnings_as_errors=false"

ninja -C out/h264Debug_32

错误提示:asser(!(is_win && !is_clang), "See: bugs.webrtc.org/9213#c13")

根据错误提示,定位到第一个问题件,把这个注释掉:

然后继续编译。gn gen ..., 这句话不会报错。

再次出现错误时,用这个  ninja -C out/h264Debug_32 >> build.log    输出错误,去log中,看看哪里有error。

注释掉\third_party\ffmpeg\libavcodec\pcm.c的最后一行,原因是PCM_VIDC这个标志未定义,通过宏定义无法正确生成,导致编译报错  C2059  error "string"。

中间还有一个过程,将 out/h264Debug_32中的 *.ninja , 将 /MTD, /MTd,都改为/MDd. 

在sdp协商中,如果有多种视频编码,h264往往被放在最后一个,可以在./media/engine/internal_encoder_factory.cc文件中

std::vectorInternalEncoderFactory::GetSupportedFormats() 函数中将h264第一个放进去。

这样,会有协商过程中,会优先使用openh264.

在这个文件中个,修改视频编码器的顺序, \src\media\engine\internal_encoder_factory.cc

链接:https://www.jianshu.com/p/e98b9365bc68

上面的步骤都完成之后,可以修改client的demo中,conductor类中的代码,进行回测。回测针对只有一台电脑的时候,也就是自己的电脑既作为接受方,也作为发送方。:(当然,如果有两台电脑,就直接用两台进行测试也行)

在client.exe,就可以看到自己和自己了。自己发送,自己接收。

h264Debug64版本的解决方案:

set DEPOT_TOOLS_WIN_TOOLCHAIN=0

set GYP_MSVS_VERSION=2017 //2017是指定vs版本

gn gen out/h264Debug_64 --ide=vs2017 --args=" proprietary_codecs=true   is_debug=true target_cpu=\"x64\" is_clang=false ffmpeg_branding=\"Chrome\"  rtc_use_h264=true rtc_include_tests=false treat_warnings_as_errors=false"

ninja -C out/h264Debug_64

执行过程中,出现问题,将日志打印出来,如下:

ninja: Entering directory `out/h264Debug_64'
[1/4] LINK(DLL) webrtc_unity_plugin.dll webrtc_unity_plugin.dll.lib webrtc_unity_plugin.dll.pdb
FAILED: webrtc_unity_plugin.dll webrtc_unity_plugin.dll.lib webrtc_unity_plugin.dll.pdb 
E:/gitHub/depot_tools/win_tools-2_7_6_bin/python/bin/python.exe ../../build/toolchain/win/tool_wrapper.py link-wrapper environment.x64 False link.exe /nologo /IMPLIB:./webrtc_unity_plugin.dll.lib /DLL /OUT:./webrtc_unity_plugin.dll /PDB:./webrtc_unity_plugin.dll.pdb @./webrtc_unity_plugin.dll.rsp
  正在创建库 ./webrtc_unity_plugin.dll.lib 和对象 ./webrtc_unity_plugin.dll.exp

ffmpeg_internal.lib(pcm.obj) : error LNK2001: 无法解析的外部符号 avpriv_emms_asm

ffmpeg_internal.lib(h264_picture.obj) : error LNK2001: 无法解析的外部符号 avpriv_emms_asm

ffmpeg_internal.lib(autorename_libavcodec_utils.obj) : error LNK2001: 无法解析的外部符号 avpriv_emms_asm

ffmpeg_internal.lib(decode.obj) : error LNK2001: 无法解析的外部符号 avpriv_emms_asm

ffmpeg_internal.lib(h264dec.obj) : error LNK2001: 无法解析的外部符号 avpriv_emms_asm

ffmpeg_internal.lib(vp3.obj) : error LNK2001: 无法解析的外部符号 avpriv_emms_asm

./webrtc_unity_plugin.dll : fatal error LNK1120: 1 个无法解析的外部命令

[2/4] LINK peerconnection_client.exe peerconnection_client.exe.pdb
FAILED: peerconnection_client.exe peerconnection_client.exe.pdb 
E:/gitHub/depot_tools/win_tools-2_7_6_bin/python/bin/python.exe ../../build/toolchain/win/tool_wrapper.py link-wrapper environment.x64 False link.exe /nologo /OUT:./peerconnection_client.exe /PDB:./peerconnection_client.exe.pdb @./peerconnection_client.exe.rsp
ffmpeg_internal.lib(pcm.obj) : error LNK2001: 无法解析的外部符号 avpriv_emms_asm

ffmpeg_internal.lib(h264_picture.obj) : error LNK2001: 无法解析的外部符号 avpriv_emms_asm

ffmpeg_internal.lib(autorename_libavcodec_utils.obj) : error LNK2001: 无法解析的外部符号 avpriv_emms_asm

ffmpeg_internal.lib(decode.obj) : error LNK2001: 无法解析的外部符号 avpriv_emms_asm

ffmpeg_internal.lib(h264dec.obj) : error LNK2001: 无法解析的外部符号 avpriv_emms_asm

ffmpeg_internal.lib(vp3.obj) : error LNK2001: 无法解析的外部符号 avpriv_emms_asm

./peerconnection_client.exe : fatal error LNK1120: 1 个无法解析的外部命令

ninja: build stopped: subcommand failed.

上面的错误,应该是链接的时候,不正确导致的,所有修改src/out/h264Debug_64文件夹下 所有*.ninja 文件,将其中 /MTd 改为 MDd . 然后重新执行 ninja的命令行。上面的错误,依然没有变化。

猜测错误的原因:应该是跟我安装的python版本,如下图:这可能是元凶。

h264Release32版本的解决方案:

set DEPOT_TOOLS_WIN_TOOLCHAIN=0

set GYP_MSVS_VERSION=2017 //2017是指定vs版本

gn gen out/h264Release_32 --ide=vs2017 --args=" proprietary_codecs=true   is_debug=false target_cpu=\"x86\" is_clang=false ffmpeg_branding=\"Chrome\"  rtc_use_h264=true rtc_include_tests=false treat_warnings_as_errors=false"

ninja -C out/h264Release_32

前三句正常: 

执行ninja命令,一路到底,没有报错。也没有build.log 文件输出。

之前需要更改:用notepad++ 进行修改 MT -- MD  。 但是这次并没有更改

h264Release64版本的解决方案:

set DEPOT_TOOLS_WIN_TOOLCHAIN=0

set GYP_MSVS_VERSION=2017 //2017是指定vs版本

gn gen out/h264Release_64 --ide=vs2017 --args=" proprietary_codecs=true   is_debug=false target_cpu=\"x64\" is_clang=false ffmpeg_branding=\"Chrome\"  rtc_use_h264=true rtc_include_tests=false treat_warnings_as_errors=false"

ninja -C out/h264Release_64

release64也出错了, 错误相同。那就是python的问题了。先搁置争议,开发32位的。

ninja: Entering directory `out/h264Release_64'
[1/4] LINK(DLL) webrtc_unity_plugin.dll webrtc_unity_plugin.dll.lib webrtc_unity_plugin.dll.pdb
FAILED: webrtc_unity_plugin.dll webrtc_unity_plugin.dll.lib webrtc_unity_plugin.dll.pdb 
E:/gitHub/depot_tools/win_tools-2_7_6_bin/python/bin/python.exe ../../build/toolchain/win/tool_wrapper.py link-wrapper environment.x64 False link.exe /nologo /IMPLIB:./webrtc_unity_plugin.dll.lib /DLL /OUT:./webrtc_unity_plugin.dll /PDB:./webrtc_unity_plugin.dll.pdb @./webrtc_unity_plugin.dll.rsp
  正在创建库 ./webrtc_unity_plugin.dll.lib 和对象 ./webrtc_unity_plugin.dll.exp

ffmpeg_internal.lib(pcm.obj) : error LNK2001: 无法解析的外部符号 avpriv_emms_asm

ffmpeg_internal.lib(h264_picture.obj) : error LNK2001: 无法解析的外部符号 avpriv_emms_asm

ffmpeg_internal.lib(autorename_libavcodec_utils.obj) : error LNK2001: 无法解析的外部符号 avpriv_emms_asm

ffmpeg_internal.lib(decode.obj) : error LNK2001: 无法解析的外部符号 avpriv_emms_asm

ffmpeg_internal.lib(h264dec.obj) : error LNK2001: 无法解析的外部符号 avpriv_emms_asm

ffmpeg_internal.lib(vp3.obj) : error LNK2001: 无法解析的外部符号 avpriv_emms_asm

./webrtc_unity_plugin.dll : fatal error LNK1120: 1 个无法解析的外部命令

[2/4] LINK peerconnection_client.exe peerconnection_client.exe.pdb
FAILED: peerconnection_client.exe peerconnection_client.exe.pdb 
E:/gitHub/depot_tools/win_tools-2_7_6_bin/python/bin/python.exe ../../build/toolchain/win/tool_wrapper.py link-wrapper environment.x64 False link.exe /nologo /OUT:./peerconnection_client.exe /PDB:./peerconnection_client.exe.pdb @./peerconnection_client.exe.rsp
ffmpeg_internal.lib(pcm.obj) : error LNK2001: 无法解析的外部符号 avpriv_emms_asm

ffmpeg_internal.lib(h264_picture.obj) : error LNK2001: 无法解析的外部符号 avpriv_emms_asm

ffmpeg_internal.lib(autorename_libavcodec_utils.obj) : error LNK2001: 无法解析的外部符号 avpriv_emms_asm

ffmpeg_internal.lib(decode.obj) : error LNK2001: 无法解析的外部符号 avpriv_emms_asm

ffmpeg_internal.lib(h264dec.obj) : error LNK2001: 无法解析的外部符号 avpriv_emms_asm

ffmpeg_internal.lib(vp3.obj) : error LNK2001: 无法解析的外部符号 avpriv_emms_asm

./peerconnection_client.exe : fatal error LNK1120: 1 个无法解析的外部命令

ninja: build stopped: subcommand failed.

-------------------------------华丽分割线,至此,完成两个版本的编译,其他类似,就不记录了------------------------------

====================================================================================

-------------------------------下面是一些花絮问题,完全没有条理,不建议读者看,仅作为自己记录------------------------

E:\gitHub\webrtc_2\src>set DEPOT_TOOLS_WIN_TOOLCHAIN=0

E:\gitHub\webrtc_2\src>set GYP_MSVS_VERSION=2017

E:\gitHub\webrtc_2\src>gn gen out/h264Release_32 --ide=vs2017 --args=" proprietary_codecs=true   is_debug=false target_cpu=\"x86\" is_clang=false ffmpeg_branding=\"Chrome\"  rtc_use_h264=true rtc_include_tests=false treat_warnings_as_errors=false use_rtti=true"
ERROR at //modules/video_coding/BUILD.gn:297:5: Assertion failed.
    assert(!(is_win && !is_clang), "See: bugs.webrtc.org/9213#c13.")
    ^-----
See: bugs.webrtc.org/9213#c13.
See //api/video_codecs/BUILD.gn:41:5: which caused the file to be included.
    "../../modules/video_coding:codec_globals_headers",
    ^-------------------------------------------------

找到下面博客中说的解决方案:

根据上面博客的提示,在 .h文件中并没有发现那句话,倒是在 BUILD.gn中发现了,然后注释掉这句话。

 

再重新执行 gn gen ...  运行到一半,然后出现这个问题:

e:\github\webrtc_2\src\third_party\ffmpeg\libavcodec\fft_template.c(292): warning C4003: 类函数宏的调用“SPLIT_RADIX_PERMUTATION”参数不足
e:\github\webrtc_2\src\third_party\ffmpeg\libavcodec\fft_template.c(292): warning C4003: 类函数宏的调用“PROCESS_FFT_PERM_SWAP_LSBS”参数不足
e:\github\webrtc_2\src\third_party\ffmpeg\libavcodec\fft_template.c(292): warning C4003: 类函数宏的调用“PROCESS_FFT_PERM_DEFAULT”参数不足
ninja: build stopped: subcommand failed.

输入: ninja -C out/release_32 >> build.log   // 这句话可以输出日志,用notepad++打开,查找error,看哪里错误。

运行到一半,又出错了:

ninja: build stopped: subcommand failed.

继续用这个代码:ninja -C out/release_32 >> build.log  // 查看错误信息,直到所有的错误信息都解决掉

猜你喜欢

转载自blog.csdn.net/qq_34732729/article/details/105707104