How can I convert a video to h264, using pass-through if available?

3

2

On my Windows 7 computer, I have several videos that need converting to an iOS-friendly format. I'd like to do this as efficiently as possible.

I have several kinds of videos:

  • MKVs containing (h|x)264 video and mp3 or AAC2ch.
  • AVI files containing any arbitrary video or audio stream.

I want to convert them to MP4s with h264 video with AAC2ch audio. On the Mac, I use MP4Tools and it does a great job. I can't find anything similar on Windows.

Is there an ffmpeg command, or an application that I can use that will simply pass-through the video when it's in the correct format? All of the Windows conversion software I have used just re-encodes the video, which adds a lot time, and reduces quality.

Redandwhite

Posted 2012-11-30T15:48:08.240

Reputation: 3 196

Answers

4

If the video and audio is already encoded properly, use the following FFmpeg command:

ffmpeg -i input.mkv -c copy output.mp4

This will copy the bitstreams without encoding.

To convert AVI files you usually want to re-encode them, since they will often contain MPEG-4 visual video and MP3 audio instead of the required (or recommended) h.264 / AAC.

slhck

Posted 2012-11-30T15:48:08.240

Reputation: 182 472

Is there a one-size-fits-all command that will re-encode when necessary? – Redandwhite – 2012-11-30T16:00:34.710

@Redandwhite Not really, because there are some peculiarities as to how the h.264 (and audio, I guess) codec(s) need to be created, e.g. with a certain profile, without B-pictures, and you'd need to check these before attempting to re-encode. You could probably set up a batch script that parses MediaInfo output and re-encodes if necessary though.

– slhck – 2012-11-30T16:15:15.823

1if your offering a complete solution, why not just use a ffmpeg based video player on the iphone devices, so much easier than conversion and better on server bandwidth – Michelle Cannon – 2012-12-06T21:35:03.710