Skip to content

Instantly share code, notes, and snippets.

@daviesgeek
Created September 21, 2019 19:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daviesgeek/af40d02bfe383d1b812c0a994a5096b8 to your computer and use it in GitHub Desktop.
Save daviesgeek/af40d02bfe383d1b812c0a994a5096b8 to your computer and use it in GitHub Desktop.

split-polywave.sh

Use case

I have a RØDECaster Pro, which records a multitrack file in the polyWAV format. It's kind of a pain to work with in editors, so I wrote this simple little ffmpeg script to split out the tracks easily.

Known issue

Probably needs to check to make ffmpeg is installed Doesn't retain chapter markers from the original file

#!/bin/bash
if [ "$1" == 'help' ] || [ "$1" == '--help' ] || [ "$1" == '-help' ] || [ "$1" == '' ]; then
echo 'Usage: split-polywav.sh [CHANNEL] [OUTPUT_FILENAME] [...FILES]'
exit 0
fi
channel=$1
output_filename=$2
files=(${@:3})
declare -a output_files
for i in ${files[@]}; do
echo "Processing $i..."
output_files+=($output_filename-$channel-$i)
ffmpeg -i $i -map_channel $channel $output_filename-$channel-$i
echo "file '$output_filename-$channel-$i'" >> split-files.txt
done
extension="${files[0]##*.}"
ffmpeg -f concat -i split-files.txt -c copy $output_filename.$extension
echo ${output_files[@]}
function finish {
rm split-files.txt
for i in ${output_files[@]}; do rm $i; done
}
trap finish EXIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment