使用 ffmpeg 将示例 mkv 转换为 mp4 并在 Windows Media Player 中播放时遇到困难

使用 ffmpeg 将示例 mkv 转换为 mp4 并在 Windows Media Player 中播放时遇到困难

我有这个大 4GB 文件 C:\katc4d7>dir "WSC KAT.mkv"

13/06/2020  00:54     4,293,411,907 WSC KAT.mkv

C:\katc4d7>

这是该文件的 ffmpeg -i

C:\katowice_c4d7>ffmpeg -i "WSC KAT.mkv"
ffmpeg version N-94664-g0821bc4eee Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.1.1 (GCC) 20190807
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --e
nable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus -
-enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --ena
ble-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enabl
e-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid
--enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 33.100 / 56. 33.100
  libavcodec     58. 55.101 / 58. 55.101
  libavformat    58. 31.104 / 58. 31.104
  libavdevice    58.  9.100 / 58.  9.100
  libavfilter     7. 58.101 /  7. 58.101
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, matroska,webm, from 'WSC KAT.mkv':
  Metadata:
    COMPATIBLE_BRANDS: iso6avc1mp41
    MAJOR_BRAND     : dash
    MINOR_VERSION   : 0
    ENCODER         : Lavf58.31.104
  Duration: 10:13:18.06, start: -0.007000, bitrate: 933 kb/s
    Stream #0:0: Video: h264 (Main), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 1k tbn, 60 tbc (default)
    Metadata:
      HANDLER_NAME    : ISO Media file produced by Google Inc.
      DURATION        : 10:13:18.000000000
    Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 10:13:18.061000000
At least one output file must be specified

C:katowice_c4d7>

该文件的 Mediainfo

C:\katowice_c4d7>mediainfo "WSC KAT.mkv"
General
Unique ID                                : 176298603207404292884266102799528496737 (0x84A1E03B723FDA3FB02350D077720E61)
Complete name                            : WSC KAT.mkv
Format                                   : Matroska
Format version                           : Version 4
File size                                : 4.00 GiB
Duration                                 : 10 h 13 min
Overall bit rate                         : 933 kb/s
Writing application                      : Lavf58.31.104
Writing library                          : Lavf58.31.104
ErrorDetectionType                       : Per level 1

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : [email protected]
Format settings                          : CABAC / 3 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 3 frames
Codec ID                                 : V_MPEG4/ISO/AVC
Duration                                 : 10 h 13 min
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 30.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Title                                    : ISO Media file produced by Google Inc.
Default                                  : Yes
Forced                                   : No
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709

Audio
ID                                       : 2
Format                                   : Opus
Codec ID                                 : A_OPUS
Duration                                 : 10 h 13 min
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Bit depth                                : 32 bits
Compression mode                         : Lossy
Language                                 : English
Default                                  : Yes
Forced                                   : No



C:\katowice_c4d7>

从中我制作了一个 10 秒的小样本文件

C:\katowice_c4d7>ffmpeg -i "WSC KAT.mkv" -ss 0 -t 10 -acodec copy -vcodec copy blahsample1.mkv

所以

14/06/2020  20:55           804,239 blahsample1.mkv

blahsample1.mkv 上的 ffmpeg -i 和 mediainfo

C:\katowice_c4d7>ffmpeg -i blahsample1.mkv
ffmpeg version N-94664-g0821bc4eee Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.1.1 (GCC) 20190807
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --
nable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus
-enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --en
ble-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enab
e-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid
--enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 33.100 / 56. 33.100
  libavcodec     58. 55.101 / 58. 55.101
  libavformat    58. 31.104 / 58. 31.104
  libavdevice    58.  9.100 / 58.  9.100
  libavfilter     7. 58.101 /  7. 58.101
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
[matroska,webm @ 00000000003e02c0] Could not find codec parameters for stream 0 (Video: h264, none(tv, bt709, progressive), 1280x720): unspecified pi
el format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, matroska,webm, from 'blahsample1.mkv':
  Metadata:
    MINOR_VERSION   : 0
    COMPATIBLE_BRANDS: iso6avc1mp41
    MAJOR_BRAND     : dash
    ENCODER         : Lavf58.31.104
  Duration: 00:00:10.14, start: -0.007000, bitrate: 634 kb/s
    Stream #0:0: Video: h264, none(tv, bt709, progressive), 1280x720, SAR 1:1 DAR 16:9, 30 fps, 30 tbr, 1k tbn, 2k tbc (default)
    Metadata:
      HANDLER_NAME    : ISO Media file produced by Google Inc.
      DURATION        : 00:00:10.140000000
    Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 00:00:10.001000000
At least one output file must be specified

因此上面给出了错误或警告或消息

> "[matroska,webm @ 00000000004f02c0] Could not find codec parameters
> for stream 0 (Video: h264, none(tv, bt709, progressive), 1280x720):
> unspecified pixel format Consider increasing the value for the
> 'analyzeduration' and 'probesize' options"

对其执行 mediainfo 来显示编解码器和容器

C:\katowice_c4d7>mediainfo blahsample1.mkv
General
Unique ID                                : 80056453567816008795659539662543258381 (0x3C3A4FE6E2791064891BD0F635B8030D)
Complete name                            : blahsample1.mkv
Format                                   : Matroska
Format version                           : Version 4
File size                                : 785 KiB
Duration                                 : 10 s 140 ms
Overall bit rate                         : 635 kb/s
Writing application                      : Lavf58.31.104
Writing library                          : Lavf58.31.104
ErrorDetectionType                       : Per level 1

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : [email protected]
Format settings                          : CABAC / 3 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 3 frames
Codec ID                                 : V_MPEG4/ISO/AVC
Duration                                 : 5 s 0 ms
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 30.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Title                                    : ISO Media file produced by Google Inc.
Default                                  : Yes
Forced                                   : No
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709

Audio
ID                                       : 2
Format                                   : Opus
Codec ID                                 : A_OPUS
Duration                                 : 10 s 1 ms
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Bit depth                                : 32 bits
Compression mode                         : Lossy
Delay relative to video                  : -5 s 140 ms
Language                                 : English
Default                                  : Yes
Forced                                   : No



C:\katowice_c4d7>

Too many packets buffered for output stream 0:1. 正如您在下面的输出中看到的那样,下面给出了一个错误

C:\katowice_c4d7>ffmpeg -i blahsample1.mkv -acodec copy -vcodec libx264 yyy1.mp4
ffmpeg version N-94664-g0821bc4eee Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.1.1 (GCC) 20190807
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --e
nable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus -
-enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --ena
ble-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enabl
e-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid
--enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 33.100 / 56. 33.100
  libavcodec     58. 55.101 / 58. 55.101
  libavformat    58. 31.104 / 58. 31.104
  libavdevice    58.  9.100 / 58.  9.100
  libavfilter     7. 58.101 /  7. 58.101
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
[matroska,webm @ 00000000005606c0] Could not find codec parameters for stream 0 (Video: h264, none(tv, bt709, progressive), 1280x720): unspecified pix
el format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, matroska,webm, from 'blahsample1.mkv':
  Metadata:
    MINOR_VERSION   : 0
    COMPATIBLE_BRANDS: iso6avc1mp41
    MAJOR_BRAND     : dash
    ENCODER         : Lavf58.31.104
  Duration: 00:00:10.14, start: -0.007000, bitrate: 634 kb/s
    Stream #0:0: Video: h264, none(tv, bt709, progressive), 1280x720, SAR 1:1 DAR 16:9, 30 fps, 30 tbr, 1k tbn, 2k tbc (default)
    Metadata:
      HANDLER_NAME    : ISO Media file produced by Google Inc.
      DURATION        : 00:00:10.140000000
    Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 00:00:10.001000000
File 'yyy1.mp4' already exists. Overwrite ? [y/N] y
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
Too many packets buffered for output stream 0:1.
Conversion failed!

C:\katowice_c4d7>

如果我尝试这个命令-acodec aac -vcodec copy,就会出现这个错误

[mp4 @ 000000000298f040] 输出流 0:0 中的 DTS: 85552 PTS: 82896 无效,由猜测替换 [mp4 @ 000000000298f040] 输出流 0:0 中的非单调 DTS;之前:85025,当前:82896;更改为 85026。这可能会导致时间不正确

正如您在下面的输出中看到的那样

C:\katowice_c4d7>ffmpeg -i blahsample1.mkv -acodec aac -vcodec copy yyy1.mp4
ffmpeg version N-94664-g0821bc4eee Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.1.1 (GCC) 20190807
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --e
nable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus -
-enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --ena
ble-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enabl
e-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid
--enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 33.100 / 56. 33.100
  libavcodec     58. 55.101 / 58. 55.101
  libavformat    58. 31.104 / 58. 31.104
  libavdevice    58.  9.100 / 58.  9.100
  libavfilter     7. 58.101 /  7. 58.101
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
[matroska,webm @ 00000000001206c0] Could not find codec parameters for stream 0 (Video: h264, none(tv, bt709, progressive), 1280x720): unspecified pix
el format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, matroska,webm, from 'blahsample1.mkv':
  Metadata:
    MINOR_VERSION   : 0
    COMPATIBLE_BRANDS: iso6avc1mp41
    MAJOR_BRAND     : dash
    ENCODER         : Lavf58.31.104
  Duration: 00:00:10.14, start: -0.007000, bitrate: 634 kb/s
    Stream #0:0: Video: h264, none(tv, bt709, progressive), 1280x720, SAR 1:1 DAR 16:9, 30 fps, 30 tbr, 1k tbn, 2k tbc (default)
    Metadata:
      HANDLER_NAME    : ISO Media file produced by Google Inc.
      DURATION        : 00:00:10.140000000
    Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 00:00:10.001000000
File 'yyy1.mp4' already exists. Overwrite ? [y/N] y
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (opus (native) -> aac (native))
Press [q] to stop, [?] for help
Output #0, mp4, to 'yyy1.mp4':
  Metadata:
    MINOR_VERSION   : 0
    COMPATIBLE_BRANDS: iso6avc1mp41
    MAJOR_BRAND     : dash
    encoder         : Lavf58.31.104
    Stream #0:0: Video: h264 (avc1 / 0x31637661), none(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 30 fps, 30 tbr, 16k tbn, 1k tbc (
default)
    Metadata:
      HANDLER_NAME    : ISO Media file produced by Google Inc.
      DURATION        : 00:00:10.140000000
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      DURATION        : 00:00:10.001000000
      encoder         : Lavc58.55.101 aac
[mp4 @ 000000000298f040] Invalid DTS: 85552 PTS: 82896 in output stream 0:0, replacing by guess
[mp4 @ 000000000298f040] Non-monotonous DTS in output stream 0:0; previous: 85025, current: 82896; changing to 85026. This may result in incorrect tim
estamps in the output file.
[mp4 @ 000000000298f040] Non-monotonous DTS in output stream 0:0; previous: 85026, current: 83424; changing to 85027. This may result in incorrect tim
estamps in the output file.
[mp4 @ 000000000298f040] Non-monotonous DTS in output stream 0:0; previous: 85027, current: 83952; changing to 85028. This may result in incorrect tim
estamps in the output file.
[mp4 @ 000000000298f040] Non-monotonous DTS in output stream 0:0; previous: 85028, current: 84496; changing to 85029. This may result in incorrect tim
estamps in the output file.
frame=  147 fps=0.0 q=-1.0 Lsize=     794kB time=00:00:10.01 bitrate= 649.4kbits/s speed=43.2x
video:629kB audio:157kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.968342%
[aac @ 0000000000143a00] Qavg: 179.721

C:\katowice_c4d7>

当我创建此文件 yyyz1.mp4 时,它将在 VLC 中播放,但无法在 WMP 中播放

C:\katowice_c4d7>ffmpeg -i blahsample1.mkv -acodec aac -vcodec copy yyyz1.mp4
ffmpeg version N-94664-g0821bc4eee Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.1.1 (GCC) 20190807
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --e
nable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus -
-enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --ena
ble-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enabl
e-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid
--enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 33.100 / 56. 33.100
  libavcodec     58. 55.101 / 58. 55.101
  libavformat    58. 31.104 / 58. 31.104
  libavdevice    58.  9.100 / 58.  9.100
  libavfilter     7. 58.101 /  7. 58.101
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
[matroska,webm @ 00000000003206c0] Could not find codec parameters for stream 0 (Video: h264, none(tv, bt709, progressive), 1280x720): unspecified pix
el format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, matroska,webm, from 'blahsample1.mkv':
  Metadata:
    MINOR_VERSION   : 0
    COMPATIBLE_BRANDS: iso6avc1mp41
    MAJOR_BRAND     : dash
    ENCODER         : Lavf58.31.104
  Duration: 00:00:10.14, start: -0.007000, bitrate: 634 kb/s
    Stream #0:0: Video: h264, none(tv, bt709, progressive), 1280x720, SAR 1:1 DAR 16:9, 30 fps, 30 tbr, 1k tbn, 2k tbc (default)
    Metadata:
      HANDLER_NAME    : ISO Media file produced by Google Inc.
      DURATION        : 00:00:10.140000000
    Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 00:00:10.001000000
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (opus (native) -> aac (native))
Press [q] to stop, [?] for help
Output #0, mp4, to 'yyyz1.mp4':
  Metadata:
    MINOR_VERSION   : 0
    COMPATIBLE_BRANDS: iso6avc1mp41
    MAJOR_BRAND     : dash
    encoder         : Lavf58.31.104
    Stream #0:0: Video: h264 (avc1 / 0x31637661), none(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 30 fps, 30 tbr, 16k tbn, 1k tbc (
default)
    Metadata:
      HANDLER_NAME    : ISO Media file produced by Google Inc.
      DURATION        : 00:00:10.140000000
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      DURATION        : 00:00:10.001000000
      encoder         : Lavc58.55.101 aac
[mp4 @ 0000000002972280] Invalid DTS: 85552 PTS: 82896 in output stream 0:0, replacing by guess
[mp4 @ 0000000002972280] Non-monotonous DTS in output stream 0:0; previous: 85025, current: 82896; changing to 85026. This may result in incorrect tim
estamps in the output file.
[mp4 @ 0000000002972280] Non-monotonous DTS in output stream 0:0; previous: 85026, current: 83424; changing to 85027. This may result in incorrect tim
estamps in the output file.
[mp4 @ 0000000002972280] Non-monotonous DTS in output stream 0:0; previous: 85027, current: 83952; changing to 85028. This may result in incorrect tim
estamps in the output file.
[mp4 @ 0000000002972280] Non-monotonous DTS in output stream 0:0; previous: 85028, current: 84496; changing to 85029. This may result in incorrect tim
estamps in the output file.
frame=  147 fps=0.0 q=-1.0 Lsize=     794kB time=00:00:10.01 bitrate= 649.4kbits/s speed=44.9x
video:629kB audio:157kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.968342%
[aac @ 0000000002976700] Qavg: 179.721

C:\katowice_c4d7>yyyz1.mp4

如果我尝试

C:\katowice_c4d7>ffmpeg -ss 0 -i "WSC KAT.mkv" -t 10 -acodec aac -vcodec copy -analyzeduration 4GB blahsample3.mp4

然后它仍然可以在 VLC 中播放,但不能在 WMP 中播放,

我刚刚听说 -analyzeduration 应该放在 -i 之前,

我注意到 mediainfo 说 AAC 复杂度低。我刚刚尝试制作另一个文件。这次将 analyzeration 放在 -i 之前,并使用 MP3 作为音频。

ffmpeg -ss 0 -analyzeduration 4GB -i "WSC KAT.mkv" -t 10 -acodec libmp3lame -vcodec copy blahsample5.mp4 它可以在 VLC 中播放,而不是 WMP。我想知道是否有任何方法可以查看文件中是否存在可能导致此问题的内容?

但它仍然可以在 VLC 中播放,而不是 WMP

如果我尝试这个命令,当它转换时我确实会得到一些有趣的输出,我想知道那里是否有线索。

C:\kat>ffmpeg -ss 0 -analyzeduration 4GB  -i "WSC KAT.mkv"-t 10 -acodec libmp3lame -vcodec libx264 blahsample6.mp4

....Output #0, mp4, to 'blahsample6.mp4':
  Metadata:
    COMPATIBLE_BRANDS: iso6avc1mp41
    MAJOR_BRAND     : dash
    MINOR_VERSION   : 0
    encoder         : Lavf58.31.104
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 30 fps, 15360 tbn, 30 tbc (default)
    Metadata:
      HANDLER_NAME    : ISO Media file produced by Google Inc.
      DURATION        : 10:13:18.000000000
      encoder         : Lavc58.55.101 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: 18446744073709551615
    Stream #0:1(eng): Audio: mp3 (libmp3lame) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 10:13:18.061000000
      encoder         : Lavc58.55.101 libmp3lame
frame=  300 fps= 57 q=-1.0 Lsize=    1080kB time=00:00:10.01 bitrate= 883.6kbits/s speed= 1.9x
video:914kB audio:157kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.925101%
[libx264 @ 00000000004afb40] frame I:2     Avg QP:17.81  size:134240
[libx264 @ 00000000004afb40] frame P:76    Avg QP:20.80  size:  6444
[libx264 @ 00000000004afb40] frame B:222   Avg QP:26.70  size:   796
[libx264 @ 00000000004afb40] consecutive B-frames:  1.3%  0.0%  0.0% 98.7%
[libx264 @ 00000000004afb40] mb I  I16..4: 11.6% 18.2% 70.2%
[libx264 @ 00000000004afb40] mb P  I16..4:  0.6%  0.9%  0.6%  P16..4: 11.8%  3.6%  3.5%  0.0%  0.0%    skip:79.1%
[libx264 @ 00000000004afb40] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  8.5%  0.8%  0.4%  direct: 0.3%  skip:89.9%  L0:53.7% L1:42.6% BI: 3.7%
[libx264 @ 00000000004afb40] 8x8 transform intra:29.5% inter:50.0%
[libx264 @ 00000000004afb40] coded y,uvDC,uvAC intra: 72.9% 76.0% 48.0% inter: 2.3% 2.8% 0.3%
[libx264 @ 00000000004afb40] i16 v,h,dc,p: 13% 40% 25% 22%
[libx264 @ 00000000004afb40] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 17% 25% 29%  5%  4%  4%  5%  5%  7%
[libx264 @ 00000000004afb40] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 32% 13%  5%  7%  5%  6%  5%  6%
[libx264 @ 00000000004afb40] i8c dc,h,v,p: 41% 35% 19%  5%
[libx264 @ 00000000004afb40] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 00000000004afb40] ref P L0: 72.3%  9.5% 13.3%  4.9%
[libx264 @ 00000000004afb40] ref B L0: 93.3%  6.0%  0.8%
[libx264 @ 00000000004afb40] ref B L1: 96.0%  4.0%
[libx264 @ 00000000004afb40] kb/s:747.92

添加

我刚刚尝试了建议的 -fflags

https://pastebin.com/raw/3pwWWGyV

但它仍然无法在 WMP 中播放

我无法将该内容粘贴到我的问题中,因为我可以放入的内容有限制!但它在 pastebin 链接上。

这可能更能说明问题

ffmpeg -analyzeduration 4GB -fflags +igndts -ss 0 -i "WSC KAT.mkv" -t 10 -acodec libmp3lame -vcodec libx264 blahsample8.mp4

https://pastebin.com/raw/na8Q1bNv

我看到它说

[libx264 @ 000000000051d600] frame I:2     Avg QP:17.81  size:134240
[libx264 @ 000000000051d600] frame P:76    Avg QP:20.80  size:  6444
[libx264 @ 000000000051d600] frame B:222   Avg QP:26.70  size:   796
[libx264 @ 000000000051d600] consecutive B-frames:  1.3%  0.0%  0.0% 98.7%
[libx264 @ 000000000051d600] mb I  I16..4: 11.6% 18.2% 70.2%
[libx264 @ 000000000051d600] mb P  I16..4:  0.6%  0.9%  0.6%  P16..4: 11.8%  3.6%  3.5%  0.0%  0.0%    skip:79.1%
[libx264 @ 000000000051d600] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  8.5%  0.8%  0.4%  direct: 0.3%  skip:89.9%  L0:53.7% L1:42.6% BI: 3.7%
[libx264 @ 000000000051d600] 8x8 transform intra:29.5% inter:50.0%
[libx264 @ 000000000051d600] coded y,uvDC,uvAC intra: 72.9% 76.0% 48.0% inter: 2.3% 2.8% 0.3%
[libx264 @ 000000000051d600] i16 v,h,dc,p: 13% 40% 25% 22%
[libx264 @ 000000000051d600] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 17% 25% 29%  5%  4%  4%  5%  5%  7%
[libx264 @ 000000000051d600] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 32% 13%  5%  7%  5%  6%  5%  6%
[libx264 @ 000000000051d600] i8c dc,h,v,p: 41% 35% 19%  5%
[libx264 @ 000000000051d600] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 000000000051d600] ref P L0: 72.3%  9.5% 13.3%  4.9%
[libx264 @ 000000000051d600] ref B L0: 93.3%  6.0%  0.8%
[libx264 @ 000000000051d600] ref B L1: 96.0%  4.0%
[libx264 @ 000000000051d600] kb/s:747.92

答案1

解码时间戳已损坏。请尝试-fflags +igndts根据 PTS 重新生成 DTS:

ffmpeg -fflags +igndts -ss 0 -i "WSC KAT.mkv" -t 10 -acodec aac -vcodec copy blahsample3.mp4

由 barlop 添加

对于 OP 仍然无法播放的问题,anex5 指出“Windows Media Player 不支持 .mp4 文件格式的播放。除非你安装兼容 DirectShow 的 MPEG-4 解码器包 https://support.microsoft.com/en-us/help/316992/file-types-supported-by-windows-media-player

答案2

如果您从 MKV 的开头进行搜索,请避免-ss选择。

使用生成示例文件

ffmpeg -i "WSC KAT.mkv" -t 10 -acodec copy -vcodec copy blahsample1.mkv

从样本生成 MP4

ffmpeg -i "blahsample1.mkv" -acodec aac -vcodec copy blahsample1.mp4

由 barlop 添加

我发现,-ss 0 在编码为 mp4 时,在 -i 之后执行实际上会产生不同的文件,与将其放在 -i 之前相比。 -ss如果使用,应该在 -i 之前,而-ss 0在 -i 之前是多余的,而在 -i 之后是错误的。

Gyan 评论

“-ss 用作视频流复制的输出选项会导致 ffmpeg 等到搜索点后的下一个关键帧才开始复制数据包。H.264 比特流在流的开头附加了一个配置单元。一些复用器(主要是 WebRTC 编写器)可能会在没有时间戳的情况下写入它。在这种情况下,-ss 0 会导致它被跳过。导致您看到的提取文件中缺少参数”

“看到这一行:[matroska,webm @ 00000000003206c0] Could not find codec parameters for stream 0 (Video: h264, none(tv, bt709, progressive), 1280x720): unspecified pixel format

相关内容