ffmpeg映射到mkv引入" fake"延迟相对于视频

时间:2016-08-01 12:25:00

标签: ffmpeg libx264 mkv

我需要使用ffmpeg将此x.264剪辑映射到matroska容器中:

ffmpeg -i f-0.mp4 -c copy f-0.mkv

这是ffmpeg控制台输出:

ffmpeg -i f-0.mp4 -c copy f-0.mkv   
ffmpeg version N-69672-g078be09 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.9.2 (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-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --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-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
  libavutil      54. 18.100 / 54. 18.100
  libavcodec     56. 21.102 / 56. 21.102
  libavformat    56. 19.100 / 56. 19.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5.  9.104 /  5.  9.104
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'f-0.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf56.19.100
  Duration: 00:02:08.06, start: 0.005333, bitrate: 5030 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 4865 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, stereo, fltp, 160 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
    Side data:
      unknown side data type 7 (4 bytes)
Output #0, matroska, to 'f-0.mkv':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf56.19.100
    Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 4865 kb/s, 29.97 fps, 29.97 tbr, 1k tbn, 30k tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, 160 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
    Side data:
      unknown side data type 7 (4 bytes)
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
...

结果似乎很好,播放同步音频和视频。但是,MediaInfo在Audio下显示了一个新项目(原始剪辑没有):

Delay relative to video                  : 1mn 5s

这是来自原始f-0.mp4文件的Mediainfo:

Audio
  ID                                       : 2
  Format                                   : AC-3
  Format/Info                              : Audio Coding 3
  Mode extension                           : CM (complete main)
  Format settings, Endianness              : Big
  Codec ID                                 : ac-3
  Duration                                 : 2mn 8s
  Bit rate mode                            : Constant
  Bit rate                                 : 160 Kbps
  Channel(s)                               : 2 channels
  Channel positions                        : Front: L R
  Sampling rate                            : 48.0 KHz
  Bit depth                                : 16 bits
  Compression mode                         : Lossy
  Delay relative to video                  : 67ms
  Stream size                              : 2.44 MiB (3%)

来自f-0.mkv输出的Mediainfo:

Audio
  ID                                       : 2
  Format                                   : AC-3
  Format/Info                              : Audio Coding 3
  Mode extension                           : CM (complete main)
  Format settings, Endianness              : Big
  Codec ID                                 : A_AC3
  Duration                                 : 2mn 8s
  Bit rate mode                            : Constant
  Bit rate                                 : 160 Kbps
  Channel(s)                               : 2 channels
  Channel positions                        : Front: L R
  Sampling rate                            : 48.0 KHz
  Bit depth                                : 16 bits
  Compression mode                         : Lossy
  Delay relative to video                  : 1mn 5s
  Stream size                              : 2.44 MiB (3%)
  Default                                  : Yes
  Forced                                   : No
  HANDLER_NAME                             : SoundHandler

没有任何延迟,没有理由插入延迟。

我担心某些播放器或其他应用程序会将此信息(延迟相对于视频)用作应予纠正的延迟。有没有办法防止这种情况发生?

添加ffprobe输出:f-0.mp4 clip

ffprobe -show_entries stream=codec_type,duration,start_time -of compact f-0.mp4
    ffprobe version N-69672-g078be09 Copyright (c) 2007-2015 the FFmpeg developers
    built with gcc 4.9.2 (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-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --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-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
    libavutil      54. 18.100 / 54. 18.100
    libavcodec     56. 21.102 / 56. 21.102
    libavformat    56. 19.100 / 56. 19.100
    libavdevice    56.  4.100 / 56.  4.100
    libavfilter     5.  9.104 /  5.  9.104
    libswscale      3.  1.101 /  3.  1.101
    libswresample   1.  1.100 /  1.  1.100
    libpostproc    53.  3.100 / 53.  3.100
  Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'f-0.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2avc1mp41
      encoder         : Lavf56.19.100
    Duration: 00:02:08.06, start: 0.005333, bitrate: 5030 kb/s
      Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 4865 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
      Metadata:
        handler_name    : VideoHandler
      Stream #0:1(und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, stereo, fltp, 160 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
      Side data:
        unknown side data type 7 (4 bytes)
  stream|codec_type=video|start_time=0.000000|duration=128.061267
  stream|codec_type=audio|start_time=-0.005333|duration=128.064000

f-0.mkv剪辑:

ffprobe version N-69672-g078be09 Copyright (c) 2007-2015 the FFmpeg developers
  built with gcc 4.9.2 (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-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --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-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
  libavutil      54. 18.100 / 54. 18.100
  libavcodec     56. 21.102 / 56. 21.102
  libavformat    56. 19.100 / 56. 19.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5.  9.104 /  5.  9.104
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, matroska,webm, from 'f-0.mkv':
  Metadata:
    COMPATIBLE_BRANDS: isomiso2avc1mp41
    MAJOR_BRAND     : isom
    MINOR_VERSION   : 512
    ENCODER         : Lavf56.19.100
  Duration: 00:02:08.13, start: 0.061000, bitrate: 5026 kb/s
    Stream #0:0(und): Video: h264 (High), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc (default)
    Metadata:
      LANGUAGE        : und
      HANDLER_NAME    : VideoHandler
    Stream #0:1(und): Audio: ac3, 48000 Hz, stereo, fltp, 160 kb/s (default)
    Metadata:
      LANGUAGE        : und
      HANDLER_NAME    : SoundHandler
stream|codec_type=video|start_time=0.066000|duration=N/A
stream|codec_type=audio|start_time=0.061000|duration=N/A

0 个答案:

没有答案