ffmpeg 转码的 H.264 视频无法在 Chrome 中播放

ffmpeg 转码的 H.264 视频无法在 Chrome 中播放

我正在尝试使用 ffmpeg 转码视频。以下是示例命令。

ffmpeg.exe -i 534.mp4 -vcodec libx264  -level 3.1 -b:v 396k -ar 48000 -ab 32k -s 100x100  -force_key_frames expr:gte(t,n_forced*2) -y -r 29.97 output.mp4

这在 IE 和 Firefox 中播放正常,但在 Chrome 中播放不正常。可能是什么问题?如何设置不同的预设?当我给出 时-vpre,它会出错,提示“未找到预设文件”。

以下是控制台输出:

ffmpeg version N-65738-g3c197442 Copyright (c) 2000-2014 the FFmpeg developers
  built on Aug 18 2014 22:10:31 with gcc 4.8.3 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfi
g --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-lib
opencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinge
r --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --
enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-
libx265 --enable-libxavs --enable-libxvid --enable-decklink --enable-zlib
  libavutil      54.  5.100 / 54.  5.100
  libavcodec     56.  0.101 / 56.  0.101
  libavformat    56.  1.100 / 56.  1.100
  libavdevice    56.  0.100 / 56.  0.100
  libavfilter     5.  0.100 /  5.  0.100
  libswscale      3.  0.100 /  3.  0.100
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  0.100 / 53.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '534.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isom
    creation_time   : 2014-09-26 19:08:24
  Duration: 00:02:04.33, start: 0.000000, bitrate: 107 kb/s
    Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv), 192x128 [SAR 1:1 DAR 3:2], 75 kb/s, 12.50
 fps, 12.50 tbr, 12500 tbn, 25 tbc (default)
    Metadata:
      creation_time   : 2014-09-26 19:08:24
      handler_name    : MP4 Video Media Handler
      encoder         : AVC Coding
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 30 kb/s (default)
    Metadata:
      creation_time   : 2014-09-26 19:08:24
      handler_name    : MP4 Sound Media Handler
[libx264 @ 0000000002ac5920] using SAR=3/2
[libx264 @ 0000000002ac5920] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0000000002ac5920] profile High, level 3.1
[libx264 @ 0000000002ac5920] 264 - core 142 r2453 ea0ca51 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.vid
eolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed
_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookah
ead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_
adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahe
ad=40 rc=abr mbtree=1 bitrate=396 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'output.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isom
    encoder         : Lavf56.1.100
    Stream #0:0(eng): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 100x100 [SAR 3:2 DAR 3:2], q=-1--1, 396 k
b/s, 29.97 fps, 11988 tbn, 29.97 tbc (default)
    Metadata:
      creation_time   : 2014-09-26 19:08:24
      handler_name    : MP4 Video Media Handler
      encoder         : Lavc56.0.101 libx264
    Stream #0:1(eng): Audio: aac (libvo_aacenc) ([64][0][0][0] / 0x0040), 48000 Hz, stereo, s16, 32 kb/s (default)
    Metadata:
      creation_time   : 2014-09-26 19:08:24
      handler_name    : MP4 Sound Media Handler
      encoder         : Lavc56.0.101 libvo_aacenc
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (aac (native) -> aac (libvo_aacenc))
Press [q] to stop, [?] for help
frame= 3722 fps=847 q=-1.0 Lsize=    5702kB time=00:02:04.34 bitrate= 375.7kbits/s dup=2169 drop=0
video:5083kB audio:487kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.378099%
[libx264 @ 0000000002ac5920] frame I:71    Avg QP: 0.46  size:  6755
[libx264 @ 0000000002ac5920] frame P:1542  Avg QP: 0.52  size:  2867
[libx264 @ 0000000002ac5920] frame B:2109  Avg QP: 3.55  size:   144
[libx264 @ 0000000002ac5920] consecutive B-frames: 14.2% 28.2%  7.7% 50.0%
[libx264 @ 0000000002ac5920] mb I  I16..4: 25.2%  5.1% 69.7%
[libx264 @ 0000000002ac5920] mb P  I16..4:  2.1%  0.5%  4.6%  P16..4: 26.3% 12.5% 11.2%  0.0%  0.0%    skip:42.8%
[libx264 @ 0000000002ac5920] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8: 10.9%  1.1%  0.6%  direct: 1.9%  skip:85.5%  L0:41
.7% L1:51.9% BI: 6.5%
[libx264 @ 0000000002ac5920] final ratefactor: -7.35
[libx264 @ 0000000002ac5920] 8x8 transform intra:6.1% inter:21.2%
[libx264 @ 0000000002ac5920] coded y,uvDC,uvAC intra: 65.5% 80.0% 79.4% inter: 18.5% 21.3% 21.2%
[libx264 @ 0000000002ac5920] i16 v,h,dc,p: 44% 50%  4%  1%
[libx264 @ 0000000002ac5920] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 39% 16%  3%  2%  3%  3%  4%  5%
[libx264 @ 0000000002ac5920] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 14% 51% 10%  3%  4%  4%  4%  4%  6%
[libx264 @ 0000000002ac5920] i8c dc,h,v,p: 27% 54% 15%  4%
[libx264 @ 0000000002ac5920] Weighted P-Frames: Y:4.9% UV:2.4%
[libx264 @ 0000000002ac5920] ref P L0: 78.8% 10.4%  6.6%  4.0%  0.2%
[libx264 @ 0000000002ac5920] ref B L0: 96.9%  2.4%  0.7%
[libx264 @ 0000000002ac5920] ref B L1: 99.8%  0.2%
[libx264 @ 0000000002ac5920] kb/s:335.24

答案1

确定了背后的原因。这与 ffmpeg 放置元数据的方式有关。其他浏览器能够成功下载并播放文件,但 chrome 却不能。一旦我运行工具 qt-faststart,chrome 也开始并行播放和下载。

答案2

用作-movflags +faststart输出选项:

ffmpeg -i input.mp4 -c copy -movflags +faststart output.mp4

它会将一些数据重新定位到文件的开头,以便在渐进式下载期间进行播放,而不必等待文件完全下载。

相关内容