Closed nypyp closed 3 months ago
pip install ffmpeg
并不会在env_name/lib中下载对应的.so文件,例如libavcodec.so等,所以需要使用conda install ffmpeg
:
conda install -c conda-forge ffmpeg #安装最新版ffmpeg,成功编译版本ffmpeg=5.1.2
如果系统环境中安装了ffmpeg并在系统环境目录下有libavcodec.so等文件的系统路径例如/usr/local/include/等,会优先使用系统路径下的文件进行编译,就算配置了find_library也没用,可以使用message给出编译时具体使用库的地址:
message(STATUS "AVCODEC_LIBRARY: ${AVCODEC_LIBRARY}")
message(STATUS "AVFORMAT_LIBRARY: ${AVFORMAT_LIBRARY}")
message(STATUS "AVUTIL_LIBRARY: ${AVUTIL_LIBRARY}")
message(STATUS "SWSCALE_LIBRARY: ${SWSCALE_LIBRARY}")
#可以使用cmake指令打印编译信息
mkdir build && cd build
cmake
如果系统路径安装了那些库,则会优先使用系统路径编译,但系统路径下的库版本未知编译的python包可能会报flv格式以及音频格式未知等问题导致推流失败:
[INFO] frame_to_text...
[INFO] warm-up done, actual latency = 2.698054s
[NULL @ 0x7f91eacabea0] Requested output format 'flv' is not a suitable output format #视频流编解码问题
[NULL @ 0x7f91eacabea0] Requested output format '-l' is not a suitable output format #音频流编解码问题
[INFO] frame_to_text...
所以最好使用conda安装的ffmpeg所使用的库文件,在CMakeList中使用set语句可以配置库使用具体路径:
set(AVCODEC_LIBRARY "/home/nypyp/miniconda3/envs/nerfstream/lib/libavcodec.so")
set(AVFORMAT_LIBRARY "/home/nypyp/miniconda3/envs/nerfstream/lib/libavformat.so")
set(AVUTIL_LIBRARY "/home/nypyp/miniconda3/envs/nerfstream/lib/libavutil.so")
set(SWSCALE_LIBRARY "/home/nypyp/miniconda3/envs/nerfstream/lib/libswscale.so")
执行pip
后,修改tese_stream.py为播放本地文件:
cap = cv2.VideoCapture("/home/nypyp/code/srs/trunk/doc/source.flv")
sudo apt-get install portaudio19-dev python-all-dev python3-all-dev
#pyaudio pip 安装会报fatal error: portaudio.h: No such file or directory,所以需要先安装前置库
pip install pyaudio
pip install tensorflow-gpu==2.8.0 #报错,依赖冲突
pip install tensorflow-gpu==2.8.1
参考博客:非root用户启动docker
ERROR: Got permission denied while trying to connect to the Docker daemon socket
#解决办法:添加用户到docker组
sudo groupadd docker #添加docker组
sudo gpasswd -a username docker #将用户username添加到组
id #查看用户所在的组
newgrp docker #如果未在组中,在用户终端下使用newgrp用刷新用户组
参考博客:Cannot stop or restart a docker container
sudo systemctl restart docker.socket docker.service
docker rm -f <container id>
pip install protobuf==3.20 #需要降级protobuf
websocket问题,参考issues:metahuman-stream issues
#werkzeug mismatcher websocket问题
#python/site-packages/werkzeug/routing/matcher.py,注释websocket_mismatch = True
#修改python/site-packages/flask_sockets.py
self.url_map.add(Rule(rule, endpoint=f)) #改成
self.url_map.add(Rule(rule, endpoint=f, websocket=True))
lsof -i:8000
kill -9 PID
pip安装成功,但是python test_stream.py的时候运行到
就会报错:
能请问下大佬有什么可能的解决办法吗?