Convert AVI to iPhone/iPod MP4

From Hurlster Wiki
Jump to navigation Jump to search
ffmpeg  -i "input.avi" "output.mp4"
ffmpeg -b bitrate -i "input.avi" "output.mp4"
ffmpeg -i input.avi -acodec libfaac -ab 128k -ar 44100 -vcodec mpeg4  -b 1250K output.m4v
ffmpeg [other-options] -b bitrate -i "input.avi" "output.mp4"
ffmpeg [other-options] -b bitrate -i "New Year Party.avi" "New Year Party.mp4"

Where,

  • -i input.avi : Input file name.
  • -b bitrate : Set the video bitrate in bit/s (default = 200 kb/s).
  • output.mp4 : Output file.

Example

Type the following command to convert japantrip_01.avi to japantrip_01.mp4 format:

$ ffmpeg -b 1250k -i japantrip_01.avi japantrip_01.mp4

iPad

The Ipad needs an H264 video up to 1024×728 (or 720p) at 30fps with AAC sound at 160Kbps, 48kHz.

there is several way to encode a video with ffmpeg, I decided to use the quality-based encoding (-crf option). (to avoid a 2-pass encoding & it gets better result than a constant bitrate)

for FFmpeg, it becomes:

   -r 30 => 30fps
   -vcodec libx264 => for the video codec.
   -acodec libfaac -ar 48000 -ab 128k -ac 2 => for the audio.
   -threads 0 => FFmpeg will manage the number of thread.
   -crf 21 for the quality level (15-25 15 is better)
   -vpre default => for the libx264 encoding preference, it can be “hq”, “default”, “fast”, “superfast”, “ultrafast”, etc
   -s xga => change the output resolution, it’s only useful if the original video is bigger than xga.
ffmpeg -i video.avi -r 30 -vcodec libx264 -acodec libfaac -threads 0 -ar 48000 -ab 128k -ac 2 -y -crf 21 -vpre default Ipad.mp4
ffmpeg -i Gone\ in\ 60\ Seconds.mp4 -r 30 -vcodec libx264 -acodec aac -threads 3 -ar 48000 \
-ab 128k -ac 2 -y -crf 21 -strict experimental Gone_in_60_seconds_ipad.mp4

if you want a faster encoding, you can change the vpre option: “-vpre fast” for example. but it will make bigger file & will increase the bitrate. But the quality will stay the same. (with superfast & ulrafast, the quality decrease)

To improve or decrease the quality, you can change the option crf. 18 will give a better result, 25 a less good result. If you increase quality, the encoding time will increase & the file size too.