23

When I use ffmpeg to convert m3u8 to mp4, I get some warning,

ffmpeg -i xx.m3u8 -c copy demo.mp4

warning is

Non-monotonous DTS in output stream 0:1; previous: 3277744, current: 3276712; changing to 3277745. This may result in incorrect timestamps in the output file.
Non-monotonous DTS in output stream 0:1; previous: 3277745, current: 3277736; changing to 3277746. This may result in incorrect timestamps in the output file.

what should I do to fix it?

6
  • U want to copy hls stream to mp4 file? Apr 30, 2019 at 6:01
  • copy *.ts to mp4 file
    – xiao xin
    Apr 30, 2019 at 6:08
  • is it single ts file? Apr 30, 2019 at 6:10
  • If it is single ts file try it :: ffmpeg -fflags +igndts -i *.ts -map 0:0 -map 0:2 -c:v copy -c:a copy demo.mp4 Apr 30, 2019 at 6:10
  • not a single ts file.
    – xiao xin
    Apr 30, 2019 at 6:18

2 Answers 2

11

You can try this:

ffmpeg -i xx.m3u8 -c copy -bsf:a aac_adtstoasc demo.mp4

Per this forum post, you can also try:

It seems that decoding time stamps are broken. You can try "-fflags +igndts" to regenerate DTS based on PTS:

Or point to the .ts file directly, ignore the DTS:

ffmpeg -fflags +igndts -i xx.ts -map 0:0 -map 0:2 -c:v copy -c:a copy demo.mp4
5
  • 1
    thank you , but also get " Non-monotonous DTS in output stream 0:1; "
    – xiao xin
    Apr 30, 2019 at 6:05
  • can u please share me hls ts format and is it nested m3u8 file? Apr 30, 2019 at 6:07
  • 2
    "regenerate DTS based on PTS"? What do those abreviations mean?
    – zrajm
    Apr 25, 2020 at 20:20
  • 3
    "Decoding Time Stamp (DTS) and Presentation Time Stamp (PTS)" according to this question: stackoverflow.com/questions/6044330
    – zrajm
    Apr 25, 2020 at 20:22
  • 1
    This answer appears to quote forum.videohelp.com/threads/… Sep 19, 2021 at 23:21
0

I ran into this downloading sports video from HUDL. The m3u8 file had #EXT-X-DISCONTINUITY and #EXT-X-PROGRAM-DATE-TIME directives that ffmpeg didn't handle correctly. So I just created .txt file for ffmpeg to simply concatenate the segments with the directives removed:

Find m3u8 using browser tools

cat ~/Downloads/<m3_u8 downloaded> | grep ".ts$" | awk '{print "file <url path of m3u8 file>" $1}' > files.txt

ffmpeg -protocol_whitelist file,tcp,http,https,tls -f concat -safe 0 -i files.txt -q 0 -c copy video.MTS
1
  • It seems that ffmpeg 4.4.x and 5.1.x support those streams correctly, also if there is nothing about that in the changleog.
    – gabry
    Nov 15, 2022 at 7:53

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.