dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles # fast
git clone https://src.adamsgaard.dk/dotfiles.git # slow
Log | Files | Refs | README | LICENSE Back to index

burn-audio-cd.sh (739B)


      1 #!/bin/sh
      2 set -e
      3 
      4 help() {
      5 	printf 'usage: %s file ..' "${0##*/}"
      6 	echo "converts each FILE to wav and burns as an audio cd"
      7 	echo "requires ffmpeg and cdio/cdrecord"
      8 }
      9 
     10 if [ $# -lt 1 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
     11 	help
     12 	exit 1
     13 fi
     14 
     15 # convert to wav
     16 i=1
     17 outdir="$(mktemp -d)"
     18 for f in "$@"; do
     19 	outwav="$(printf '%s/%04d_%s' "$outdir" "$i" "$(basename "${f%.*}.wav")")"
     20 
     21 	if [ -e "$outwav" ]; then
     22 		printf '%s exists, skipping...\n' "$outwav"
     23 	else
     24 		ffmpeg -i "$f" -c:a pcm_s16le -ac 2 -ar 44100 "$outwav"
     25 	fi
     26 
     27 	i=$(( i + 1 ))
     28 done
     29 
     30 # burn wav as audio cd
     31 if type cdio >/dev/null 2>&1; then
     32 	doas cdio tao -a "$outdir"/*.wav && cdio eject
     33 else
     34 	cdrecord -v -pad speed=1 -dao -swab "$outdir"/*.wav
     35 fi
     36 
     37 rm -rf "$outdir"