使用 ffmpeg 将未压缩的视频转换为带 AAC 的 MP4 时,Windows Media PLayer 上没有音频

使用 ffmpeg 将未压缩的视频转换为带 AAC 的 MP4 时,Windows Media PLayer 上没有音频

我在将未压缩的视频转换为 mp4 格式并使用 AAC 音频时遇到了问题。我没有收到任何错误,但 Windows Media PLayer 的输出文件中的视频无法播放音频(其他播放器可以很好地处理这个问题,但通常 WMP 不会对我的其他 MP4 产生问题,所以我仍然觉得这里出了问题)。这是我的完整命令:

ffmpeg -i uncompressed.avi -s 426x240 -pix_fmt yuv420p -c:v libx264 -preset:v veryslow -profile:v main -crf:v 27 -movflags +faststart -c:a libfdk_aac -b:a 128k -t 00:00:10 output.mp4

输出结果如下:

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-mingw32- --pkg-config=pkg-config --enable-gpl --enable-libsoxr --enable-libx264 --enable-avisynth --enable-libxvid --enable-libmp3lame --enable-version3 --enable-zlib --enable-librtmp --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libopenjpeg --enable-gnutls --enable-libgsm --enable-libfreetype --enable-fontconfig --enable-libass --enable-libutvideo --enable-libopus --disable-w32threads --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 --enable-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
Guessed Channel Layout for  Input Stream #0.1 : stereo
Input #0, avi, from 'uncompressed.avi':
  Metadata:
    date            : 2012-04-16T16:02:12.00409-07:00
  Duration: 00:02:22.93, start: 0.000000, bitrate: 1199367 kb/s
    Stream #0:0: Video: rawvideo, bgr24, 1920x1080, 23.98 tbr, 23.98 tbn, 23.98 tbc
    Stream #0:1: Audio: pcm_f32le ([3][0][0][0] / 0x0003), 96000 Hz, stereo, flt, 6144 kb/s
[libx264 @ 000000000038f580] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 @ 000000000038f580] profile Main, level 2.2
[libx264 @ 000000000038f580] 264 - core 133 r2339 585324f - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=1 ref=16 deblock=1:0:0 analyse=0x1:0x131 me=umh subme=10 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=24 chroma_me=1 trellis=2 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=8 b_pyramid=2 b_adapt=2 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=23 scenecut=40 intra_refresh=0 rc_lookahead=60 rc=crf mbtree=1 crf=27.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:
    date            : 2012-04-16T16:02:12.00409-07:00
    encoder         : Lavf55.12.102
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 426x240, q=-1--1, 24k tbn, 23.98 tbc
    Stream #0:1: Audio: aac (libfdk_aac) ([64][0][0][0] / 0x0040), 96000 Hz, stereo, s16, 128 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> libx264)
  Stream #0:1 -> #0:1 (pcm_f32le -> libfdk_aac)
Press [q] to stop, [?] for help
frame=   53 fps=0.0 q=0.0 size=       0kB time=00:00:02.84 bitrate=   0.1kbits/s    
frame=   98 fps= 97 q=32.0 size=      23kB time=00:00:04.76 bitrate=  38.8kbits/s    
frame=  151 fps=100 q=32.0 size=      64kB time=00:00:06.68 bitrate=  78.5kbits/s    
frame=  200 fps= 99 q=32.0 size=     105kB time=00:00:08.60 bitrate=  99.7kbits/s    
[mp4 @ 00000000023d8e20] Starting second pass: moving header on top of the file
frame=  240 fps= 87 q=-1.0 Lsize=     244kB time=00:00:10.00 bitrate= 199.8kbits/s    

video:77kB audio:157kB subtitle:0 global headers:0kB muxing overhead 4.142690%
[libx264 @ 000000000038f580] frame I:2     Avg QP:24.64  size:  8447
[libx264 @ 000000000038f580] frame P:45    Avg QP:29.82  size:   686
[libx264 @ 000000000038f580] frame B:193   Avg QP:35.11  size:   159
[libx264 @ 000000000038f580] consecutive B-frames:  0.8%  0.0%  2.5% 26.7% 22.9% 15.0% 11.7% 16.7%  3.8%
[libx264 @ 000000000038f580] mb I  I16..4: 41.6%  0.0% 58.4%
[libx264 @ 000000000038f580] mb P  I16..4:  0.2%  0.0%  0.7%  P16..4: 12.0%  3.7%  5.8%  0.8%  0.3%    skip:76.4%
[libx264 @ 000000000038f580] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  8.5%  1.5%  0.9%  direct: 0.3%  skip:88.8%  L0:42.5% L1:50.5% BI: 7.0%
[libx264 @ 000000000038f580] direct mvs  spatial:95.9% temporal:4.1%
[libx264 @ 000000000038f580] coded y,uvDC,uvAC intra: 76.0% 40.8% 12.1% inter: 1.6% 0.4% 0.0%
[libx264 @ 000000000038f580] i16 v,h,dc,p: 25% 29%  6% 39%
[libx264 @ 000000000038f580] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10% 13%  4%  9% 13% 12% 14% 11% 14%
[libx264 @ 000000000038f580] i8c dc,h,v,p: 21% 48% 21% 10%
[libx264 @ 000000000038f580] Weighted P-Frames: Y:2.2% UV:2.2%
[libx264 @ 000000000038f580] ref P L0: 48.5% 11.1% 11.4%  4.7%  4.1%  5.3%  3.6%  1.9%  1.6%  1.5%  0.9%  1.1%  0.9%  1.3%  1.1%  1.1%
[libx264 @ 000000000038f580] ref B L0: 77.3%  6.0%  5.8%  2.5%  2.5%  2.1%  1.3%  0.5%  0.6%  0.3%  0.3%  0.4%  0.2%  0.2%  0.2%
[libx264 @ 000000000038f580] ref B L1: 93.9%  6.1%
[libx264 @ 000000000038f580] kb/s:62.65

我收到的唯一警告是它猜测了音频的通道布局。但是,它猜对了,所以我看不出这怎么会是问题所在:

我尝试过的事情:

  • 使用libvo_aacencand aac(与-strict experimental)...结果相同
  • 在可自由分发的版本(无需编译--enable-nonfree)上厌倦了上述两种情况,从以下位置下载这里而不是我自己构建的...结果相同
  • 使用 ...audio 编码相同的输入文件libvorbis效果很好

我不知所措。事实上,vorbis 编码器工作正常,这让我认为输入文件没有问题。但是,我不明白为什么 AAC 会因此而受阻。有什么想法我哪里做错了吗?

更新:ffprobe以下是有问题的文件 的输出:

ffprobe version N-54933-g1af9211 Copyright (c) 2007-2013 the FFmpeg developers
  built on Jul 25 2013 18:05:50 with gcc 4.7.3 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
  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, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    date            : 2012-04-16T16:02:12.00409-07:00
    encoder         : Lavf55.12.102
  Duration: 00:00:10.03, start: 0.021333, bitrate: 199 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 426x240, 63 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 96000 Hz, stereo, fltp, 128 kb/s
    Metadata:
      handler_name    : SoundHandler

答案1

好的,这里的问题似乎是采样率。音频以 96 kHz 编码,显然 Windows Media Player 不支持。当我将-ar 48000采样率设置为 48 kHz 时,音频播放完美。无论如何,96 kHz 对于网络视频来说可能有点过分了。感谢所有提供帮助的人。

相关内容