lipku / metahuman-stream

Real time interactive streaming digital human

Home Page:https://zhuanlan.zhihu.com/p/675131165

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cant get any video stream on Vlc with rtmp://localhost/live/livestream, err with Requested output format 'flv' is not a suitable output format

nypyp opened this issue · comments

python 3.10
pytorch 1.12.1 cuda 11.3
ubuntu 18.04
ffmpeg 4.4.2

after the install guide, run docker and app.py, cant get the video on vlc and get a err in app.py that said Requested output format 'flv' is not a suitable output format, did there are any advise to fix this issue? if you know, please help me, thx

[INFO] warm up ASR live model, expected latency = 1.400000s
start websocket server
[INFO] frame_to_text... 
[INFO] warm-up done, actual latency = 2.698054s
[NULL @ 0x7f91eacabea0] Requested output format 'flv' is not a suitable output format
[INFO] frame_to_text... 
[INFO] frame_to_text... 
[INFO] frame_to_text... 
[INFO] frame_to_text... 
------actual avg fps:28.9061
[INFO] frame_to_text... 
[INFO] frame_to_text... 
[INFO] frame_to_text... 
[INFO] frame_to_text... 
------actual avg fps:39.0283

step1 编译python_rtmpstream

安装ffmpeg

pip install ffmpeg并不会在env_name/lib中下载对应的.so文件,例如libavcodec.so等,所以需要使用conda install ffmpeg:

conda install -c conda-forge ffmpeg #安装最新版ffmpeg,成功编译版本ffmpeg=5.1.2

编译rtmp_streaming

如果系统环境中安装了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")

修改tese_stream

执行pip后,修改tese_stream.py为播放本地文件:

cap = cv2.VideoCapture("/home/nypyp/code/srs/trunk/doc/source.flv")

安装pyaudio

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
#apt 安装报错下列软件包有未满足的依赖关系:portaudio19-dev : 依赖: libasound2-dev 但是它将不会被安装
#换conda 安装
conda install pyaudio

step2 metahuman-stream

metahuman-stream install

pip install tensorflow-gpu==2.8.0 #报错,依赖冲突
pip install tensorflow-gpu==2.8.1

docker run

非root用户启动docker

参考博客:非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用刷新用户组
docker 假死进程占用端口

参考博客:Cannot stop or restart a docker container

sudo systemctl restart docker.socket docker.service
docker rm -f <container id>

运行app.py出现的问题

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))

nginx端口占用问题

lsof -i:8000
kill -9 PID