diff --git a/multi-record/README.md b/multi-record/README.md new file mode 100644 index 0000000..22f8302 --- /dev/null +++ b/multi-record/README.md @@ -0,0 +1,3 @@ +# Multi Record Tools + +* multi-record.sh \ No newline at end of file diff --git a/multi-record/killffmpeg.sh b/multi-record/killffmpeg.sh new file mode 100755 index 0000000..9167389 --- /dev/null +++ b/multi-record/killffmpeg.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +killall ffmpeg diff --git a/multi-record/multi-record.sh b/multi-record/multi-record.sh new file mode 100755 index 0000000..ec46ea7 --- /dev/null +++ b/multi-record/multi-record.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +./record.sh -c "steinberg.json" & +./record.sh -c "webcam.json" & +./record.sh -c "capture.json" & +./video-record.sh -c "webcam-video.json" & +./video-record.sh -c "capture-video.json" & + + + + diff --git a/multi-record/record.sh b/multi-record/record.sh new file mode 100755 index 0000000..c7dd08e --- /dev/null +++ b/multi-record/record.sh @@ -0,0 +1,90 @@ +#!/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> /dev/null + + diff --git a/multi-record/video-record.sh b/multi-record/video-record.sh new file mode 100755 index 0000000..66416d1 --- /dev/null +++ b/multi-record/video-record.sh @@ -0,0 +1,90 @@ +#!/bin/bash + +# Set the config file +recordconf="webcam-video.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 -fflags +genpts -use_wallclock_as_timestamps 1 -r 15 -thread_queue_size 32 -i ${inputvideo} -f pulse -thread_queue_size 32 -i ${inputaudio} -use_wallclock_as_timestamps 1 -r 15 -c:v h264 -c:a aac ${theoutput} 2> /dev/null +#echo ffmpeg -f pulse -i ${inputaudio} -c:a flac ${theoutput} +#ffmpeg -f pulse -i ${inputaudio} -c:a flac ${theoutput} 2> /dev/null + + diff --git a/multi-record/videorender.sh b/multi-record/videorender.sh new file mode 100755 index 0000000..011606a --- /dev/null +++ b/multi-record/videorender.sh @@ -0,0 +1,2 @@ +#!/bin/bash +ffmpeg -y -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -i "${1}" -c:a copy -c:v hevc_nvenc "${2}"