Skip to content

Instantly share code, notes, and snippets.

@qntmpkts
Last active April 8, 2024 13:51
Show Gist options
  • Star 25 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save qntmpkts/403a027a4bfe99812ebf8952c41f8789 to your computer and use it in GitHub Desktop.
Save qntmpkts/403a027a4bfe99812ebf8952c41f8789 to your computer and use it in GitHub Desktop.
Restream m3u8 stream with ffmpeg to youtube live

Setup YouTube Live Event

Head on over to your YouTube live Events page (https://www.youtube.com/my_live_events).

Create a new live event that is unlisted (or private) and of Custom type.

Under Basic ingestion choose 1500 Kbps - 4000 kbps (720p).

Check the Enable 60fps box.

Note your Stream Name and Primary Server URL.

Restream With FFmpeg

Get FFmpeg for your machine (sudo apt-get install ffmpeg)

Run the following in a new terminal window (replacing <m3u8_5000kbps_url> and <youtube_rtmp_address>):

ffmpeg -re -i <m3u8_5000kbps_url> -c:v copy -c:a aac -ar 44100 -ab 128k -ac 2 -strict -2 -flags +global_header -bsf:a aac_adtstoasc -bufsize 3000k -f flv "<youtube_rtmp_address>"

Example:

ffmpeg -re -i protocol://domain.tld/stream.m3u8 -c:v copy -c:a aac -ar 44100 -ab 128k -ac 2 -strict -2 -flags +global_header -bsf:a aac_adtstoasc -bufsize 3000k -f mp4 "rtmp://a.rtmp.youtube.com/live2/<STREAMNAME/KEY>"

Back To YouTube

Head back to your YouTube Live Event.

Click on the Live Control Room tab up top.

Click the Preview button.

The stream should take a moment to preview, then you can click the Start button.

@joy-khan
Copy link

make a video bro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment