Search code examples
ffmpegvideo-streamingsteam

ffmpeg "steam" cbr gop


It's about live video streaming to STEAM... with ffmpeg

I have this command

ffmpeg -re -i file-from-webcam.webm -deinterlace 
-c:v libx264 -pix_fmt yuv420p -preset veryfast 
-tune zerolatency -c:a aac -b:a 128k -ac 2 -strict -2 -crf 18 
-r 30 -g 60  -vb 1369k -minrate 1369k -maxrate 1369 -ar 44100 -x264-params "nal-hrd=cbr" 
-vf "scale=1280:720" -profile:v main 
-f flv "rtmp://ingest-rtmp.broadcast.steamcontent.com/app/steam_...."

but after a few seconds, the stream stops and the log of steam says

    Make sure your upload key-frame interval is set to 2 seconds 
and use constant bitrate (CBR). 
Limit your encoders group of picture (GOP) to at most two times your framerate.

but I do have -x264-params "nal-hrd=cbr" and -r 30 -g 60 framerate 30 GOP 60...

Is there something wrong in the ffmpeg command ? Or is it linux server related ?

**** The SAME ffmpeg command work very nicely in youtube, twitter, twitch, dlive, facebook, etc...

so what I'm I missing to get it work for steam ?


Solution

  • ffmpeg -re -i file.webm -deinterlace -c:v libx264 -preset veryfast -tune zerolatency -c:a aac -b:a 128k -ac 2 -r 30 -g 60 -vb 1369k -minrate 1369k -maxrate 1369k -bufsize 2730k -ar 44100 -x264-params "nal-hrd=cbr" -vf "scale=1280:720,format=yuv420p" -profile:v main -f flv "rtmp://ingest-rtmp.broadcast.steamcontent.com/app/___key___"
    
    • -crf and -b:v/-vb are mutually exclusive. It's likely your -vb was being ignored. Since you want a specific bitrate remove -crf.
    • -maxrate 1369 was missing the k.
    • Add -bufsize. See FFmpeg Wiki: Encoding for Streaming Sites.
    • No need for -strict -2. Users always add that without knowing why. (It was for the old AAC encoder before 2015.)
    • Make sure your input has audio. Some sites like YouTube require audio. If it does not have audio use the anullsrc filter to generate silent audio.