我有一些 H.264 编码的视频,可以在 Web 浏览器中正确呈现 HTML5,但在 iPad 上无法正确呈现。当我使用从互联网下载的 H.264 视频时,我的视频可以在 iPad 上正确呈现,因此这不是 HTML 问题。
这是有关我的视频的 ffmpeg 信息 -
我的原始 .mov 视频:
似乎流 1 编解码器帧速率与容器帧速率不同:6000.00 (6000/1) -> 30.00 (30/1)
从“a_video.mp4”输入#0、mov、mp4、m4a、3gp、3g2、mj2:
元数据:
主要品牌:qt
次要版本:537199360
兼容品牌:qt
持续时间:00:00:42.74,开始:0.000000,比特率:220 kb/s
Stream #0.0(eng):音频:aac、44100 Hz、立体声、s16、94 kb/s
流#0.1(eng):视频:h264、yuv420p、762x464、122 kb/s、30 fps、30 tbr、3k tbn、6k tbc
之后使用 Handbrake 将我的 .mov 转换为 mp4,但无法在 iPad 上渲染:
似乎流 0 编解码器帧速率与容器帧速率不同:180000.00 (180000/1) -> 29.97 (30000/1001)
输入 #0、mov、mp4、m4a、3gp、3g2、mj2,来自“a_video.m4v”:
元数据:
<前><代码>主要品牌:mp42
次要版本:0
兼容品牌:mp42isomavc1
编码器:HandBrake 0.9.5 2011010300
持续时间:00:00:42.77,开始:0.000000,比特率:169 kb/s
流#0.0(und):视频:h264、yuv420p、752x464 [PAR 381:376 DAR 381:232]、35 kb/s、PAR 145161:141376 DAR 145161:87232、29.97 fps、29.97 tbr、 90,000 TB,180,000 TB
流 #0.1(eng):音频:aac、44100 Hz、立体声、s16、128 kb/s
这是我在网上找到的一个 .mp4,它可以在 iPad 上渲染:
似乎流 1 编解码器帧速率与容器帧速率不同:180000.00 (180000/1) -> 25.00 (25/1)
从“a_video_3_emu.mp4”输入#0、mov、mp4、m4a、3gp、3g2、mj2:
元数据:
主要品牌:M4VP
次要版本:1
兼容品牌:M4VPM4A mp42isom
编码器:CoreMediaAuthoring 677、CoreMedia 420.17、i386
持续时间:00:01:38.01,开始:0.000000,比特率:1023 kb/s
流 #0.0(und):音频:aac、32000 Hz、单声道、s16、97 kb/s
流 #0.1(和):视频:h264、yuv420p、480x360 [PAR 1:1 DAR 4:3]、914 kb/s、25 fps、25 tbr、90k tbn、180k tbc
有谁发现我的方式有问题吗我的视频被编码了吗?
编辑
起初我的理论是 iPad 对不同的容器格式很敏感;但事实似乎并非如此。我拍摄了一段在 iPad 上正确渲染的视频并将其转换为 .mov,并且它仍然在 iPad 上正常播放。所以iPad处理底层H.264码流的方式肯定有问题。
I have some H.264-encoded videos which render in HTML5 correctly in the web browser, but do not render correctly on the iPad. When I use a H.264 video I downloaded off the internet, my video renders correctly on the iPad, so it is not an HTML problem.
Here is the ffmpeg info about my videos --
My original .mov video:
Seems stream 1 codec frame rate differs from container frame rate: 6000.00 (6000/1) -> 30.00 (30/1)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'a_video.mp4':
Metadata:
major_brand : qt
minor_version : 537199360
compatible_brands: qt
Duration: 00:00:42.74, start: 0.000000, bitrate: 220 kb/s
Stream #0.0(eng): Audio: aac, 44100 Hz, stereo, s16, 94 kb/s
Stream #0.1(eng): Video: h264, yuv420p, 762x464, 122 kb/s, 30 fps, 30 tbr, 3k tbn, 6k tbc
After using Handbrake to convert my .mov to a mp4, yet doesn't render on the iPad:
Seems stream 0 codec frame rate differs from container frame rate: 180000.00 (180000/1) -> 29.97 (30000/1001)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'a_video.m4v':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42isomavc1
encoder: HandBrake 0.9.5 2011010300
Duration: 00:00:42.77, start: 0.000000, bitrate: 169 kb/s
Stream #0.0(und): Video: h264, yuv420p, 752x464 [PAR 381:376 DAR 381:232], 35 kb/s, PAR 145161:141376 DAR 145161:87232, 29.97 fps, 29.97 tbr, 90k tbn, 180k tbc
Stream #0.1(eng): Audio: aac, 44100 Hz, stereo, s16, 128 kb/s
Here is a .mp4 I found online which does render on the iPad:
Seems stream 1 codec frame rate differs from container frame rate: 180000.00 (180000/1) -> 25.00 (25/1)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'a_video_3_emu.mp4':
Metadata:
major_brand : M4VP
minor_version : 1
compatible_brands: M4VPM4A mp42isom
encoder : CoreMediaAuthoring 677, CoreMedia 420.17, i386
Duration: 00:01:38.01, start: 0.000000, bitrate: 1023 kb/s
Stream #0.0(und): Audio: aac, 32000 Hz, mono, s16, 97 kb/s
Stream #0.1(und): Video: h264, yuv420p, 480x360 [PAR 1:1 DAR 4:3], 914 kb/s, 25 fps, 25 tbr, 90k tbn, 180k tbc
Does anyone see something wrong with the way I am encoded my videos?
Edit
At first my theory was that the iPad was sensitive to different container formats; but that appears not to be the case. I took a video which does render correctly on the iPad and converted it to a .mov, and it still played correctly on the iPad. So there must be a problem with how the iPad deals with the underlying H.264 stream.
发布评论
评论(3)
如果您有 H.264 视频流 - 无论容器如何(mov、m4v、mp4) - 并且您的 HTML5 视频在 Web 浏览器中呈现,但不在 iPad 上呈现,则有两种可能的修复方法
:解决方案是将H.264视频流转换为mpeg4。
ffmpeg -i video_h264_not_working.mov -acodec copy -vcodec mpeg4 video_mpeg.mov
(或者,您可以在 Handbrake 中选择 MPEG4 而不是 H.264。)
第二种解决方案是重新处理 H.264具有以下参数的视频:
ffmpeg -i video_h264_not_working.mov -vcodec libx264 -r 25 -b 516k -bt 516k -crf 22 -vpre normal video_h264.mov
第二个解决方案来自: http://houseoflaudanum.com/navigate/howtos/html5-video-no-webm/
我猜在前一种情况下,mpeg4编解码器在iPad上更轻松;在后一种情况下,iPad 不喜欢原始 H.264 编码中的某些流参数,因此需要进行“清理”。
要确定您的视频流实际上是什么,只需执行 ffmpeg -i myvideo.mov 即可。
If you have a H.264 video stream -- regardless of the container (mov, m4v, mp4) -- and your HTML5 video renders in a web browser but doesn't render on the iPad, there are two possible fixes:
The first solution is to convert the H.264 video stream to mpeg4.
ffmpeg -i video_h264_not_working.mov -acodec copy -vcodec mpeg4 video_mpeg.mov
(Alternatively, you can select MPEG4 instead of H.264 in Handbrake.)
The second solution is to re-process the H.264 video with the following parameters:
ffmpeg -i video_h264_not_working.mov -vcodec libx264 -r 25 -b 516k -bt 516k -crf 22 -vpre normal video_h264.mov
The second solution came from: http://houseoflaudanum.com/navigate/howtos/html5-video-no-webm/
I'm guessing in the former case, the mpeg4 codec is more relaxed on the iPad; and in the latter case, the iPad didn't like some of the stream parameters from the original H.264 encoding, so a "cleaning" was necessary.
To determine what your video stream actually is, just do ffmpeg -i myvideo.mov.
我使用免费的 Miro Video Converter 对 HTML5 视频进行编码和转码取得了巨大成功(OS X、Windows),如深入了解 HTML5 的 Web 视频部分中的建议通过马克朝圣者。
Miro Video Converter 几乎可以将任何视频文件转换为 MP4、Theora 或 MP3(仅限音频)。它具有预设功能,可以将视频转换为适合流行手机、iPod 和其他媒体播放器的正确尺寸和格式。只需转换您的视频并将其复制到您的设备即可。
这是一种超级简单的方法,可以将几乎所有视频转换为 MP4、WebM (vp8)、Ogg Theora 或 Android、iPhone 等。您也会因为它 100% 免费且开源而感到高兴。
另一个名副其实的视频转换实用程序是 Video Monkey,这是一款专门为苹果。它是在伟大的工具 Visual Hub 消亡后创建的。 Video Monkey 大量借鉴了 Visual Hub 视频转换工具,无论是概念上还是从发布到 SourceForge 的 TranscoderRedux 原始代码转储中。
I've had great success encoding and transcoding HTML5 video using the free Miro Video Converter (OS X, Windows) as recommended in the Video on the Web section of Dive Into HTML5 by Mark Pilgrim.
Miro Video Converter can convert virtually any video file to MP4, Theora, or MP3 (the audio only). It has presets that will convert video to the correct sizes and formats for popular phones, iPods, and other media players. Just convert your video and copy it to your device.
It's a super simple way to convert almost any video to MP4, WebM (vp8), Ogg Theora, or for Android, iPhone, and more. You'll feel good that it's 100% Free and open-source, too.
An another veritable video conversion utility is Video Monkey, a free video encoding application exclusively for Mac. It was created after the demise of the great tool Visual Hub. Video Monkey borrows heavily from the Visual Hub video conversion tool, both conceptually and from the original code dump posted to SourceForge as TranscoderRedux.
sudo port install ffmpeg
并尝试这个秘密武器:调整原始视频的宽度和高度,并根据需要设置比特率。将原始视频作为参数传递给脚本。适用于几乎任何源格式。您需要 macports 作为 port 命令。
sudo port install ffmpeg
and try this secret sauce:Adjust width and height to the original video and set the bitrate as you see fit. Pass the original video as parameter to the script. Works with almost any source format. You need macports for the port command.