PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : avi2mp4.sh: Konvertiert Dateien nach MP4 (H264 o. XviD/AAC)



micmac
26.10.08, 10:30
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 ----------------------------
...

Newbie314
26.10.08, 11:37
Cool. Frage: warum AAC mit einem Nero Tool und nicht per Lame oder ähnlichem (.. was bereits installiert ist ...) ? Gibt es da Qualitätsunterschiede ?

micmac
26.10.08, 11:46
Cool. Frage: warum AAC mit einem Nero Tool und nicht per Lame oder ähnlichem (.. was bereits installiert ist ...) ? Gibt es da Qualitätsunterschiede ?

Hi!

Also man kann entweder faac, neroAacEnc oder Wine und neroAacEnc.exe (schneller als das native neroAacEnc) zum konvertieren nach AAC benutzen. Das sind auch alle Möglichkeiten, die mir unter Linux einfallen. faac ist open source, aber ich bin mir ziemlich sicher, dass der Nero-Kodierer besser ist. Lame kann keine AACs erstellen, "nur" MP3s. Bis jetzt hat sich noch niemand nach MP3-Unterstützung in avi2mp4.sh erkundigt und ich brauche sie persönlich nicht, deshalb gibt es sie auch noch nicht :)

Grüße

micmac
07.02.09, 16:59
1.1.12:
- added subtitle support (SRT, SUB and VobSub)
- added $TRACK_LANG so user can set a three digit language code.
It's not _that_ useful because you can not set it on a
per-file or even-per track basis. Why did I even add it in the
first place? :D
- call MP4Box from within the tmp directory do avoid another bug
(for some reason MP4Box added something like ".idx" to the
command line otherwise)
- some small fixes (comments, README)
- call MP4Box without "-isma" because it removes the subtitles
1.1.13:
- script now refuses to (try to) convert mpeg containers
- updated README

undefined
07.02.09, 20:01
So etwas kann man auch mit ffmpeg machen ;)


ffmpeg -i infile.avi \
-vcodec libx264 -vpre avi2mp4 -r 25 -b 1000k \
-acodec libfaac -ar 44100 -ab 64k -ac 2 -y outfile.mp4

Wer sich über die -vpre Option wundert das ist eine preset Einbindung aus den FFMPEG Examples.

micmac
09.02.09, 19:55
So etwas kann man auch mit ffmpeg machen ;)
...
Na dann waren die 679 Zeilen ja völlig umsonst :ugly:

undefined
09.02.09, 20:41
Nicht unbedingt - ich habe nur 66 Zeilen benötigt. (http://gitweb.hjcms.de/cgi-bin/index.cgi/ffpreset-scripts/commit/?id=3d17ed227314e43ea3bedc88a62a326911a7a980) ;)
Aber werfe auf jeden fall mal einen blick in die ffmpeg Quellen die presets Geschichte macht das ganze Interessanter.

micmac
28.03.09, 19:02
1.1.14:
- now 3GPP text subtitles (.ttxt) are recognized as well
- new configuration variable SBTL, see README
- pass TRACK_LANG & video fps along as a global MP4Box argument
- changed subtitle handling, now for text subtitles the 3GPP
header is adapted slightly for proper display (I tried to
follow the findings of this blog entry:
http://blog.jharding.org/2008/11/subtitles-on-appletv-and-iphone.html
Thanks for the ideas!)
- use "-ipod" argument directly when muxing
1.1.15:
- fix subtitle related mistake
- set vim modeline
- some cleanups (in README as well)

micmac
17.05.09, 09:32
1.1.16:
- fix quite a few return checks that caused avi2mp4.sh to not terminate
properly
- adjust ChangeLog's style :)