-
-
Save Cyxo/e4192f58e738446f3491d839eaa50ed7 to your computer and use it in GitHub Desktop.
Stream video to youtube via ffmpeg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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 | |
FOLDER="videos" # Source UDP (voir les annonces SAP) | |
KEY="...." # Clé à récupérer sur l'event youtube | |
SOURCE="" | |
n=0 | |
filter="" | |
for f in $FOLDER/*.mp4 | |
do | |
SOURCE="$SOURCE -i $f" | |
filter="$filter [$n:v:0] [$n:a:0]" | |
((n++)) | |
done | |
filter="$filter concat=n=$n:v=1:a=1 [v] [a]" | |
echo "ffmpeg $SOURCE -filter_complex '$filter'" | |
ffmpeg \ | |
$SOURCE -filter_complex "$filter" \ | |
-map "[v]" -map "[a]" -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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Found this through upwork.
To loop the input forever, try changing line 30 to
ffmpeg -stream_loop -1 \
From the manpage:
-stream_loop number (input) Set number of times input stream shall be looped. Loop 0 means no loop, loop -1 means infinite loop.
Changing the script so it supports looping mp3s with a still image or video would be pretty simple too if you need help.