1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
#Configurations
VBR="1500k"
FPS="24"
BUFSIZE="3000k" #twice of bitrate
QUAL="ultrafast"
SIZE=1920x1080
WEBCAMSIZE=320x240
AUDIO_ENCODER="aac"
CURRENT_DIRECTORY=${PWD}
OUTPUT_EXTENSION=$1
echo "Recording to path: $1 "
TIMESTAMP=$(date "+%Y-%m-%d-%H-%M-%S")
YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2"
KEY="111-111-222"
AUDIO_FILE="/home/ravisagar/projects/ffmpeg-livestreamer/songs/allsongs.mp3"
# Use - pactl list sources, to check desktop audio source
DESKTOP_AUDIO="usb-0000:02:00.0-2"
#MIC=$(arecord -l | grep "Samson" | cut -d ':' -f 1 | cut -d ' ' -f 2)
#command starts here
ffmpeg \ #-video_size $SIZE \
-framerate $FPS -f x11grab -probesize 10M -thread_queue_size 8192 \
-f alsa -ac 2 -thread_queue_size 8192 -f pulse \
-ac 2 -thread_queue_size 8192 \
-filter_complex \
"[1:a]channelsplit=channel_layout=stereo:channels=FR, \
showfreqs=s=240x200:ascale=sqrt:cmode=combined:colors=#330000@0.5[right]; \
[1:a]channelsplit=channel_layout=stereo:channels=FL, \
showfreqs=s=240x200:ascale=sqrt:cmode=combined:colors=#330000@0.5,vflip[left]; \
[right][left]vstack[w]; \
[0:v][w]overlay=x=W-w-30-10:y=H-h-30+200-10[bg2]; \
[1:a]adelay=500|500,volume=2[a1]; \
[2:a]adelay=750|750[delayed]; \
[delayed][a1]amix=inputs=2[a]" \
-map "[v]" -map "[a]" \
-c:v libx264 -preset $QUAL -r $FPS -g $(($FPS *2)) -b:v $VBR -bufsize 3000k -maxrate $VBR \
-c:a $AUDIO_ENCODER -ar 44100 -b:a 128k -pix_fmt yuv420p \
~/$TIMESTAMP.$OUTPUT_EXTENSION