-
-
Save ksandom/5f08463e7660b5c217015d82e61f3314 to your computer and use it in GitHub Desktop.
Stream video to youtube via ffmpeg
This file contains hidden or 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. | |
CONFIG_FILE=~/.streamToYoutube | |
if [ ! -f "$CONFIG_FILE" ]; then | |
echo "#!/bin/bash | |
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 | |
" > "$CONFIG_FILE" | |
echo "Créé $CONFIG_FILE . Vous devriez le modifier." | |
exit 1 | |
fi | |
. "$CONFIG_FILE" | |
# ffmpeg \ | |
# -i "$SOURCE" -deinterlace \ | |
# -vcodec libx264 -pix_fmt yuv420p -preset $QUAL -tune zerolatency -crf 27 -r $FPS -g $(($FPS * 2)) -b:v $VBR \ | |
# -acodec libmp3lame -ar 44100 -threads 8 -b:a 712000 -bufsize 512k \ | |
# -f flv "$YOUTUBE_URL/$KEY" | |
# -q:v 3 | |
ffmpeg -f pulse -itsoffset -1.5 -i alsa_input.usb-Blue_Microphones_Yeti_Stereo_Microphone_REV8-00.analog-stereo -f v4l2 -s 1280x720 -r 10 -i $SOURCE -vcodec libx264 -pix_fmt yuv420p -preset ultrafast -r $FPS -g 20 -b:v $VBR -codec:a libmp3lame -af 'volume=2' -ar 44100 -threads 8 -b:a 44100 -bufsize 128k -f flv "$YOUTUBE_URL/$KEY" -tune zerolatency -crf 20 | |
# ffmpeg -f pulse -i alsa_input.usb-Blue_Microphones_Yeti_Stereo_Microphone_REV8-00.analog-stereo -f x11grab -i :0.0+1280,720 -s 1280x720 -r 10 -vcodec libx264 -pix_fmt yuv420p -preset ultrafast -r $FPS -g 20 -b:v $VBR -codec:a libmp3lame -ar 44100 -threads 6 -b:a 44100 -bufsize 128k -f flv "$YOUTUBE_URL/$KEY" -tune zerolatency -crf 15 | |
# -ac 2 | |
# -bufsize 512k |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment