46 lines
1 KiB
Bash
Executable file
46 lines
1 KiB
Bash
Executable file
#!/bin/bash
|
|
set -e
|
|
|
|
# Arg parser
|
|
while [ ! $# == 0 ]; do
|
|
case "$1" in
|
|
-o | --output) shift; OUTPUT=$1;;
|
|
*)
|
|
if [[ -f $1 ]]; then
|
|
INPUT=$1
|
|
else
|
|
echo "Invalid argument \"$1\""
|
|
exit 1
|
|
fi
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
# If no input is specified, exit
|
|
[[ ! -f $INPUT ]] && echo "No input file specified!" && exit 1
|
|
|
|
# If no output is specified, plop it into the same folder as the source and rename to *.avi
|
|
[[ ! $OUTPUT ]] && OUTPUT=$(echo "$INPUT" | sed 's/\(.*\)\..*/\1/').avi
|
|
|
|
#################
|
|
|
|
# Make tempdir
|
|
TMPDIR="/tmp/$(echo "$INPUT" | sed 's/\(.*\)\..*/\1/')-$RANDOM"
|
|
mkdir "$TMPDIR"
|
|
|
|
# Extract camrec file
|
|
7z e "$INPUT" -o"$TMPDIR"
|
|
|
|
# Ready up ffmpeg jank for merging audio (I hope to god there is only one video stream)
|
|
AUDIO=
|
|
NUM=0
|
|
for i in "$TMPDIR/*.wav"; do
|
|
AUDIO+="-i $i -map $NUM "
|
|
NUM=$(( $NUM + 1 )) # Fuck you Bash
|
|
done
|
|
|
|
# Convert contents to AVI
|
|
ffmpeg -i "$TMPDIR/Screen_Stream.avi" $AUDIO -map $NUM -c:v copy -c:a copy $OUTPUT
|
|
|
|
rm -r "$TMPDIR"
|