#!/bin/bash ## Little helper to convert recordings. ## Requires (in $PATH as timediff): http://paste.maniactwister.de/show/2082 show_usage() { printf "Usage: %s \n" "$0" } if [ $# -lt 2 ]; then show_usage exit 1 fi if [[ $1 == "-h" || $1 == "--help" ]] then show_usage exit 0 fi start=$1 end=$2 length=$(timediff $start $end) shift 2 name=$@ echo "Start enconding now" # Mencoder is too dumb to handle start/endpos correctly, so we use ffmpeg for this. # Slice file ffmpeg -vcodec copy -map 0.0 -acodec copy -map 0.1 -ss $start -t $length -i "$name" "tmp-$name" # Convert file mencoder "tmp-$name" -o "${name%.*}.mkv" -oac mp3lame -ovc x264 # -ss $start -endpos $length # Remove tmp file rm "tmp-$name" printf "Finished - Output: %s" "${name%.*}.mkv\n"