13

I'm trying to setup a simple mobile page for a client with a link to an .mp4 video file. Lke so:

<a href="My_Video_File.mp4" target="_blank">Watch MP4 Video</a>

And then I've obviously got my video file sourced properly and the .mp4 has the following characteristics:

Dimension: 480 * 272
Codecs: AAC, H.264, MPEG-4 SDSM, MPEG-4 ODSM
Channel Count: 2
Total Bitrate: 991
Size: 11.4MB

But, the problem is when I click on the link iPhone says "Movie cannot be played." and doesn't tell me why.

Any help?

Machavity
  • 30,841
  • 27
  • 92
  • 100
AJB
  • 7,389
  • 14
  • 57
  • 88
  • have you tried copying the file to your iphone via iTunes and seeing if it plays that way? – Alan Jul 19 '10 at 22:20
  • 1
    And..what happens when you try the HTML5 video tag: http://www.w3schools.com/html5/tag_video.asp – Alan Jul 19 '10 at 22:21

5 Answers5

22

The problem was partially to do with encoding but more to do with the dimensions.

I found out that if your .mp4 file is larger in dimension than 640*360 then the iPhone (iPad, iPod) won't even give the user the option to attempt to play it. They just get the X'd out play button icon.

Also, these devices only support .mp4's that are encoded with the baseline H.264 profile, or they can't be played.

Also, there's a bitrate limit of 1.5Mb for the iPhone, but it's suggested to keep the bitrate below 900kb.

If quality is less of a concern than size then you can use m4v's of larger dimensions but I believe the bitrate rules still apply.

Machavity
  • 30,841
  • 27
  • 92
  • 100
AJB
  • 7,389
  • 14
  • 57
  • 88
  • 6
    The bitrate limit for the iPhone is actually 2500kbps. The iPod video had the 1500kbps limit. The iPhone 4 and iPad (both generations) and newer can play up to 720p, Main Profile at nearly any bitrate. – Chealion Jun 22 '11 at 15:33
  • your answer contradicts your facts in the question therefore it is a bad answer –  May 22 '20 at 21:25
  • @francogrex You might want to check the dates on this question. It's literally a decade old now. Things have changed. – AJB May 30 '20 at 05:04
  • update 2022: a width of 1920 is accepted (at least). You can limit width without specifying height using an expression: `-vf "scale='min(600,iw)':-1"` -- see [Ask Ubuntu answer](https://askubuntu.com/a/772612/485233) – webaware Jun 08 '22 at 09:33
  • If it plays the mp4 video and not the audio, then the problem is that the iPhone doesn't support AAC - you need mp4a for the audio codec. Apple is known for not having backward compatibility with standard formats. – MC9000 Feb 26 '23 at 03:19
9

I encountered a similar issue and my guess was encoding. I had tried the "iPhone" preset with Adobe Premiere CS4 (Adobe Media Encoder) with no luck.

Running it through ffmpeg with the following did the trick:

ffmpeg -i INPUT -s 320x240 -r 30000/1001 -b 200k -bt 240k -vcodec libx264 -coder 0 -bf 0 -refs 1 -flags2 -wpred-dct8x8 -level 30 -maxrate 10M -bufsize 10M -acodec libfaac -ac 2 -ar 48000 -ab 192k OUTPUT.mp4

I found the above (and many other configurations) here: http://rodrigopolo.com/ffmpeg/cheats.html (I corrected a few typos in their "iPod-iPhone 640 width, without presset" [sic].)

Other searching around will probably yield more information about the encoding requirements (h.264 baseline 3.0) and size requirements for the movie to play on the iPhone.

The official Apple reference on the subject: http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/CreatingVideoforSafarioniPhone/CreatingVideoforSafarioniPhone.html

jeffreypriebe
  • 2,267
  • 25
  • 30
6

You need the h254 video to be progressive not lower. Choose the H.264 preset and change the video from lower to progressive.

Robert Randy
  • 61
  • 1
  • 1
3

this did it for me:

ffmpeg -an -i movie.mp4 -vcodec libx264 -codec:a libmp3lame -qscale:a 1 -pix_fmt yuv420p -profile:v baseline -level 3 output.mp4

I used mp3 codec here. This fixed my iPhone mp4 problem!

TylerH
  • 20,799
  • 66
  • 75
  • 101
1

I ran into a similar situation with video that I was generating. It would play fine on my local machine, or through a browser that supports .mp4; however when I tried viewing it on my iPhone it would invariably bring up the crossed-out play button. After reading ffmpeg docs I tried using the following and it worked beautifully on my iPhone as well as the other devices I've been able to try.

ffmpeg -i input.mkv -c:v libx264 -crf 28 -preset veryslow -tune fastdecode \
  -profile:v baseline -level 3.0 -movflags +faststart -c:a libfdk_aac -ac 2 \
  -ar 44100 -ab 64k -threads 0 -f mp4 output.mp4

The video that I'm dealing with is 1280x720 at 30fps, and the option that finally got it working was

-profile:v baseline -level 3.0
TylerH
  • 20,799
  • 66
  • 75
  • 101
Thismatters
  • 507
  • 4
  • 14