diff options
Diffstat (limited to 'record')
| -rwxr-xr-x | record | 62 |
1 files changed, 62 insertions, 0 deletions
@@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +help() { + # display help + echo -e " +Usage: record [-h|-s|-m|-M|-n fileName] + +Script to record screen. By default, this script records the primary monitor +and both microphone and headset audio. +If no file name is specified it defaults to the current timestamp. + +Options: + -h Print this help message + -s Select the secondary monitor + -m Mute mic audio + -M Mute all audio + -n Enter file name for the video +" +} + +primaryRes=$(xrandr | awk -F'[ +]' '/primary/ { print $4 }') +primaryOffset=$(xrandr | awk -F'[ +]' '/primary/ { print $5 }') +secondaryRes=$(xrandr | grep " connected" | awk -F'[ +]' '! /primary/ { print $3 }') + +vidopts="-s $primaryRes -r 60 -probesize 32M -f x11grab -thread_queue_size 1024 -threads 0 -i :0+$primaryOffset" + +audopts="-f alsa -thread_queue_size 1024 -ac 2 -ar 44100 -i hw:CARD=Creative,DEV=2 -f alsa -thread_queue_size 1024 -ac 2 -ar 44100 -i hw:CARD=Microphone,DEV=0 -filter_complex [1:a]volume=0.1,amix=inputs=2,aresample=async=1" + +name=$(date "+%F-%H-%M-%S") + +while getopts ":hsmMn:" option; do + case $option in + h) # print help menu + help + exit + ;; + s) # select secondary screen + vidopts="-s $secondaryRes -r 60 -f x11grab -i :0" + ;; + m) # mute mic audio + audopts="-f alsa -thread_queue_size 1024 -ac 2 -ar 44100 -i hw:CARD=Creative,DEV=2" + ;; + M) # mute all audio + audopts="-an" + ;; + n) # enter a file name + name=$OPTARG + ;; + \?) # invalid option + echo "Error: Invalid option -$OPTARG" >&2 + exit 1 + ;; + :) # empty optarg + echo "Option -$OPTARG requires an argument" >&2 + exit + ;; + esac +done + +opts="-c:v libx265 -c:a libopus -b:a 128k -preset ultrafast" + +ffmpeg $vidopts $audopts $opts "$HOME/vids/${name}.mkv" |
