1

I have a HLS stream, that contains a number of arbitrary TS segments, some of which may refer to the same file. Desktop and mobile Safari plays it just fine, e.g. if I have a playlist that contains two identical segments which are 10s long, the video will look like a segment is repeated, and is 20s long.

FFmpeg (2.2.1), on the other hand, can't seem to handle this. When I try to convert an M3U8 file into an MP4 file,

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

it's not happy about the timestamps, I get output like this:

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%

The result is 10s long, which I also assume is because it thinks those two segments happen at the same time and drops frames. How can I force it to toss the timestamps and use frame rate to create fresh timestamps so I get a 20s long video?

  • Please include the complete ffmpeg console output. You can trim multiple repeating lines. – llogan Apr 24 '14 at 16:35
  • @LordNeckbeard added. – Alex B Apr 24 '14 at 17:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.