#!/bin/bash # script to convert an mkv to m4v if [ "$1" -a "$2" ]; then filename=`basename "$1" .mkv` fps=`mkvinfo "$filename".mkv|grep "Default duration"|head -n 1|cut -d'(' -f2|cut -c 1-6` #sfreq=`mkvinfo "$filename".mkv|grep "Sampling frequency"|head -n 1|cut -d':' -f2|cut -c 2-6` mkvextract tracks "$filename".mkv 1:video.h264 ffmpeg -i "$filename".mkv -vn -acodec pcm_s16le -ac 2 audio.wav normalize-audio audio.wav #faac -c $sfreq audio.wav neroAacEnc -br $2 -lc -if audio.wav -of audio.aac MP4Box -fps $fps -add video.h264 -add audio.aac "$filename".m4v if [ $? -eq 0 ]; then rm audio.aac audio.wav video.h264 echo "All Done!" fi else echo "Usage: mkv2m4v.sh {filename} {target audio bitrate (eg: 128000)}" fi