4

I just used ffmpeg to convert a video file's container from .mkv to mp4 (just changed the container; didn't re-encode). The resulting mp4 vid plays well on QuickTime and am very pleased with the result. However, it wouldn't play in either Quick Look or iTunes.

In Quick Look as well as in iTunes, I am able to just move the play pointer up and down the slider manually but it just shows stills from the video. This is very frustrating as I was hoping to be able to add the video to my iTunes library! Any reason why this would happen?

Oh and if it helps, the codecs are H.264/AC3. Should that matter? A similar question elsewhere was closed with the accepted answer suggesting that the video be re-encoded. I really, really don't want to do down that road if there's ANY way to skirt that. I just want to change the container which is way faster than a full-blown re-encoding!

7
  • We can not help you not knowing what did you do, so please elaborate.
    – Ruskes
    Commented May 14, 2014 at 16:42
  • 1
    This questions suggests a slightly different set of flags for ffmpeg to gain iTunes support: apple.stackexchange.com/questions/123657/… Might this help? Commented May 14, 2014 at 19:40
  • 1
    @GrahamMiln Thanks a ton for referring me to the threat...the solution worked like charm! Sadly yes, it does involve re-encoding but I can live with that since it's just the audio part. The process didn't affect my file size nor did it take as long as a full-fledged re-encoding. Could you please resubmit your comment above as an answer so I could accept it and close the thread? Once again, thanks for your help!
    – TheLearner
    Commented May 14, 2014 at 21:04
  • 1
    @AmitSchandillia I have updated the answer to include the alternative encoding flags. Good to hear this approach fixed the iTunes playback problem. Commented May 15, 2014 at 5:25
  • 1
    For those following this thread, the follow up question to chillin's answer is here: apple.stackexchange.com/questions/130810/…
    – TheLearner
    Commented May 15, 2014 at 6:22

3 Answers 3

3

Conversion by QuickTime Player

QuickTime Player may be swiftly converting the file on opening using OS X's new AVFoundation. This would explain why it can play the file but not QuickLook or iTunes.

QuickTime conversion on opening

It is likely the movie is not in an ideal format for QuickTime Player on OS X 10.9, thus the conversion. With OS X 10.9, Apple dropped native support for many video formats and containers. Where possible legacy formats are converted on opening.

Supported MPEG-4

You may have a valid MPEG-4 container but the contents are not natively supported without conversion.

Have you confirmed the movie's encoding using the Finder's Get Info panel?

Get Info on a movie file

Re-Encoding

It is highly likely you will need to re-encode the movie, as suggested in MP4 movie does play in QuickTime but not in iTunes, if you want iTunes for playback.

This questions suggests a slightly different set of flags for ffmpeg to gain iTunes support, Convert a bunch of MKV files to MP4 to read them in iTunes:

./ffmpeg -i <filename>.mkv -c:v copy -c:a aac -b:a 384k -strict -2 <filename>.mp4

Alternatives to iTunes

If you wish to avoid re-encoding to gain iTunes support, consider looking for alternatives to iTunes. VLC and XMBC are both worthy alternatives; they both handle a wide range of video formats.

4
  • Yes, the codecs I mentioned are from the mp4 file's "Get Info" window in Finder...that's what's puzzling me. I always thought these codecs are natively supported by Mac.
    – TheLearner
    Commented May 14, 2014 at 17:31
  • I just noticed that the output generated by the above ffmpeg command has the audio in the MPEG-4 HE AAC format. Any way to force it to generate AAC instead of HE AAC? though the output plays just fine on my QT and iTunes, I would prefer it to be AAC so that it could play on my TV as well (my TV doesn't seem to recognize HE AAC but it does recognize AAC). Many thanks!
    – TheLearner
    Commented May 15, 2014 at 5:39
  • @AmitSchandillia please can you ask this as a separate question? This will attract clear answers and help others by keeping the different topics separate. Commented May 15, 2014 at 5:44
  • Thank you. For those following this, the follow up question is apple.stackexchange.com/questions/130807 Commented May 15, 2014 at 6:16
3
+50

AAC vs AC-3

In my experience, about half the time mkv files are encoded with AAC audio, and half the time with AC-3, and yes this matters. Quicktime will play the AAC and AC-3 formats, but iTunes and iOS media player will not. If the audio in the mkv file was AC-3 and you merely rewrapped it in an mp4 container, it will still have AC-3 encoding on the audio. What you need to do is transcode the audio to AAC when you run that ffmpeg command like this:

 ffmpeg -loglevel panic -i "original.mkv" -vcodec copy -c:a aac -strict -2 -ab 160k -ac 2 -ar 48k new.file.with.transcoded.audio.in.acc.mp4 

mp4 atom

ffmpeg is a wonderful and fast utility, but it does not care that you are an iTunes user. iTunes and iOS media player are very finicky about decoding video if the mp4 atom is in a place it doesn't like, namely, anywhere except near the beginning of the file. Quicktime also complains sometimes...

movie atom quicktime

...but is definitely better about playing unoptimized video. There's no telling where ffmpeg placed it, but likely its in the same place whomever encoded the original mkv left it.


Subler

Subler is a utility designed specifically for encoding subtitles, but it also will do exactly what you need it to do in this case. It will not only rewrap, and not transcode, the video to a friendly format, it will transcode the audio from AC-3 to AAC if necessary, and it will optimize the location of the mpeg-4 atom in the resulting file for iTunes friendly use. It uses a friendly drag and drop paradigm. Download Subler, unzip into your Applications folder and launch Subler. Type command-n to begin, and drag your mkv file into the window, and choose from the simple available options to result in a video mp4 or m4v file with identical video but transcoded audio. Make sure to mark the check box under Subler menu/Preferences to transcode the audio.


z264

z264 is a cool bash script designed to specifically solve the video issues that Mac and iTunes and iOS users face. Here's exactly what it does and how to make it work for you, if you're not too turned off by the command line.

check file for AVC encoding and flv, wmv, or mkv wrapper and rewrap in mp4 container otherwise, if not already am mp4, transcode to AVC mp4

z264 has several dependencies (mediainfo, rmtrash, ffmpeg, SublerCLI, and HandBrakeCLI)

  • copy and paste script text into a text file, uncomment binary install section (remove #), save anywhere
  • open Terminal.app

    chmod +x z264
    
  • run once

    ./z264
    
  • recomment binary section (replace #) after dependencies install into /usr/local/bin/

  • create ramdisk called 'Two' using command in ramdisk section

    diskutil quiet erasevolume HFS+ 'Two' `hdiutil attach -nomount ram://4194304`
    
  • double-check command definitions (locations of dependencies), and correct locations (to "/usr/local/bin/")

    change line 231 to read:  mediainfo="/usr/local/bin/mediainfo"
    change line 236 to read:  rmtrash="/usr/local/bin/rmtrash"
    change line 238 to read:  ffmpeg="/usr/local/bin/ffmpeg"
    change line 239 to read:  SublerCLI="/usr/local/bin/SublerCLI"
    change line 262 to read:  mediainfo="/usr/local/bin/mediainfo"
    change line 263 to read:  rmtrash="/usr/local/bin/rmtrash"
    change line 265 to read:  HandBrakeCLI="/usr/local/bin/HandBrakeCLI"
    
  • save as z264 in /usr/local/bin/

  • use Terminal to call z264 on single file, directory of files, or your entire drive

    z264 directory.full.of.mixed.video.filetypes/*
    

z264 will examine everything, but will only touch avi, flv, mpg, mpeg, wmv, vob, mkv and mp4 video files, copying video and audio streams and rewrapping if possible, transcoding just the audio if necessary, and transcoding only what video is necessary, and leave you with iTunes friendly, atom optimized mp4 files, leaving the originals in your Trash. It makes reasonably intelligent decisions for you about how to transcode files based on how you set its HandBrake variables (set at lines 312-333).

minor issues: does not yet count how many background processes it spawns, meaning if there are a lot of transcodes, it will take awhile for them to complete, but they will complete. You also need a lot of memory (8GB is ok). Snow Leopard users will need to install purge command from xcode developer tools.

2
  • 1
    I don't understand, what does your ffmpeg script (ffmpeg -loglevel panic -i "original.mkv" -vcodec copy -c:a aac -strict -2 -ab 160k -ac 2 -ar 48k new.file.with.transcoded.audio.in.acc.mp4) does differently than the one Graham Miln pointed to (./ffmpeg -i <filename>.mkv -c:v copy -c:a aac -b:a 384k -strict -2 <filename>.mp4)? To me the latter seems simpler and does what we intend it to, transcode the audio, leave the video intact, and re-encapsulate the whole thing in an mp4. What's the problem in that?
    – TheLearner
    Commented May 15, 2014 at 3:31
  • @AmitSchandillia : it is my mistake, I did not look at the link in his comment, only the answer below. The commands, in fact, are the same commands, neither is more complex than the other. I was referring to the answer provided, not the comment. The answer is not correct, IMO. The simple fact is iTunes doesn't decode 5.1 AC-3 audio, and that explains everything.
    – chillin
    Commented May 15, 2014 at 4:32
0

For newcomers who might encounter the same issue. It could be just a Finder issue.

Try holding option ⌥ and right click Finder to relaunch it.

I have solved this problem today doing the above steps. If that did not work out for you, it is probably a codec problem.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .