OBS 启动参数设为 --startstreaming , 可以让它启动后自动开始直播
对应ffmpeg参数:
bash
@echo off
:loop
ffmpeg -re -i a.mp4 -r 24 -c:v libx264 -preset ultrafast -profile:v baseline -g 24 -keyint_min 24 -x264-params nal-hrd=cbr -b:v 2500k -minrate 1250k -maxrate 3750k -bufsize 5000k -c:a aac -b:a 128k -f flv rtmp://你的推流地址
if errorlevel 1 (
echo FFmpeg exited with an error. Reconnecting in 5 seconds...
timeout /t 5 /nobreak >nul
goto loop
) else (
echo FFmpeg exited without error. Exiting the script.
)
-r 24 每秒24帧
-g 24 -keyint_min 24 每24帧有一个关键帧(关键帧间隔1s)
-x264-params nal-hrd=cbr -b:v 2500k -minrate 1250k -maxrate 3750k -bufsize 5000k
码率2500Kbs ,采用CBR码率控制