Skip to content

Instantly share code, notes, and snippets.

@heikomat
Last active March 3, 2024 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heikomat/f6c79a6fd13c39f39cce8bc50e5a86c1 to your computer and use it in GitHub Desktop.
Save heikomat/f6c79a6fd13c39f39cce8bc50e5a86c1 to your computer and use it in GitHub Desktop.
basketball game stream with mirrorless/dslr camera

obs:

  • video: output to 1080p at 59.94fps - because that's what the camera outputs
  • advanced, Filename formatting: "obs" (so that the recording file doesn't change all the time)
  • output, recording
    • format: mpeg-ts (works well for streams)
    • encoder: H264 hardware encoder (easier on the battery)
    • rate control: CBR
    • bitrate: 20000 kbps (more than that will cause the video in the file to lag if it is being read at the same time)
    • keyframe-interval: 2s (easier to pick-up lost streams)
  • start recording

ffmpeg:

while true; do
    ffmpeg \
      -re -sseof -1 -i ~/Movies/obs.ts \
      -acodec aac -ar 44100 -b:a 192k \
      -vcodec hevc_videotoolbox \
      -b:v 13500K -maxrate 20M \
      -vf "minterpolate=fps=60:mi_mode=blend,format=pix_fmts=yuv420p,scale=2560:-1" \
      -f flv rtmp://x.rtmp.youtube.com/live2/<stream-key>
done
  • start reading the recording at the end of the file (-sseof -1)
  • use hardware-h265 encoding for high quality per bitrate
  • set the bitrate to the one suggested by youtube for 1440p streams
    • reduce that bitrate if it is to much for the internet connection
  • set the max bitrate to whatever the internet connections allows to prevent stuttering
  • motion-interpolate the 59.94 fps video to 60 fps to prevent stuttering
  • upscale the video to 1440p so youtube gives it more bitrate
  • stream the video to youtube
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment