I often have the problem of needing to convert a folder full of video files to a format compatible with my Freebox, without spending ages in front of my machine doing each video individually. This often happens when I have several takes from my mobile phone or camcorder as mp4 files. Here’s how I worked out how to do it. These instructions apply to Windows 7, and may also work elsewhere on Windows machines.
I have tailored these instructions for a generic encode that will work on Freebox (ADSL triple-play box in France) but since the resulting files stick to standards they should work on most set-top boxes and portable players, including phones and tablets except iPhone/iPad, which read mp4 natively anyway… The typical conversion required is from mp4 to mkv or avi; I prefer mkv for the Freebox as it has worked in more cases for me.
I’m assuming the video codec doesn’t need changing. Most video I encounter is h264 or XviD which are Freebox compatible. This makes converting much faster, because re-encoding video takes ages. I do force audio encoding though, because I’ve had problems with AAC audio tracks (which the Freebox v5 doesn’t like very much at all) or raw PCM and other audio formats that don’t play nice.
Be careful with some Android phone video as it can have dynamic framerates. See advanced notes on how to change codec or force a framerate on your video which will help keep audio and video in sync. If you need to edit after you’ve converted your takes, you’ll be better off with a constant framerate.
AviDemux – https://avidemux.sourceforge.net/ a capable video editor / converter. Open Source and free. This also works on Mac and Linux, and the simple batch file below is adaptable for bash shells which would cover Mac and Linux. Work it out for yourself.
1. The script file for AviDemux. This is a simple file used to provide instructions to AviDemux to save the mp4 video file you have as an mkv, and re-encode audio to Lame MP3 @ 128kbps. It provides a generic display width of 1280 pxiels but this may not be used if the source video is different (we’re not re-encoding video here).
#PY <- Needed to identify # #--automatically built-- adm = Avidemux() adm.videoCodec("Copy") adm.audioClearTracks() adm.setSourceTrackLanguage(0,"unknown") adm.audioAddTrack(0) adm.audioCodec(0, "Lame", "bitrate=128", "preset=0", "quality=2", "disableBitReservoir=False"); adm.audioSetDrc(0, 0) adm.audioSetShift(0, 0,0) adm.setContainer("MKV", "forceDisplayWidth=False", "displayWidth=1280")
2. The batch file, which will just search all mp4 files and loop through, calling AviDemux each time.
set avidemux="C:\Program Files\Avidemux 2.6 - 64bits\avidemux.exe" for %%f in (*.mp4) do \ %avidemux% --force-alt-h264 --load "%%f" --run fbx.py --save "%%f.avi" --quit
For convenience download a zip file with these files.
Putting it all together:
Set line 1 of the batch file (test.bat in the download) to point to the path where your avidemux.exe resides.
Copy both files into an empty folder.
Copy your .mp4 files to convert into that folder too.
Double-click test.bat and the script will take each mp4 file one-by-one and send it to AviDemux to encode/mux it for you. AviDemux will launch a window each time, but you should not need to interact with it at all. Once it has finished, you will have a bunch of .mkv files with your mp4 files.
You can do all sorts of encodings with this method. The batch file can be changed to look for avi, mkv or other video file extensions. Just change (*.mp4) to (*.avi) or whatever.
If you want to re-encode video, you can create a specific conversion file from AviDemux by loading a single video to convert, setting up your parameters, then using File > Project Script > Save As Project to create a scripting file. Then edit that file to remove specific lines (like the filename and segment lengths) but to keep the video and audio codec information, and reference that new file on line 3 of the batch file.