Code
avi2mp4.sh README
____ ____ ____ ____ ____ ____ ____ ____ ____ ____
||a |||v |||i |||2 |||m |||p |||4 |||. |||s |||h ||
||__|||__|||__|||__|||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|
-------------- Converts video files in batch mode to MP4 ---------------
Where to get it: http://forum.doom9.org/showthread.php?t=133598
Before putting this script to serious use encode a few samples first.
avi2mp4.sh is a batch converter. For each file a resolution gets calcu-
lated and a compressibility test determines the minimum bit rate needed
for the level of quality the user asks for.
If this isn't possible with the maximum bitrate the user allows, then
the output resolution gets downsized and a new compressibility test
starts.
Once a matching pair of bit rate and resolution has been found the input
file gets converted to H.264/MPEG-4 AVC or MPEG-4 video and AAC audio.
Finally these streams are wrapped into MP4.
Different kinds of subtitles can be added: SRT, SUB, 3GPP (TTXT) and
VobSub.
----------------------------- Requirements -----------------------------
- bc calculator
- faac or neroAacEnc (even Wine and a Windows binary will do)
- mplayer
- mencoder
- aacgain (at least v1.7.0; you can find a Debian package at RareWares:
http://www.rarewares.org/debian/packages/unstable/)
- MP4Box (part of gpac; v0.4.4 or later required)
------------------------- Compressibility Tests ------------------------
The compressibility test is new. Send me an e-mail with concerns or
ideas you might have.
--------------------------------- Hints --------------------------------
Global options need to be set in a file in your user's home directory,
namely ~/.avi2mp4.conf. An initial configuration file will be created.
MEncoder is used for the video conversion. There are multiple possibili-
ties to influence MEncoder's behaviour. The first is the configuration
variable MENCODER_OPTS. The content will be passed on to MEncoder.
A second possibility is to add MEncoder options on a per file basis.
Put the desired options in a file and name it like the input file name
extended by the suffix ".me" (e.g. movie.avi.me).
You can add video filters on a per file basis as well. Write them into
a file the same way as before, only this time use the suffix ".vf". Your
filters will be prepended to the existing chain (scale=x:y,harddup).
avi2mp4.sh searches the video filter chain for "crop" statements. If one
is found the calculation of the output resolution will be adjusted
accordingly.
You can indicate that a video is Progressive NTSC by creating a file
with the suffix ".p" (frame rate of the output video will be 23.976
frames per second for NTSC input).
--------------------------- MPEG containers ----------------------------
MPEG containers are problematic because they don't contain a proper
index like AVI containers do. This wasn't a problem until the
compressibility test was introduced. Since then avi2mp4.sh relies on
being able to "jump" through the input file. More often then not this
didn't work with MPEG containers.
Because of that input files are now skipped when an MPEG container is
detected. You'll have to re-multiplex the files to, e.g., AVI:
mencoder -ovc copy -oac copy input.mpg -o movie.avi
To rip a DVD simply dump the title you want to convert to your disk
first:
mencoder dvd:// -ovc copy -oac copy -o movie.avi
Finally:
avi2mp4.sh movie.avi
-------------------------------- iPods ---------------------------------
You want your videos to play on your iPod?
- obey bit rate and resolution limits
- no "B" frames allowed. Also, with H.264, the baseline profile level
must be set and CABAC disabled
XVID_ENCOPTS=max_bframes=0
X264_ENCOPTS=nocabac:level_idc=30:bframes=0
- AAC's Low Complexity (LC) profile must be used
Videos created with the initial configuration file should work on your
iPod out of the box. Same should be the case for your PSP.
Please also read about the configuration variables "MP4BOX_IPOD" and
"SBTL".
----------------------------- Configuration ----------------------------
...
Display More