我无法在任何 iOS 设备上播放我的 mp4 视频。我在运行 iOS 6 的 iPhone 和运行 iOS 7 的 iPad 上进行测试。当我将视频上传到我的服务器并直接在设备上输入 URL 时,屏幕变黑,并出现一条警告,提示“操作无法完成”。当我尝试使用标签在网页上播放视频时,也会出现同样的问题<video>
。
该视频在 Android 和 Windows 上均可正常播放。您可以找到示例视频这里。这是我的 ffmpeg 设置。
ffmpeg -i uncompressed.avi -s 854x480 -c:v libx264 -pix_fmt yuv420p
-preset:v veryslow -profile:v baseline -crf 23
-c:a libfdk_aac -flags +qscale -global_quality 3 -afterburner 1
-ar 48000 -cutoff 19000
output.mp4
这是编码视频时 ffmpeg 的输出。
ffmpeg version N-55064-g3cd8aaa Copyright (c) 2000-2013 the FFmpeg developers
built on Jul 29 2013 12:59:12 with gcc 4.8.0 (GCC)
configuration: --arch=x86_64 --target-os=mingw32 --cross-prefix=/home/dominic/
GitHub/ffmpeg-windows-build-helpers/sandbox/mingw-w64-x86_64/bin/x86_64-w64-ming
w32- --pkg-config=pkg-config --enable-gpl --enable-libsoxr --enable-libx264 --en
able-avisynth --enable-libxvid --enable-libmp3lame --enable-version3 --enable-zl
ib --enable-librtmp --enable-libvorbis --enable-libtheora --enable-libspeex --en
able-libopenjpeg --enable-gnutls --enable-libgsm --enable-libfreetype --enable-f
ontconfig --enable-libass --enable-libutvideo --enable-libopus --disable-w32thre
ads --enable-frei0r --enable-filter=frei0r --enable-libvo-aacenc --enable-bzlib
--enable-libxavs --extra-cflags=-DPTW32_STATIC_LIB --enable-libopencore-amrnb --
enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-libschroedinger --enab
le-libbluray --enable-libvpx --enable-libilbc --enable-static --disable-shared -
-enable-nonfree --enable-libfdk-aac --enable-runtime-cpudetect
libavutil 52. 40.100 / 52. 40.100
libavcodec 55. 19.100 / 55. 19.100
libavformat 55. 12.102 / 55. 12.102
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 81.103 / 3. 81.103
libswscale 2. 4.100 / 2. 4.100
libswresample 0. 17.103 / 0. 17.103
libpostproc 52. 3.100 / 52. 3.100
Input #0, avi, from 'cure.avi':
Metadata:
date : 2013-10-12T21:16:56.00708-07:00
Duration: 00:00:30.07, start: 0.000000, bitrate: 88517 kb/s
Stream #0:0: Video: lagarith (LAGS / 0x5347414C), rgb24, 854x480, 23.98 tbr,
23.98 tbn, 23.98 tbc
Stream #0:1: Audio: pcm_s32le ([1][0][0][0] / 0x0001), 96000 Hz, stereo, s32
, 6144 kb/s
[libx264 @ 000000000209f620] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 @ 000000000209f620] profile Constrained Baseline, level 4.0
[libx264 @ 000000000209f620] 264 - core 133 r2339 585324f - H.264/MPEG-4 AVC cod
ec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=0 r
ef=16 deblock=1:0:0 analyse=0x1:0x131 me=umh subme=10 psy=1 psy_rd=1.00:0.00 mix
ed_ref=1 me_range=24 chroma_me=1 trellis=2 8x8dct=0 cqm=0 deadzone=21,11 fast_ps
kip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=1 sliced_threads=0 nr=0 d
ecimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 k
eyint=250 keyint_min=23 scenecut=40 intra_refresh=0 rc_lookahead=60 rc=crf mbtre
e=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[libfdk_aac @ 00000000020d8f80] Note, the VBR setting is unsupported and only wo
rks with some parameter combinations
Output #0, mp4, to 'cure-baseline.mp4':
Metadata:
date : 2013-10-12T21:16:56.00708-07:00
encoder : Lavf55.12.102
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 854x48
0, q=-1--1, 24k tbn, 23.98 tbc
Stream #0:1: Audio: aac (libfdk_aac) ([64][0][0][0] / 0x0040), 48000 Hz, ste
reo, s16
Stream mapping:
Stream #0:0 -> #0:0 (lagarith -> libx264)
Stream #0:1 -> #0:1 (pcm_s32le -> libfdk_aac)
video:4373kB audio:442kB subtitle:0 global headers:0kB muxing overhead 0.333461%
[libx264 @ 000000000209f620] frame I:16 Avg QP:22.72 size: 46151
[libx264 @ 000000000209f620] frame P:705 Avg QP:27.08 size: 5303
[libx264 @ 000000000209f620] mb I I16..4: 42.7% 0.0% 57.3%
[libx264 @ 000000000209f620] mb P I16..4: 1.9% 0.0% 1.6% P16..4: 32.1% 9.7
% 4.8% 0.6% 0.2% skip:48.9%
[libx264 @ 000000000209f620] coded y,uvDC,uvAC intra: 47.7% 59.1% 19.9% inter: 1
2.9% 9.2% 0.9%
[libx264 @ 000000000209f620] i16 v,h,dc,p: 31% 21% 7% 41%
[libx264 @ 000000000209f620] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 11% 13% 6% 11% 15%
13% 14% 10% 9%
[libx264 @ 000000000209f620] i8c dc,h,v,p: 48% 21% 18% 13%
[libx264 @ 000000000209f620] ref P L0: 74.5% 10.1% 6.1% 2.0% 1.6% 1.4% 1.2%
0.5% 0.4% 0.4% 0.4% 0.4% 0.3% 0.3% 0.3% 0.2%
[libx264 @ 000000000209f620] kb/s:1191.01
答案1
好吧,经过一段时间的思考,答案似乎是 H.264 级别。看起来 ffmpeg 默认为 4.0 级,这似乎不是支持的由 iOS 提供。
当我将级别设置为 3.1 时,ffmpeg 会提示有关 DPB 大小的错误。因此,我添加了一个-refs 11
标志,现在视频可以播放了。只要级别仍设置为 3.1 并且不超过该级别指定的 DPB 大小,我甚至可以让主配置文件正常工作。