I'd like to get the hive mind's perspective on a script that I'm writing to go from Baseline or High 4.1 Profile MKV to M4V to play on iOS 4/5 devices (AppleTV 2, iPad 2, iPhone 4/4S, etc).

After doing some basic reverse engineering of YAMB and GOTSent (sorry richter03, I haven't taken a look at DDCGui yet), this is the basic pseudo code of what I'm doing:

  1. Get the MKV Info using mkvinfo.
  2. Parse it to get the following info:
    1. Track Number
    2. Track Type
    3. Default Duration (FPS)
    4. Language
    5. Sampling Frequency
    6. Channels
    7. Codec ID
  3. Extract the h264 video track using mkvextract
  4. Extract the audio tracks using mkvextract
  5. Process the audio tracks
    If there is AAC and neither AC3 or DTS:
    Pass it through

    If there is no AAC but there is AC3:
    Run through eac3to using
    Code:
    eac3.exe audio.ac3 audio.wav
    Run through neroaacenc using:
    Code:
    neroaacenc.exe -lc -q 0.35 -ignorelength -if audio.wav -of audio.aac
    [Previously, I used valdec using the GOTSent method:
    Code:
    valdec.exe audio.ac3 -wav audio.wav -spk:NUMBER_OF_CHANNELS -fmt:0 -drc -gain:8 -drc_power:8
    If there is no AAC but there is DTS:
    Run through eac3to using:
    Code:
    eac3.exe audio.dts audio.wav
    Run through neroaacenc using:
    Code:
    neroaacenc.exe -lc -q 0.35 -ignorelength -if audio.wav -of audio.aac
  6. Remux using mp4box to mp4:
    Code:
    mp4box -add video.h264:fps=FRAMES_PER_SECOND -add audio.aac -add audio.ac3 -add audio.dts out_filename -tmp C:\Temp\

Does anyone have any suggestions to making this better? I'm programming this in python with the intentions of releasing it's source here.