简体   繁体   English

iPhone“无法播放”.mp4 H.264 视频文件

[英]iPhone "cannot play" .mp4 H.264 video file

I'm trying to setup a simple mobile page for a client with a link to an .mp4 video file.我正在尝试为客户端设置一个简单的移动页面,其中包含指向 .mp4 视频文件的链接。 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:然后我显然已经正确获取了我的视频文件,并且 .mp4 具有以下特征:

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."但是,问题是当我点击链接时 iPhone 显示“无法播放电影”。 and doesn't tell me why.并且没有告诉我为什么。

Any help?有什么帮助吗?

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.我发现如果您的 .mp4 文件的尺寸大于 640*360,那么 iPhone(iPad、iPod)甚至不会让用户尝试播放它。 They just get the X'd out play button icon.他们只是得到了 X'd out 播放按钮图标。

Also, these devices only support .mp4's that are encoded with the baseline H.264 profile, or they can't be played.此外,这些设备仅支持使用基线 H.264 配置文件编码的 .mp4,否则无法播放。

Also, there's a bitrate limit of 1.5Mb for the iPhone, but it's suggested to keep the bitrate below 900kb.此外,iPhone 的比特率限制为 1.5Mb,但建议将比特率保持在 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.如果质量不如大小那么重要,那么您可以使用更大尺寸的 m4v,但我相信比特率规则仍然适用。

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.我曾在 Adob​​e Premiere CS4(Adobe Media Encoder)中尝试过“iPhone”预设,但没有成功。

Running it through ffmpeg with the following did the trick:使用以下命令通过 ffmpeg 运行它可以解决问题:

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].)我在此处找到了上述(以及许多其他配置): http ://rodrigopolo.com/ffmpeg/cheats.html(我更正了“iPod-iPhone 640 宽度,无印刷机”[原文如此] 中的一些错别字。)

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.其他搜索可能会产生更多关于编码要求(h.264 基线 3.0)和电影在 iPhone 上播放的大小要求的信息。

The official Apple reference on the subject: http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/CreatingVideoforSafarioniPhone/CreatingVideoforSafarioniPhone.html关于该主题的官方 Apple 参考: http : //developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/CreatingVideoforSafarioniPhone/CreatingVideoforSafarioniPhone.html

You need the h254 video to be progressive not lower.您需要 h254 视频是渐进式的而不是更低的。 Choose the H.264 preset and change the video from lower to progressive.选择 H.264 预设并将视频从较低更改为渐进式。

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.我在这里使用了 mp3 编解码器。 This fixed my iPhone mp4 problem!这解决了我的 iPhone mp4 问题!

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;它可以在我的本地机器上正常播放,或者通过支持 .mp4 的浏览器播放; however when I tried viewing it on my iPhone it would invariably bring up the crossed-out play button.然而,当我尝试在我的 iPhone 上查看它时,它总是会弹出打叉的播放按钮。 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 文档后,我尝试使用以下方法,它在我的 iPhone 以及我尝试过的其他设备上运行良好。

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我正在处理的视频是 30fps 的 1280x720,最终让它工作的选项是

-profile:v baseline -level 3.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM