Video (.mp4) playing in QuickTime but not in Finder Quick Look or iTunes
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!
Solution 1:
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.
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?
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.
Solution 2:
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...
...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.