Avidemux Forum

Avidemux => Stable branch (2.5) discussion => Topic started by: vinniel on June 13, 2012, 04:15:58 PM

Title: MP4 to MKV Script
Post by: vinniel on June 13, 2012, 04:15:58 PM
I think I'm slowly getting the hang of Avidemux scripts, but I need some help on the container part.  Has anyone written a script to convert all the files in a directory from MP4 to MKV?  Nothing fancy, here, just copy the video -- output as MKV. 

I can get it to work, manually, and Avidemux does some wonderful MKVs for the USB input on my DVD player, but I checked, and I have 147 mp4 files in one directory.  I'm not real anxious to do all those files manually.

Thanks!
Title: Re: MP4 to MKV Script
Post by: Jan Gruuthuse on June 13, 2012, 05:22:37 PM
Source: Command-line only batch processing (http://www.avidemux.org/admWiki/doku.php?id=tutorial:batch_processing)

Windows
set avidemux="C:\Program Files\Avidemux 2.5\avidemux2.exe"
set videocodec=Copy
set audiocodec=Copy
set container=Matroska
for %%f in (*.mp4) do %avidemux% --video-codec %videocodec% --audio-codec %audiocodec% --output-format %container% --force-alt-h264 --load "%%f" --save "%%f.mkv" --quit


Linux:
#!/bin/bash
VIDEOCODEC="Copy"
AUDIOCODEC="Copy"
CONTAINER="Matroska"
for FIL in `ls *mp4 | sort` ; do
  avidemux2 --video-codec $VIDEOCODEC --audio-codec $AUDIOCODEC --output-format $CONTAINER --force-alt-h264 --load "$FIL" --save ${FIL%.*}.mkv --quit
done
Title: Re: MP4 to MKV Script
Post by: vinniel on June 13, 2012, 06:16:41 PM
Thanks!  I'll give it a whirl.
Title: Re: MP4 to MKV Script
Post by: Jan Gruuthuse on June 14, 2012, 06:14:54 AM
Keep in mind this is not re-encoding. The settings in GUI are for Video: Copy and Audio: Copy. If you need re-encoding need to work with run your specific job saved in avidemux (--run anyjob.py).