172 lines
5.0 KiB
Bash
172 lines
5.0 KiB
Bash
#!/bin/sh
|
|
|
|
# dependencies= pulseaudio, ffmpeg
|
|
# Credits to: (https://github.com/whoisYoges/record-with-ffmpeg/blob/master/README.md)
|
|
# I make some updates here just for my use...
|
|
# FPS="23" for better quality and resolution to 1920x1080
|
|
# for check your device list use this commnad:
|
|
# pactl list sources
|
|
# and change the values on the audio configuration; that's all!
|
|
########################
|
|
### Variables Starts ###
|
|
########################
|
|
|
|
videodir="$HOME/Videos/ffmpeg/"
|
|
audiodir="$HOME/Audio/ffmpeg/"
|
|
recordingresolution="1920x1080"
|
|
outputresolution="1920x1080"
|
|
fps="23"
|
|
crf="18"
|
|
|
|
monitoraudioinput="alsa_output.pci-0000_0b_00.6.analog-stereo.monitor"
|
|
microphoneaudioinput="nui_mic_denoised_out.monitor"
|
|
monitoraudiochannel="2"
|
|
microphoneaudiochannel="2"
|
|
monitoraudiofrequency="48000"
|
|
microphoneaudiofrequency="48000"
|
|
outputaudiofrequency="48000"
|
|
|
|
######################
|
|
### Variables Ends ###
|
|
######################
|
|
|
|
########################
|
|
### Functions Starts ###
|
|
########################
|
|
|
|
checkVideoDir(){
|
|
if [ ! -d "$videodir" ]; then
|
|
mkdir -p "$videodir"
|
|
fi
|
|
}
|
|
|
|
checkAudioDir(){
|
|
if [ ! -d "$audiodir" ]; then
|
|
mkdir -p "$audiodir"
|
|
fi
|
|
}
|
|
|
|
internalAudioOnly(){
|
|
ffmpeg \
|
|
-f pulse -ac "$monitoraudiochannel" -ar "$monitoraudiofrequency" -i "$monitoraudioinput" \
|
|
-acodec libmp3lame -ar "$outputaudiofrequency" -q:a 1 \
|
|
"$(date +ffmpeg-"%Y-%m-%d-%I-%M-%S-%p").wav"
|
|
}
|
|
|
|
microphoneOnly(){
|
|
ffmpeg \
|
|
-f pulse -ac "$microphoneaudiochannel" -ar "$microphoneaudiofrequency" -i "$microphoneaudioinput" \
|
|
-acodec libmp3lame -ar "$outputaudiofrequency" -q:a 1 \
|
|
"$(date +ffmpeg-"%Y-%m-%d-%I-%M-%S-%p").wav"
|
|
}
|
|
|
|
internalAudioAndMicrophone(){
|
|
ffmpeg \
|
|
-f pulse -ac "$monitoraudiochannel" -ar "$monitoraudiofrequency" -i "$monitoraudioinput" \
|
|
-f pulse -ac "$microphoneaudiochannel" -ar "$microphoneaudiofrequency" -i "$microphoneaudioinput" \
|
|
-filter_complex amix=inputs=2 \
|
|
-acodec libmp3lame -ar "$outputaudiofrequency" -q:a 1 \
|
|
"$(date +ffmpeg-"%Y-%m-%d-%I-%M-%S-%p").wav"
|
|
}
|
|
|
|
videoWithoutAudio(){
|
|
ffmpeg \
|
|
-f x11grab -r "$fps" -s "$recordingresolution" -i :0.0+0,0 \
|
|
-vcodec libx264 -preset veryfast -crf "$crf" \
|
|
-pix_fmt yuv420p \
|
|
-s "$outputresolution" "$(date +ffmpeg-"%Y-%m-%d-%I-%M-%S-%p").mkv"
|
|
}
|
|
|
|
videoWithInternalAudio(){
|
|
ffmpeg \
|
|
-f pulse -ac "$monitoraudiochannel" -ar "$monitoraudiofrequency" -i "$monitoraudioinput" \
|
|
-f x11grab -r "$fps" -s "$recordingresolution" -i :0.0+0,0 \
|
|
-vcodec libx264 -preset veryfast -crf "$crf" \
|
|
-acodec libmp3lame -ar "$outputaudiofrequency" -q:a 1 \
|
|
-pix_fmt yuv420p \
|
|
-s "$outputresolution" "$(date +ffmpeg-"%Y-%m-%d-%I-%M-%S-%p").mkv"
|
|
}
|
|
|
|
videoWithMicrophone(){
|
|
ffmpeg \
|
|
-f pulse -ac "$microphoneaudiochannel" -ar "$microphoneaudiofrequency" -i "$microphoneaudioinput" \
|
|
-f x11grab -r "$fps" -s "$recordingresolution" -i :0.0+0,0 \
|
|
-vcodec libx264 -preset veryfast -crf "$crf" \
|
|
-acodec libmp3lame -ar "$outputaudiofrequency" -q:a 1 \
|
|
-pix_fmt yuv420p \
|
|
-s "$outputresolution" "$(date +ffmpeg-"%Y-%m-%d-%I-%M-%S-%p").mkv"
|
|
}
|
|
|
|
videoWithMicrophoneAndInternalAudio(){
|
|
ffmpeg \
|
|
-f pulse -ac "$monitoraudiochannel" -ar "$monitoraudiofrequency" -i "$monitoraudioinput" \
|
|
-f pulse -ac "$microphoneaudiochannel" -ar "$microphoneaudiofrequency" -i "$microphoneaudioinput" \
|
|
-filter_complex amix=inputs=2 \
|
|
-f x11grab -r "$fps" -s "$recordingresolution" -i :0.0+0,0 \
|
|
-vcodec libx264 -preset veryfast -crf "$crf" \
|
|
-acodec libmp3lame -ar "$outputaudiofrequency" -q:a 1 \
|
|
-pix_fmt yuv420p \
|
|
-s "$outputresolution" "$(date +ffmpeg-"%Y-%m-%d-%I-%M-%S-%p").mkv"
|
|
}
|
|
|
|
######################
|
|
### Functions Ends ###
|
|
######################
|
|
|
|
###################
|
|
### Main Starts ###
|
|
###################
|
|
PS3="Choose your recording option [1-8]: "
|
|
options=("InternalAudioOnly" "MicrophoneOnly" "InternalAudioAndMic" "VideoWithoutAudio" "VideoWithInternalAudio" "VideoWithMic" "VideoWithBothMicAndInternalAudio" "Quit")
|
|
|
|
select one in "${options[@]}"; do
|
|
case $one in
|
|
InternalAudioOnly)
|
|
checkAudioDir
|
|
cd "$audiodir"
|
|
internalAudioOnly
|
|
;;
|
|
MicrophoneOnly)
|
|
checkAudioDir
|
|
cd "$audiodir"
|
|
microphoneOnly
|
|
;;
|
|
InternalAudioAndMic)
|
|
checkAudioDir
|
|
cd "$audiodir"
|
|
internalAudioAndMicrophone
|
|
;;
|
|
VideoWithoutAudio)
|
|
checkVideoDir
|
|
cd "$videodir"
|
|
videoWithoutAudio
|
|
;;
|
|
VideoWithInternalAudio)
|
|
checkVideoDir
|
|
cd "$videodir"
|
|
videoWithInternalAudio
|
|
;;
|
|
VideoWithMic)
|
|
checkVideoDir
|
|
cd "$videodir"
|
|
videoWithMicrophone
|
|
;;
|
|
VideoWithBothMicAndInternalAudio)
|
|
checkVideoDir
|
|
cd "$videodir"
|
|
videoWithMicrophoneAndInternalAudio
|
|
;;
|
|
Quit)
|
|
printf "Exitting...."
|
|
exit 0
|
|
;;
|
|
*)
|
|
printf "Invalid Choice."
|
|
;;
|
|
esac
|
|
done
|
|
|
|
#################
|
|
### Main Ends ###
|
|
#################
|