Skip to content

Instantly share code, notes, and snippets.

@Cyxo
Forked from olasd/stream_to_youtube.sh
Last active April 30, 2024 16:46
Show Gist options
  • Save Cyxo/e4192f58e738446f3491d839eaa50ed7 to your computer and use it in GitHub Desktop.
Save Cyxo/e4192f58e738446f3491d839eaa50ed7 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
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"
@lucario1001
Copy link

@xcko can you help me do looping ogg files with a gif/video

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