By Jacob Klint (jklint@juno.com)
Created for the
UC Irvine Paul Merage School of Business
1/2006
AutoMPEG4 does batch conversions of video files to the MPEG4 format, suitable for the iPod and other video devices. It uses the open-source programs avisynth, mencoder, ffmpeg, and mp4box. The advantage over executing these programs manually is twofold: you can setup a complete multi-pass transcode from start to finish, and the program can recurse through entire directory structures and convert files that match certain criteria.
I am using this program (along with XMLerator) to run an automated podcast. Our main streaming solution at the school is WMV-based, so I schedule AutoMPEG4 to reencode the video archives each night and then run XMLerator to update the podcasts to include the new files.
AutoMPEG4 is written in C# using Microsoft Visual Studio 2005 and the .NET 2.0 framework.
Download the latest version here: http://www.gsm.uci.edu/~dvdotnet/downloads/autompeg4.zip
For more information on podcasting, visit the Apple site at: http://www.apple.com/itunes/podcasts/techspecs.html
This program was designed and implemented entirely by Jacob Klint (me) for the UC Irvine Paul Merage School of Business. I am currently (as of 1/2006) an undergraduate majoring in Information and Computer Science at UC Irvine and will graduate in June 2006. I plan to work in the Southern California area once I graduate and am actively pursuing job opportunities.
AutoMPEG4 requires several open-source tools to function. If you do not already have them installed, you can download them at these locations:
AviSynth – http://www.avisynth.org. Install this program.
ffmpeg – download 3GP Convert from videohelp.com (http://www.videohelp.com/tools?tool=3GP_Converter), unzip the download file, and extract the files “ffmpeg.exe” , “avsredirect.dll”, “cygwin1.dll”, and “cygz.dll” from the “cores” folder. Place these two files in the same folder as AutoMPEG4.exe.
Mencoder – download the binaries from http://oss.netfarm.it/mplayer-win32.php and extract mencoder.exe into the same folder as AutoMPEG4.exe.
Mp4box – download the binaries from http://gpac.sourceforge.net/auth_mp4box.php and extract mp4box.exe into the same folder as AutoMPEG4.exe.
AutoMPEG4 is designed for PC's running Microsoft Windows XP and the .NET 2.0 runtime environment (freely available at http://www.microsoft.com/downloads/details.aspx?FamilyID=0856eacb-4362-4b0d-8edd-aab15c5e04f5&DisplayLang=en).
AutoMPEG4 Copyright (C) 2006 Jacob Klint
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
exluding commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
If you have any commercial interest in this product, please contact the author:
Jacob Klint jklint@juno.com
command-line based, so it's easy to schedule and then forget about
flexible – can match folders based on file extension and/or filename prefix
powerful – can recurse fully through an entire directory structure
compatible – produces standard MP4 compatible with the iPod and other video devices.
I have no definite plans to improve this project as it is more than sufficient for our purposes here at the school, but two major ideas come to mind:
implement a GUI. The MPEG engine is completely separate from the console interface, so creating a GUI is a simple matter of putting together a form that can gather parameters and pass them on.
At the DOS command line (cmd.exe), use this line to run the program: AutoMPEG4.exe “options.txt”. Alternatively, drag-and-drop a configuration file onto the AutoMPEG4.exe file. Finally, you can schedule it to run regularly using the Windows task scheduler (in the control panel).
All configuration is done via text files. A sample file named “options.txt” is included with the executable. With this arrangement, you can easily create separate profiles for different folders and switch among them just by executing AutoMPEG4 with the name of a different config file passed to it on the command line.
The options file format is as follows:
[GENERAL]
sourcedirectory=\\pvr\video
includesubdirectories=false
rename=false
destdirectory=Podcast
posttranscodeexe=C:\Documents and Settings\jk\Desktop\XMLerator\XMLerator\bin\Debug\xmlerator.exe
posttranscodeexeargs="c:\documents and settings\jk\desktop\options.txt"
[ENCODING]
videobitrate=200
audiobitrate=64
// for the ipod, the resolution must be such that the total number of pixels (resolutionX * resolutionY) is <= 230400.
resolutionX=512
resolutionY=384
[PREFIX]
transcodeme
[FILEEXT]
mpg
Any line starting with “//” is completely ignored. Quotation marks are not necessary anywhere, so don't insert them unless you mean for them to be there.
Each section is explained below.
sourcedirectory – the topmost folder to process
includesubfolders – if true, AutoMPEG4 recurses completely through all the subdirectories below the source directory; if false, only the source directory is processed.
rename – if true and a prefix is used to specify files, the prefix will be removed from the original source files following transcoding.
destdirectory – the subfolder in which to place the MPEG4 files
posttranscodeexe - an executable to run once all transcoding is complete
posttranscodeexeargs – the command-line arguments for posttranscodeexe
videobitrate – the bitrate for the video
audiobitrate – the bitrate for the audio
resolutionX – the width of the video in pixels
resolutionY - the height of the video in pixels
This is a list of prefixes, one of which each source file must match in order to be transcoded. Leave this section blank if you do not wish to use prefix-matching.
This is a list of file extensions, one of which each source file must match in order to be transcoded. Leave this section blank if you do not wish to use extension-matching.
Underneath the covers, AutoMPEG4 first creates an avisynth file based on the file template “avisynthtemplate.txt” and then runs each command in the file “autompeg4template.txt”, replacing all variables surrounded with %variablename% with their appropriate values.
The variables available are:
INPUT – the complete input file name.
OUTPUT – the complete output file name
VIDEOBITRATE – as specified in the options file
AUDIOBITRATE – as specified in the options file
RESOLUTION_X – the width of the video in pixels
RESOLUTION_Y – the height of the video in pixels
The format for “avstemplate.txt” is the standard Avisynth format.
The format for “autompeg4template.txt” is as follows: executablename.exe[EXEARGS]string of arguments for executable
You can rewrite these templates yourself to customize the encoding process as you like. For instance, there's no need to stick with the 2-pass/aac encoding I created as the default if you need something else. Just edit the templates to reflect the encoder executable, codec, and other options you desire. The variables named above will be replaced, and each command line will run. You can also run any other exe's you like!
last updated: 1/29/2006