Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'd like to have a solution to batch convert video files to a format suitable for the AppleTV2, iPad2, iPhone4, while at the same time preserving as much quality as possible; I want a single output file that will play on both devices and also good for consumption by other Mac software (eg. Aperture, iMovie, iTunes).

Batch processing is a requirement since I'm gonna convert many many files from different sources (mainly lots of videos captured by compact digital cameras, cell phones, and so on).

I'm looking into ffmpeg and MEncoder (both installed via MacPorts), but I can't seem to find a suitable preset for libx264 even if everyone out there is talking about them.

A different approach involving different software would be ok too as long as I can script it somehow and run it on a whole directory full of files to be converted.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

Handbrake has presets for the iPhone, AppleTV 2 and 3, iPod and other devices.

These make use of a rather recent bundled version of libx264 – so it usually produces really good quality. When choosing settings, make sure you use the Constant Rate Factor instead of a fixed or average bitrate (or check that it's not over 2 Mbit/s; see later for more). It usually results in better average quality than just trying to squeeze the bitrate.

Handbrake doesn't allow you to perform "real" batch encoding by default. Handbrake has a queue which you can fill with input video one-by-one, but it's tedious. You can use HandBrakeBatch to do the job instead.


If you want to stick to FFmpeg, you can use the presets and level/profile settings supplied with the libx264 encoder to generate iPhone-compatible output video. The basic command you can use for iPhone 4s would be:

ffmpeg -i input.mp4 -c:v libx264 -crf 24 -c:a libfaac -b:a 192k out.mp4

Tune the value on -crf for quality. Lower means better, higher means worse quality. Sane values range from 19 to 25.

The iPhone 3GS and lower only support the Baseline profile (i.e. use -profile:v baseline) and Level 3.0 (i.e. -level 3.0). Don't forget to scale the video accordingly with -s:v 960x540 for example.

See this blog entry for more info on encoding for Apple devices, which would go far beyond what I can explain here.

share|improve this answer

While slhck has a pretty comprehensive answer, a simpler way is to use the tools Apple has included in the OS. Apple's Automator has an encode movie option. Setting this up (at least on Mac OS X 10.7 and later) is a pretty quick process:

  1. Set up an Automator action that is a folder action
  2. Select the folder
  3. Add encode media action
  4. Specify 720p setting and better quality (since you're not using Apple TV v.1) and optionally a path to save the converted movies
  5. Save the action and away you go

Screenshot

share|improve this answer
    
Interesting, I've never used that before due to the lack of specific options, but it seems like a pretty easy solution. –  slhck Aug 31 '12 at 6:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.