Restream M3U8 source to Facebook Youtube Live

205 Likes 2 Comments
ffmpeg-livestream

How to restream a m3u8 stream to YouTube/Facebook with FFmpeg
Whilst it’s not common if you want to restream a m3u8 source and view through YouTube here is the way to do it with FFmpeg.

You need to have the m3u8 link and FFmpeg, this method is usually used on a server and then you can view a location blocked m3u8 stream on YouTube (Smart tv).

The FFmpeg batch scripts is:

ffmpeg -re -i https://streamsite.com/stream/streamsource.m3u8 -c:v copy -c:a aac -ar 44100 -ab 128k -ac 2 -strict -2 -flags +global_header -bsf:a aac_adtstoasc -bufsize 2500k -f flv rtmp://a.rtmp.youtube.com/live2/YOUTUBESTREAMKEYHERE

This FFmpeg command copies the m3u8 link and connects to YouTube and streams it live. We are not encoding it, just passing it through to YouTube. The audio defines are just common values and the buffersize is the amount of buffer given.

The only things you need to change unless you wanna play around with audio variables are

https://streamsite.com/stream/streamsource.m3u8 to your actual m3u8 stream url

Put your YouTube live stream key to rtmp://a.rtmp.youtube.com/live2/YOUTUBESTREAMKEYHERE where it says YOUTUBESTREAMKEYHERE

Run the batch script and it will start streaming. Do note if you’re streaming copyrighted content to put the stream unlisted / private.

Thats how to restream or pass on a m3u8 stream to YouTube with FFmpeg.

You might like

Avatar

About the Author: Toc Xoan

2 Comments

  1. i use your command on my ubuntu server, ffmpeg installed but the command do nothing, but if i used for youtube stream eveythink OK, just error for facebook live stream

    1. The command for streaming for Facebook is something like that:

      ffmpeg -re -i https://streamsite.com/stream/streamsource.m3u8 -c:v copy -c:a aac -ar 44100 -ab 128k -ac 2 -strict -2 -flags +global_header -bsf:a aac_adtstoasc -bufsize 2500k -f flv rtmps://live-api-s.facebook.com:443/rtmp/STREAMKEYABC?s_bl=0&s_sw=0&s_vt=api-s&a=STREAMKEYXYZ

      Hope it help 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *