python - ffmpeg rtmp 在 youtube 上播放速度低于 1x

标签 python opencv ffmpeg video-streaming rtmp

我制作了一个 python 和 opencv 程序,该程序每秒产生大约 8-15fps 的帧,具有 MJPEG 输出格式,其中 MJPEG 地址在 localhost 网络服务器(0.0.0.0:5000)上提供,并且我尝试使用 ffmpeg 将其帧广播到像 youtube 这样的 rtmp 服务器所以基本上我确实将 MJEG 转换为 flv 并使用以下命令转发到 rtmp 服务器 ffmpeg -f mjpeg -i http://0.0.0.0:5000/video_feed -f lavfi -i anullsrc -c:v libx264 -vf "scale=trunc(oh*a/2)*2:320,unsharp=lx=3:ly=3:la=1.0" -crf 24 -c:a aac -ac 1 -f flv rtmp://a.rtmp.youtube.com/live2/xxx-xxx-xxx但不幸的是 youtube 流有太多的缓冲,每 5 秒左右发生一次,ffmpeg 终端告诉写入速度只有 0.317x 左右(预计与 youtube 同步大约 0.99-1x),我的问题是
有没有办法以 8-15fps 的速度“实时”流式传输并自动与 youtube rtmp 服务器同步而无需缓冲,因为我认为 youtube 需要大约 30fps 而我的 fps 只有 9-15fps,这可能会导致缓冲。
是否有类似的附加 ffmpeg 参数可以加快写入速度?谢谢你
enter image description here
enter image description here

最佳答案

原始视频通常会分配 25 的帧速率。但您的源是可变帧速率。您需要将挂钟时间指定为时间戳,并为 YT 生成恒定帧速率输出。ffmpeg -f mjpeg -use_wallclock_as_timestamps true -i http://0.0.0.0:5000/video_feed -f lavfi -re -i anullsrc -vsync cfr -r 25 -c:v libx264 -vf "scale=trunc(oh*a/2)*2:320,unsharp=lx=3:ly=3:la=1.0" -crf 24 -c:a aac -ac 1 -f flv rtmp://a.rtmp.youtube.com/live2/xxx-xxx-xxx

关于python - ffmpeg rtmp 在 youtube 上播放速度低于 1x,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64021212/

相关文章:

python - random.randint 非整数? [Python]

python - 如何为列python中的每一行应用一个函数

python - 自动化 shell 脚本登录 vpn 传递 sudo -S

c# - FFMPEG 将音轨连接到更长的视频轨道时,音频循环

flutter - 在 flutter 中录制像 Tiktok/Smule 这样的 Duet 视频

python - Visual Studio 中的一个项目有多个团队 - 不好的做法?

c++ - opencv c++比较不同图像中的关键点位置

c++ - 将 vector<Point2f> 传递给 getAffineTransform

python - 使用 OpenCV 和 Keras 进行人脸比较(不是识别或检测)?

bash - 使用 ffmpeg 将图像转换为电影 - 使用 Bash 将通配符传递给 ffmpeg glob -i 输入