Does it need to be a script? Would HandBrake work instead?
If it does need to be a script, I've had better success with ffmpeg
than with mencoder
, although I haven't regularly converted mkv files to mp4.
EDIT
Your mencoder
command does not work for me; QuickTime cannot open the resulting mp4 file. Here's a lengthy article about converting an mkv file into an iTunes-compatible mp4/m4v file. Another article lists where to get some of those tools for your Mac.
The basic process is:
- Use
mkvinfo
to figure out framerate of source mkv file. - Use
mkvextract
to separate video and audio streams into.h264
and.ac3
files, respectively. - Use
hexedit
to change the first line of the resulting.h264
file. - Use
ffmpeg
to convert the.ac3
file to a.m4a
file. - Use
MP4Box
to add the.h264
and.m4a
files to a new.mp4
container with the framerate that you gathered in step 1.
EDIT AGAIN
There's a thread about converting mkv to mp4 for PS3 viewing, which leads to a post with a script. Haven't tried it myself but it seems to use mkvextract and ffmpeg so it may do pass-through. Uses Python.