Skip to content

Instantly share code, notes, and snippets.

@kylefmohr
Created May 10, 2025 17:02
Show Gist options
  • Save kylefmohr/b8c71792d151b98cb241d6bee42aa640 to your computer and use it in GitHub Desktop.
Save kylefmohr/b8c71792d151b98cb241d6bee42aa640 to your computer and use it in GitHub Desktop.
Re-encoding a troublesome RTSP stream to YouTube Live's RTMP via ffmpeg
#!/bin/bash
ffmpeg \
-hide_banner \
-thread_queue_size 512 \
-fflags +genpts+discardcorrupt+igndts \
-err_detect ignore_err \
-use_wallclock_as_timestamps 1 \
-rtsp_transport tcp \
-stimeout 30000000 \
-re \
-i "rtsp://YOUR_USERNAME:[email protected]:554/live/av0" \
-f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 \
-map 0:v:0 -map 1:a:0 \
-c:v libx264 -preset veryfast -pix_fmt yuv420p -s 1920x1080 -r 60 -g 120 -b:v 4000k -maxrate 4500k -bufsize 8000k \
-c:a aac -b:a 128k -ar 44100 \
-f flv -max_muxing_queue_size 1024 \
-tune zerolatency \
"rtmp://a.rtmp.youtube.com/live2/YOUR_YOUTUBE_LIVE_STREAM_KEY"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment