(FFmpeg) How to Stream a File to YouTube?

Part 1: (FFMPEG) HOW TO OBTAIN A YOUTUBE STREAMING KEY?

Streaming a local file to YouTube is extremely easy and actually a feature that really takes your FFmpeg skills to the next level with little effort. 

With the minimal amount of code this script will stream input.mp4 to YouTube without any issues (stream.sh):

YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2" # Youtube Streaming URL
KEY="xxxx-xxxx-xxxx-xxxx" # Your Youtube Streaming Key

ffmpeg -re -i input.mp4 -framerate 30 -f FLV "$YOUTUBE_URL/$KEY"

There’s a new option, -re, in this code that is imperative for a stream to run in realtime. The -re option indicates the stream will read the input at the native frame rate and send output at the same rate. Without this flag, the stream will receive data faster than the user can view it. Breaking the realtime point of going live.

Tip: -framerate 30 is required else the stream will not start.

Trackbacks & Pingbacks 1

  1. From (FFmpeg) How to obtain a YouTube Streaming key? - John Riselvato on 07 Apr 2020 at 1:25 pm

    […] Now you are ready to stream to YouTube. Part 2: (FFMPEG) HOW TO STREAM A FILE TO YOUTUBE? […]