ffmpeg/OneDrive - MXF 中的 MP4 无法在浏览器中播放

ffmpeg/OneDrive - MXF 中的 MP4 无法在浏览器中播放

解决方案

ffmpeg -i input.mxf -pix_fmt yuv420p -c:v libx264 -preset fast -crf 22 -c:a aac -b:a 192k -movflags +faststart test.mp4

原始问题

尝试将大型 MXF(播放时间 1.1GB,2 分 36 秒)转换为一个相当小的 MP4 文件,以托管在 OneDrive(企业版)上。我可以使用以下方法进行转换:

ffmpeg -i input.mxf -c:v libx264 -preset fast -crf 22 -c:a aac -b:a 192k output.mp4

它确实可以在我电脑上的媒体播放器中播放,但在 Chrome 的 OneDrive 中我收到错误消息:“抱歉,加载视频时出现问题。”

现在,当我获取一个随机 MP4 测试文件,通过上述命令进行转换并上传时,它可以播放而不会出现问题。

有任何想法吗?

如果您需要调查某些内容(终端输出、文件信息......),请告诉我。

谢谢!

编辑:这是日志:

ffmpeg -i input.mxf -pix_fmt yuv420p -c:v libx264 -preset fast -crf 22 -c:a aac -b:a 192k -movflags +faststart test.mp4

日志:

ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 8.2.0 (Solus)
  configuration: --prefix=/usr --libdir=/usr/lib64 --disable-debug --disable-stripping --enable-shared --disable-static --enable-avisynth --enable-avresample --enable-gcrypt --enable-gpl --enable-libaom --enable-libass --enable-libbluray --enable-libcaca --enable-libcdio --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libopus --enable-libpulse --enable-libsnappy --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libv4l2 --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg --enable-nonfree --enable-nvdec --enable-nvenc --enable-openal --enable-opengl --enable-openssl --enable-sdl2 --enable-version3
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
Guessed Channel Layout for Input Stream #0.1 : mono
Guessed Channel Layout for Input Stream #0.2 : mono
Guessed Channel Layout for Input Stream #0.3 : mono
Guessed Channel Layout for Input Stream #0.4 : mono
Guessed Channel Layout for Input Stream #0.5 : mono
Guessed Channel Layout for Input Stream #0.6 : mono
Guessed Channel Layout for Input Stream #0.7 : mono
Guessed Channel Layout for Input Stream #0.8 : mono
Input #0, mxf, from 'input.mxf':
  Metadata:
    product_uid     : 27b66489-cf4b-1ddd-ae1e-be3d000b0002
    uid             : 27b66489-cf4b-1ddd-ae1e-be3d000b0000
    generation_uid  : 27b66489-cf4b-1ddd-ae1e-be3d000b0001
    company_name    : NANO
    product_name    : MXF 
    product_version : 3.1.0.0
    modification_date: 2019-02-15T11:31:07.000000Z
    material_package_umid: 0x060A2B340101010501010D23130000007C7826A05B0C1845AB68D7D39C677BF8
    timecode        : 00:00:00:00
  Duration: 00:02:36.08, start: 0.000000, bitrate: 59982 kb/s
    Stream #0:0: Video: mpeg2video (4:2:2), yuv422p(tv, bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], 50000 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
    Metadata:
      file_package_umid: 0x060A2B340101010501010D2313000000BF8B987DDF1F1749ABE27A7C953DC783
    Stream #0:1: Audio: pcm_s24le, 48000 Hz, mono, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D2313000000BF8B987DDF1F1749ABE27A7C953DC783
    Stream #0:2: Audio: pcm_s24le, 48000 Hz, mono, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D2313000000BF8B987DDF1F1749ABE27A7C953DC783
    Stream #0:3: Audio: pcm_s24le, 48000 Hz, mono, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D2313000000BF8B987DDF1F1749ABE27A7C953DC783
    Stream #0:4: Audio: pcm_s24le, 48000 Hz, mono, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D2313000000BF8B987DDF1F1749ABE27A7C953DC783
    Stream #0:5: Audio: pcm_s24le, 48000 Hz, mono, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D2313000000BF8B987DDF1F1749ABE27A7C953DC783
    Stream #0:6: Audio: pcm_s24le, 48000 Hz, mono, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D2313000000BF8B987DDF1F1749ABE27A7C953DC783
    Stream #0:7: Audio: pcm_s24le, 48000 Hz, mono, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D2313000000BF8B987DDF1F1749ABE27A7C953DC783
    Stream #0:8: Audio: pcm_s24le, 48000 Hz, mono, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D2313000000BF8B987DDF1F1749ABE27A7C953DC783
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg2video (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (pcm_s24le (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x1ff1340] using SAR=1/1
[libx264 @ 0x1ff1340] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x1ff1340] profile High, level 4.0
[libx264 @ 0x1ff1340] 264 - core 155 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=2 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=6 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 lookahead_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=1 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=30 rc=crf mbtree=1 crf=22.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'test.mp4':
  Metadata:
    product_uid     : 27b66489-cf4b-1ddd-ae1e-be3d000b0002
    uid             : 27b66489-cf4b-1ddd-ae1e-be3d000b0000
    generation_uid  : 27b66489-cf4b-1ddd-ae1e-be3d000b0001
    company_name    : NANO
    product_name    : MXF 
    product_version : 3.1.0.0
    modification_date: 2019-02-15T11:31:07.000000Z
    material_package_umid: 0x060A2B340101010501010D23130000007C7826A05B0C1845AB68D7D39C677BF8
    timecode        : 00:00:00:00
    encoder         : Lavf58.20.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 0.04 fps, 12800 tbn, 25 tbc
    Metadata:
      file_package_umid: 0x060A2B340101010501010D2313000000BF8B987DDF1F1749ABE27A7C953DC783
      encoder         : Lavc58.35.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp (24 bit), 192 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D2313000000BF8B987DDF1F1749ABE27A7C953DC783
      encoder         : Lavc58.35.100 aac
[mp4 @ 0x1fe5480] Starting second pass: moving the moov atom to the beginning of the file.864x    
frame= 3902 fps= 21 q=-1.0 Lsize=   93645kB time=00:02:36.09 bitrate=4914.5kbits/s speed=0.858x    
video:89857kB audio:3670kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.126170%
[libx264 @ 0x1ff1340] frame I:18    Avg QP:19.65  size:174490
[libx264 @ 0x1ff1340] frame P:982   Avg QP:22.50  size: 43528
[libx264 @ 0x1ff1340] frame B:2902  Avg QP:24.02  size: 15895
[libx264 @ 0x1ff1340] consecutive B-frames:  0.7%  0.2%  0.2% 98.8%
[libx264 @ 0x1ff1340] mb I  I16..4: 11.7% 77.5% 10.7%
[libx264 @ 0x1ff1340] mb P  I16..4:  0.8%  6.4%  0.3%  P16..4: 40.4% 14.4%  9.4%  0.0%  0.0%    skip:28.4%
[libx264 @ 0x1ff1340] mb B  I16..4:  1.6% 10.4%  0.0%  B16..8: 16.4%  3.9%  0.1%  direct:14.4%  skip:53.0%  L0:45.2% L1:42.6% BI:12.2%
[libx264 @ 0x1ff1340] 8x8 transform intra:85.7% inter:79.2%
[libx264 @ 0x1ff1340] coded y,uvDC,uvAC intra: 60.2% 63.0% 3.7% inter: 17.6% 23.3% 0.1%
[libx264 @ 0x1ff1340] i16 v,h,dc,p: 30% 26% 29% 16%
[libx264 @ 0x1ff1340] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 14% 46%  4%  3%  4%  3%  4%  4%
[libx264 @ 0x1ff1340] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 23% 12%  6%  9%  9%  7%  6%  6%
[libx264 @ 0x1ff1340] i8c dc,h,v,p: 57% 20% 21%  2%
[libx264 @ 0x1ff1340] Weighted P-Frames: Y:0.1% UV:0.1%
[libx264 @ 0x1ff1340] ref P L0: 48.9% 51.1%
[libx264 @ 0x1ff1340] ref B L0: 70.1% 29.9%
[libx264 @ 0x1ff1340] ref B L1: 90.1%  9.9%
[libx264 @ 0x1ff1340] kb/s:4716.20
[aac @ 0x1feea40] Qavg: 173.287

答案1

为了实现广泛的 MP4 兼容性,视频应为 H264 格式,并采用 4:2:0 子采样,音频应为 AAC-LC。此外,建议将元数据移至文件前面,以便快速开始播放,但这并不是绝对必要的。

所以,

ffmpeg -i input.mxf -pix_fmt yuv420p -c:v libx264 -preset fast -crf 22 -c:a aac -b:a 192k -movflags +faststart output.mp4

相关内容