ffmpeg HLS 解复用器处理具有重叠时间戳的视频

ffmpeg HLS 解复用器处理具有重叠时间戳的视频

我有一个 HLS 流,其中包含多个任意 TS 片段,其中一些可能引用同一个文件。桌面和移动 Safari 都可以正常播放它,例如,如果我有一个播放列表,其中包含两个长度为 10 秒的相同片段,则视频看起来就像一个重复的片段,长度为 20 秒。

另一方面,FFmpeg (2.2.1) 似乎无法处理这个问题。当我尝试将 M3U8 文件转换为 MP4 文件时,

ffmpeg -y -i a.m3u8 -c copy a.mp4

它对时间戳不满意,我得到如下输出:

ffmpeg version 2.2.1 Copyright (c) 2000-2014 the FFmpeg developers
  built on Apr 11 2014 22:50:38 with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.2.1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
  libavutil      52. 66.100 / 52. 66.100
  libavcodec     55. 52.102 / 55. 52.102
  libavformat    55. 33.100 / 55. 33.100
  libavdevice    55. 10.100 / 55. 10.100
  libavfilter     4.  2.100 /  4.  2.100
  libavresample   1.  2.  0 /  1.  2.  0
  libswscale      2.  5.102 /  2.  5.102
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
Input #0, hls,applehttp, from 'example.m3u8':
  Duration: 00:00:20.00, start: 1.400000, bitrate: 0 kb/s
  Program 0
    Metadata:
      variant_bitrate : 0
    Stream #0:0: Video: h264 (Baseline) ([27][0][0][0] / 0x001B), yuv420p, 640x480, 20 tbr, 90k tbn, 180k tbc
    Stream #0:1: Audio: aac ([15][0][0][0] / 0x000F), 22050 Hz, mono, fltp, 71 kb/s
Output #0, mp4, to 'example.mp4':
  Metadata:
    encoder         : Lavf55.33.100
    Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 640x480, q=2-31, 90k tbn, 90k tbc
    Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 22050 Hz, mono, 71 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mpegts @ 0x7fb723026e00] DTS 130180 < 1025680 out of order
[hls,applehttp @ 0x7fb723006600] DTS 130180 < 1025680 out of order
[mp4 @ 0x7fb7231afa00] Non-monotonous DTS in output stream 0:0; previous: 899680, current: 4180; changing to 899681. This may result in incorrect timestamps in the output file.
[mp4 @ 0x7fb7231afa00] Non-monotonous DTS in output stream 0:0; previous: 899681, current: 8680; changing to 899682. This may result in incorrect timestamps in the output file.

... a lot of repeating DTS logs ...

[mp4 @ 0x7fb7231afa00] Non-monotonous DTS in output stream 0:0; previous: 899879, current: 899680; changing to 899880. This may result in incorrect timestamps in the output file.
frame=  400 fps=0.0 q=-1.0 Lsize=    1338kB time=00:00:10.18 bitrate=1076.4kbits/s
video:1131kB audio:203kB subtitle:0 data:0 global headers:0kB muxing overhead 0.272749%

结果是 10 秒长,我也认为这是因为它认为这两个片段同时发生并丢帧。我如何才能强制它丢弃时间戳并使用帧速率创建新的时间戳,以便获得 20 秒长的视频?

相关内容