[x264-devel] Trouble with ffmpeg+x264 producing H264 stream that cannot be played on iPhones

Mo DeJong mo at modejong.com
Wed Jan 2 07:24:50 CET 2013


Hi all

First off, thanks for all the great work on x264. My testing has shown that for short videos (around 5 seconds) x264 is able to emit good quality versions at around 100 Kb while Quicktime would require around 300 Kb. That is amazing. I am looking at a method to include videos in an iPhone app and the final download size of the app is important to keep as small as possible, and x264 would work great, except.

While the ffmpeg+x264 produced .mov or .m4v files play back in Quicktime and in the iOS simulator, I have found that they do not play on actual iOS devices. I tested this one an older iPod Touch 3rd gen with iOS 4, an iPhone 4 CDMA with iOS 5.0, and and iPhone 4S with iOS 6.0 on it. I tested with my own app and I also used the "MoviePlayer_iPhone" app provided by Apple, all the phones I have produced the same error when attempting to read the H264 encoded data in the .mov file:

error = "Error Domain=MediaPlayerErrorDomain Code=-11800 \"The operation could not be completed\" UserInfo=0x187a00 {NSLocalizedDescription=The operation could not be completed}";

The error description really is of little value (yes I looked on stack overflow), it is not a problem in the app. I can swap out any other .mov with H264 encoding and it works fine. What does not work is when the app is run on the phone with a video produced by ffmpeg+x264.

My command line when creating the video was the following:

ffmpeg -y -i ExplosionBW.mov -c:v libx264 -pix_fmt yuv420p -preset:v veryslow -profile:v baseline -crf 23 Explosion.mov

I used ffmpeg-1.0.1.tar.bz2, an up to date last_x264.tar.bz2 as of today, and yasm-1.2.0.tar.gz when I created the binary.

The input was a .mov that uses the Animation codec for lossless video. The output Explosion.mov (I also tried .m4v) works great on MacOSX, but something is going wrong in the hardware on the iOS device when the video data should be decompressed. I know the .mov file is being read because it is possible to query the length of the movie and the framerate. It is only when actually playing the movie that things go badly.

Could I possibly be using the wrong command line arguments to encode for iOS baseline? I was under the impression that "-profile:v baseline" would take care of all the flags needed to produce a video that could play on iOS hardware.

thanks
Mo


More information about the x264-devel mailing list