Skip to content

Instantly share code, notes, and snippets.

@TinyPoro
Forked from qntmpkts/m3u8-to-youtube-live.md
Created February 11, 2021 03:56
Show Gist options
  • Save TinyPoro/4d5ee7707457a2c75edf12b315991377 to your computer and use it in GitHub Desktop.
Save TinyPoro/4d5ee7707457a2c75edf12b315991377 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.

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