#!/bin/bash # Set the config file recordconf="webcam.json" #recordconf=$1 POSITIONAL=() while [[ $# -gt 0 ]] do key="$1" case $key in -h|-\?|--help) # show_help # Display a usage synopsis. echo help exit ;; -c) # Takes an option argument; ensure it has been specified. if [ "$2" ]; then recordconf=$2 shift # echo recordconfig $recordconf else die 'ERROR: "-c" requires a non-empty option argument.' fi ;; --configfile) # Takes an option argument; ensure it has been specified. if [ "$2" ]; then recordconf=$2 shift # echo recordconfig $recordconf else die 'ERROR: "--inputfile" requires a non-empty option argument.' fi ;; -c=?*|--configfile=?*) recordconf=${1#*=} # Delete everything up to "=" and assign the remainder. # echo recordconfg $recordconf ;; --configfile=) # Handle the case of an empty --file= die 'ERROR: "--inputfile" requires a non-empty option argument.' ;; -v|--verbose) verbose=$((verbose + 1)) # Each -v adds 1 to verbosity. ;; --) # End of all options. shift break ;; -?*) printf 'WARN: Unknown option (ignored): %s\n' "$1" >&2 ;; *) # Default case: No more options, so break out of the loop. break esac shift done # For debugging purposes #echo $recordconf #cat $recordconf # This is debugging getting the values from the config #jq '.input.video' $recordconf #jq '.input.audio' $recordconf #jq '.output.file' $recordconf inputvideo=`jq '.input.video' $recordconf | tr -d \"` inputaudio=`jq '.input.audio' $recordconf | tr -d \"` outputdir=`date +%Y-%m-%d`/`date +%H-%M-%S` outputfile=`jq '.output.file' $recordconf | tr -d \"` theoutput=${outputdir}/${outputfile} echo output $output echo outputfile $outputfile echo outputdir $outputdir echo theoutput $theoutput echo inputvideo $inputvideo echo inputaudio $inputaudio mkdir -p $outputdir #echo ffmpeg -f v4l2 -framerate 24 -video_size 864x480 -c:v h264 -i ${inputvideo} -f pulse -i ${inputaudio} -c:a aac ${theoutput} #ffmpeg -f v4l2 -framerate 24 -video_size 864x480 -i ${inputvideo} -f pulse -i ${inputaudio} -c:a aac ${theoutput} #echo ffmpeg -f pulse -i ${inputaudio} -c:a flac ${theoutput} ffmpeg -f pulse -i ${inputaudio} -c:a flac ${theoutput} 2> ${theoutput}.log