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.
One thought on “(FFmpeg) How to Stream a File to YouTube?”
Comments are closed.