dotfiles/.bin/OLD/rec_scr_huff

47 lines
1.2 KiB
Plaintext
Raw Normal View History

2023-02-22 08:31:38 +01:00
#!/bin/sh
set -e
_vidfile="/home/sdk/rec-screen.mkv"
_outfile="/home/sdk/rec-encoded-$(date "+%Y%m%d_%H%M%S").mp4"
_res="1920x1080"
_fps="30"
_mon_dev="snd/mon"
_mic_dev="snd/default"
_mon_in="-thread_queue_size 16 -use_wallclock_as_timestamps 1 -f sndio -i ${_mon_dev}"
_mon_proc="-c:a pcm_s16le"
_mic_in="-thread_queue_size 16 -use_wallclock_as_timestamps 1 -f sndio -i ${_mic_dev}"
_mic_proc="-af pan='stereo|c0=FL|c1=FL' -c:a pcm_s16le"
_vid_in="-framerate ${_fps} -f x11grab -i :0.0"
_vid_proc="-qscale 0 -c:v huffyuv -framerate ${_fps}"
_ffmpeg_param="${_vid_in} ${_mic_in} ${_mon_in} -map 0:v ${_vid_proc} -map 1:a ${_mic_proc} -map 2:a ${_mon_proc}"
printf 'Press q to stop.\n'
set -x
ffmpeg -y -loglevel error -hide_banner ${_ffmpeg_param} "${_vidfile}"
set +x
# with audio?
[ "$1" == "-a" ] \
&& _audio_encode_param="-filter_complex amix=inputs=2,stereotools=phase=5,compand=attacks=0:points=-80/-115|-35.1/-80|-35/-35|20/20 -c:a aac -b:a 160k"
printf 'Encoding...\n'
set -x
ffmpeg -hide_banner -y \
-i "${_vidfile}" \
-c:v libx264 \
-crf 28 \
-s ${_res} \
-preset veryfast \
-movflags faststart \
-threads 12 \
${_audio_encode_param} \
"${_outfile}"
set +x
printf '%s\n' "${_outfile}"