Skip to content

Instantly share code, notes, and snippets.

@olasd
Created March 28, 2014 19:58
Show Gist options
  • Save olasd/9841772 to your computer and use it in GitHub Desktop.
Save olasd/9841772 to your computer and use it in GitHub Desktop.
Stream video to youtube via ffmpeg
#! /bin/bash
#
# Diffusion youtube avec ffmpeg
# Configurer youtube avec une résolution 720p. La vidéo n'est pas scalée.
VBR="2500k" # Bitrate de la vidéo en sortie
FPS="30" # FPS de la vidéo en sortie
QUAL="medium" # Preset de qualité FFMPEG
YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2" # URL de base RTMP youtube
SOURCE="udp://239.255.139.0:1234" # Source UDP (voir les annonces SAP)
KEY="...." # Clé à récupérer sur l'event youtube
ffmpeg \
-i "$SOURCE" -deinterlace \
-vcodec libx264 -pix_fmt yuv420p -preset $QUAL -r $FPS -g $(($FPS * 2)) -b:v $VBR \
-acodec libmp3lame -ar 44100 -threads 6 -qscale 3 -b:a 712000 -bufsize 512k \
-f flv "$YOUTUBE_URL/$KEY"
@ggrelet
Copy link

ggrelet commented Apr 4, 2021

is it possible to set my source as another live video? eg: live video url from Facebook something like https://www.facebook.com/groupname/videos/590993838218530/

Interested by any answer too, I tried with piping from youtube-dl with no luck.

@BitcoinJake09
Copy link

is it possible to set my source as another live video? eg: live video url from Facebook something like https://www.facebook.com/groupname/videos/590993838218530/

Interested by any answer too, I tried with piping from youtube-dl with no luck.

im here looking for answers too, im currently trying to write code using FFMPEG & youtube-dl, and i seem to have that part ok, but i really want to stream from a URL like @bentech4u wants to do also.. hopefully someone in this community can figure it out. best of luck all.

@faraamcode
Copy link

Please how can I stream a website URL (like an ongoing video conference url ) to youtube using FFmpeg

@adriel
Copy link

adriel commented Dec 15, 2021

@faraamcode you could (if supported) first get the feed down via streamlink, then pipe it into ffmpeg.

@dedshit
Copy link

dedshit commented Jan 8, 2022

@bentech4u Copy M3U8 from facebook live thats all also if both video , audio streams are libx264, aac respectively then no need for re-encoding stream to youtube rtmp

if not then you need to encode codecs suggested by youtube

@dedshit
Copy link

dedshit commented Jan 8, 2022

damn man why the hell you reported my question 🤨🤨

@adriel
Copy link

adriel commented Sep 11, 2023

It can be as simple as ffmpeg -i "<YOUR_SOURCE>" -f flv "rtmp://a.rtmp.youtube.com/live2/<YOUR_STREAM_KEY>"

The other stuff just adds extra control. You may or may not need it depending on your needs.

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