iPhone "cannot play" .mp4 H.264 video file
Asked Answered
S

5

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?

Sprite answered 19/7, 2010 at 22:16 Comment(2)
have you tried copying the file to your iphone via iTunes and seeing if it plays that way?Ernest
And..what happens when you try the HTML5 video tag: w3schools.com/html5/tag_video.aspErnest
S
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.

Sprite answered 30/1, 2011 at 7:28 Comment(5)
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.Krute
your answer contradicts your facts in the question therefore it is a bad answerBair
@francogrex You might want to check the dates on this question. It's literally a decade old now. Things have changed.Sprite
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 answerColumelliform
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.Foliated
P
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

Phosphorite answered 11/9, 2010 at 22:16 Comment(0)
P
6

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

Poeticize answered 11/10, 2012 at 19:2 Comment(0)
B
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!

Brumbaugh answered 10/11, 2017 at 20:51 Comment(0)
P
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
Patrilocal answered 24/8, 2014 at 20:43 Comment(1)
It does not work for me, do you have any update for newer versions of FFMPEG?Cesaro

© 2022 - 2024 — McMap. All rights reserved.