This is a Bash script that uses FFmpeg to stream a video file and an audio file to YouTube Live.
#! /bin/bash
VBR="1500k"
FPS="24"
QUAL="superfast"
YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2"
KEY="bxts-x2xm-rjr6-ux74-2xys"
VIDEO_SOURCE="/home/ubuntu/evolux.mp4"
AUDIO_SOURCE="http://188.121.1.261:8000/radio.mp3"
ffmpeg \
-re -f lavfi -i "movie=filename=$VIDEO_SOURCE:loop=0, setpts=N/(FRAME_RATE*TB)" \
-thread_queue_size 512 -i "$AUDIO_SOURCE" \
-map 0:v:0 -map 1:a:0 \
-map_metadata:g 1:g \
-vcodec libx264 -pix_fmt yuv420p -preset $QUAL -r $FPS -g $(($FPS * 2)) -b:v $VBR \
-acodec libmp3lame -ar 44100 -threads 6 -qscale:v 3 -b:a 320000 -bufsize 512k \
-f flv "$YOUTUBE_URL/$KEY"
To adjust the stream bit rate, you can modify the ‘VBR‘ variable, which is currently set to “1500k“. This sets the video bit rate to 1500 kbps. You can change this value to your desired bit rate.
For example, to set the bit rate to 2000 kbps, you can change the ‘VBR‘ variable to:
VBR="2000k"
Similarly, you can adjust the audio bit rate by changing the value of the ‘-b:a‘ parameter, which is currently set to “320000“. This sets the audio bit rate to 320 kbps. You can change this value to your desired bit rate.
For example, to set the audio bit rate to 128 kbps, you can change the ‘-b:a’ parameter to:
-b:a 128000
Once you have made the necessary changes, save the script and run it again to start the streaming with the adjusted bit rates.