ps:視頻測試demo,服務器配置很低,加載有點慢;需要有音視頻設備,不然會報錯。
關於官網文檔
只測試了 Windows 。講的不是很清楚,文檔內容有缺失,通過查詢 issues 、官網討論論壇 和 自我嘗試,還好最終編譯運行成功了。
官網文檔關鍵點
所有平台需要環境
- node version >= v12.0.0
- python version >= 3.6 with PIP
- GNU make
node 和 python 下載最新版本安裝即可
node 沒什么注意的
python 需要配置好環境變量並且刪除系統自帶的程序別名問題
系統用戶環境變量里面有一個 %USERPROFILE%\AppData\Local\Microsoft\WindowsApps 這個文件夾里面有 python.exe 的快捷方式?會在安裝 mediasoup 時導致 找不到 python pip 問題,進入 WindowsApps 文件夾把 python.exe python3.exe...刪除了就可以。
GNU make 也通過文檔提供的地址下載,安裝,然后 添加路徑(*:\MinGW\msys\1.0\bin)到環境變量,只是安裝的時候需要注意,需要安裝完 make 會依賴到的所有包。
最開始嘗試只選中帶 make 字段的包安裝,在命令行 make -v 能正常彈出信息,但是嘗試安裝就會出錯。具體是哪些不清楚...選了一大半,最后沒問題了。
每次 MinGW Installer 下載安裝包時,有可能會失敗,失敗了就可能導致最后 make 會出問題,所以需要關注一下,下載安裝的log。
使用的 vscode 終端,make -v 可能沒反應,就是有問題,用 cmd 命令行能彈出錯誤提示,總之, make 有問題就需要 通過 MinGW Installer 重新安裝。
然后 Microsoft Visual Studio 可以在 官網下載
安裝配置時必須選上 使用 C++ 的桌面開發
然后添加環境變量,包含三個關鍵程序的路徑:cl.exe、vcvars64.bat、MSBuild.exe
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64
具體路徑和 Microsoft Visual Studio 版本有關系,大概位置不變。
最后下載文檔里面的證書 安裝到計算機上,選擇安裝到 當前用戶 和 本地計算機時,可以兩個都裝起...
編譯時具體環境
安裝流程 npm install mediasoup@3 --save
一直使用 vscode 終端 卡了一個錯誤好久
Directory does not contain a valid build tree: H:\workspace\mediasoup-demo-3\server\node_modules\mediasoup\worker\out\Release The Meson build system Version: 0.60.2 Source dir: H:\workspace\mediasoup-demo-3\server\node_modules\mediasoup\worker Build dir: H:\workspace\mediasoup-demo-3\server\node_modules\mediasoup\worker\out\Release Build type: native build Project name: mediasoup-worker Project version: undefined meson.build:1:0: ERROR: Compiler cl can not compile programs.
Compiler cl can not compile programs ,讓人崩潰。
這個有一個前提 需要提前運行一下 vcvars64 ,並且還有一點區別
默認新開終端是 PowerShell ,此時需要完整執行
cmd /c "call `"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat`" && set > %temp%/vcvars.txt" Get-Content "$env:temp\vcvars.txt" | Foreach-Object { if ($_ -match "^(.*?)=(.*)$") { Set-Content "env:\$($matches[1])" $matches[2] } }
然后再 npm install mediasoup
如果是選擇 cmd ,則只需要 vcvars64 回車一下就好 。
此時應該都能進入正常流程,下載所需要的依賴、然后編譯 mediasoup 的關鍵底層服務。
下載的時候很容易就會出錯,導致安裝失敗
http.client.RemoteDisconnected: Remote end closed connection without response make: *** [setup] 錯誤 2
Remote end closed connection without response ,下載每個包都可能這樣,如果網絡沒問題(vpn、番薔),全部下載成功,即可進入編譯,最后安裝成功。
PowerShell
PS H:\workspace\edumeet-master\server> cmd /c "call `"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat`" && set > %temp%/vcvars.txt" ********************************************************************** ** Visual Studio 2017 Developer Command Prompt v15.9.41 ** Copyright (c) 2017 Microsoft Corporation ********************************************************************** [vcvarsall.bat] Environment initialized for: 'x64' PS H:\workspace\edumeet-master\server> PS H:\workspace\edumeet-master\server> Get-Content "$env:temp\vcvars.txt" | Foreach-Object { >> if ($_ -match "^(.*?)=(.*)$") { >> Set-Content "env:\$($matches[1])" $matches[2] >> } >> } PS H:\workspace\edumeet-master\server> npm install mediasoup@3 --save > mediasoup@3.9.2 postinstall H:\workspace\edumeet-master\server\node_modules\mediasoup > node npm-scripts.js postinstall npm-scripts.js [INFO] running task "postinstall" npm-scripts.js [INFO] executing command: node npm-scripts.js worker:build npm-scripts.js [INFO] running task "worker:build" npm-scripts.js [INFO] executing command: make -C worker make: Entering directory `/h/workspace/edumeet-master/server/node_modules/mediasoup/worker' # Updated pip and setuptools are needed for meson # `--system` is not present everywhere and is only needed as workaround for # Debian-specific issue (copied from # https://github.com/gluster/gstatus/pull/33), fallback to command without # `--system` if the first one fails. python -m pip install --system --target=/h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/pip pip setuptools || \ python -m pip install --target=/h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/pip pip setuptools || \ echo "Installation failed, likely because PIP is unavailable, if you are on Debian/Ubuntu or derivative please install the python3-pip package" Usage: h:\Program Files\Python310\python.exe -m pip install [options] <requirement specifier> [package-index-options] ... h:\Program Files\Python310\python.exe -m pip install [options] -r <requirements file> [package-index-options] ... h:\Program Files\Python310\python.exe -m pip install [options] [-e] <vcs project url> ... h:\Program Files\Python310\python.exe -m pip install [options] [-e] <local project path> ... h:\Program Files\Python310\python.exe -m pip install [options] <archive url/path> ... no such option: --system Collecting pip Using cached pip-21.3.1-py3-none-any.whl (1.7 MB) Collecting setuptools Using cached setuptools-59.2.0-py3-none-any.whl (952 kB) Installing collected packages: setuptools, pip Successfully installed pip-21.3.1 setuptools-59.2.0 # Install `meson` and `ninja` using `pip` into custom location, so we don't # depend on system-wide installation. python -m pip install --upgrade --target=/h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/pip meson ninja Collecting meson Using cached meson-0.60.2-py3-none-any.whl (838 kB) Collecting ninja Using cached ninja-1.10.2.3-py2.py3-none-win_amd64.whl (292 kB) Installing collected packages: ninja, meson Successfully installed meson-0.60.2 ninja-1.10.2.3 /h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/pip/bin/meson setup \ --buildtype release \ -Db_ndebug=true \ -Db_pie=true \ -Db_staticpic=true \ --reconfigure \ "" \ /h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/Release || \ /h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/pip/bin/meson setup \ --buildtype release \ -Db_ndebug=true \ -Db_pie=true \ -Db_staticpic=true \ "" \ /h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/Release Directory does not contain a valid build tree: H:\workspace\edumeet-master\server\node_modules\mediasoup\worker\out\Release The Meson build system Version: 0.60.2 Source dir: H:\workspace\edumeet-master\server\node_modules\mediasoup\worker Build dir: H:\workspace\edumeet-master\server\node_modules\mediasoup\worker\out\Release Build type: native build Project name: mediasoup-worker Project version: undefined C compiler for the host machine: cl (msvc 19.16.27045 "���� x64 �� Microsoft (R) C/C++ �������� 19.16.27045 ��") C linker for the host machine: link link 14.16.27045.0 C++ compiler for the host machine: cl (msvc 19.16.27045 "���� x64 �� Microsoft (R) C/C++ �������� 19.16.27045 ��") C++ linker for the host machine: link link 14.16.27045.0 Host machine cpu family: x86_64 Host machine cpu: x86_64 Downloading openssl source from https://www.openssl.org/source/openssl-1.1.1l.tar.gz Download size: 9834044 Downloading: .......... Downloading openssl patch from https://wrapdb.mesonbuild.com/v2/openssl_1.1.1l-2/get_patch Download size: 10613607 Downloading: .
Command Prompt
H:\workspace\edumeet-master\server>vcvars64 ********************************************************************** ** Visual Studio 2017 Developer Command Prompt v15.9.41 ** Copyright (c) 2017 Microsoft Corporation ********************************************************************** [vcvarsall.bat] Environment initialized for: 'x64' H:\workspace\edumeet-master\server>npm install mediasoup > mediasoup@3.9.2 postinstall H:\workspace\edumeet-master\server\node_modules\mediasoup > node npm-scripts.js postinstall npm-scripts.js [INFO] running task "postinstall" npm-scripts.js [INFO] executing command: node npm-scripts.js worker:build npm-scripts.js [INFO] running task "worker:build" npm-scripts.js [INFO] executing command: make -C worker make: Entering directory `/h/workspace/edumeet-master/server/node_modules/mediasoup/worker' # Updated pip and setuptools are needed for meson # `--system` is not present everywhere and is only needed as workaround for # Debian-specific issue (copied from # https://github.com/gluster/gstatus/pull/33), fallback to command without # `--system` if the first one fails. python -m pip install --system --target=/h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/pip pip setuptools || \ python -m pip install --target=/h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/pip pip setuptools || \ echo "Installation failed, likely because PIP is unavailable, if you are on Debian/Ubuntu or derivative please install the python3-pip package" Usage: h:\Program Files\Python310\python.exe -m pip install [options] <requirement specifier> [package-index-options] ... h:\Program Files\Python310\python.exe -m pip install [options] -r <requirements file> [package-index-options] ... h:\Program Files\Python310\python.exe -m pip install [options] [-e] <vcs project url> ... h:\Program Files\Python310\python.exe -m pip install [options] [-e] <local project path> ... h:\Program Files\Python310\python.exe -m pip install [options] <archive url/path> ... no such option: --system Collecting pip Using cached pip-21.3.1-py3-none-any.whl (1.7 MB) Collecting setuptools Using cached setuptools-59.2.0-py3-none-any.whl (952 kB) Installing collected packages: setuptools, pip Successfully installed pip-21.3.1 setuptools-59.2.0 # Install `meson` and `ninja` using `pip` into custom location, so we don't # depend on system-wide installation. python -m pip install --upgrade --target=/h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/pip meson ninja Collecting meson Using cached meson-0.60.2-py3-none-any.whl (838 kB) Collecting ninja Using cached ninja-1.10.2.3-py2.py3-none-win_amd64.whl (292 kB) Installing collected packages: ninja, meson Successfully installed meson-0.60.2 ninja-1.10.2.3 /h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/pip/bin/meson setup \ --buildtype release \ -Db_ndebug=true \ -Db_pie=true \ -Db_staticpic=true \ --reconfigure \ "" \ /h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/Release || \ /h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/pip/bin/meson setup \ --buildtype release \ -Db_ndebug=true \ -Db_pie=true \ -Db_staticpic=true \ "" \ /h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/Release Directory does not contain a valid build tree: H:\workspace\edumeet-master\server\node_modules\mediasoup\worker\out\Release The Meson build system Version: 0.60.2 Source dir: H:\workspace\edumeet-master\server\node_modules\mediasoup\worker Build dir: H:\workspace\edumeet-master\server\node_modules\mediasoup\worker\out\Release Build type: native build Project name: mediasoup-worker Project version: undefined C compiler for the host machine: cl (msvc 19.16.27045 "���� x64 �� Microsoft (R) C/C++ �������� 19.16.27045 ��") C linker for the host machine: link link 14.16.27045.0 C++ compiler for the host machine: cl (msvc 19.16.27045 "���� x64 �� Microsoft (R) C/C++ �������� 19.16.27045 ��") C++ linker for the host machine: link link 14.16.27045.0 Host machine cpu family: x86_64 Host machine cpu: x86_64 Downloading openssl source from https://www.openssl.org/source/openssl-1.1.1l.tar.gz Download size: 9834044 Downloading: ...
PS:此時如果指定安裝舊一點版本的 mediasoup ,比如 3.5.14 還會失敗...不久之前更改了編譯方案的原因,舊的需要改配置。