Upload files to "record"

main
Berkeley 2024-04-07 23:34:13 +00:00
parent e4a773aa61
commit 19c7058306
1 changed files with 167 additions and 0 deletions

167
record/record Normal file
View File

@ -0,0 +1,167 @@
#!/bin/sh
# dependencies= pulseaudio, ffmpeg
# Check README for more details. (https://github.com/whoisYoges/record-with-ffmpeg/blob/master/README.md)
########################
### 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 ###
#################