Help with error: "Non-monotonous DTS in output stream"

Questions involving a Windows version of FFmpeg.
Post Reply
avirex
Posts: 2
Joined: Wed May 08, 2013 8:03 pm

Help with error: "Non-monotonous DTS in output stream"

Post by avirex »

Hello.

I am using ffmpeg (Windows) to re-stream a particular Live TV stream to our edge streaming server, and it works well for a few hours, but then the video begins pausing and freeze.

In ffmpeg begin the see the following error repeat:

Code: Select all

[flv @ 0000000004a72a60]
 
Non-monotonous DTS in output stream 0:0; previous: 38226576, current: 31954504; 
changing to 38226576. This may result in incorrect timestamps in the output file.

[flv @ 0000000004a72a60]
 
Non-monotonous DTS in output stream 0:0; previous: 38226576, current: 31954543; 
changing to 38226576. This may result in incorrect timestamps in the output file.

Does anyone know what this error means and how to mitigate? Here is the ffmpeg command:

Code: Select all

ffmpeg.exe -threads 0 -i "$rurl playpath=$rplaypath swfUrl=$rswfurl pageUrl=$rpageurl live=1 " -map_metadata -1 -loglevel info -f flv -acodec copy -vcodec copy -r 15 -aspect 16:9 -bufsize 12000k "rtmp://localhost/$dapp/$dstream"  2> F:\Streams\$dstream.log


Thanks for any help!

rogerdpack
Posts: 1882
Joined: Fri Aug 05, 2011 9:56 pm

Re: Help with error: "Non-monotonous DTS in output stream"

Post by rogerdpack »

That is odd. I'd probably suggest re-asking your question on the ffmpeg-user mailing list. Sorry to not be of more help.

avirex
Posts: 2
Joined: Wed May 08, 2013 8:03 pm

Re: Help with error: "Non-monotonous DTS in output stream"

Post by avirex »

Thanks. I am awaiting approval to post to that list.

Something interesting I found in the logs, when the error actually starts...

negative cts, previous timestamps might be wrong
DTS 4294905094, next:4418668000 st:0 invalid dropping
PTS 4294905094, next:4418668000 invalid dropping st:0

frame=110408 fps= 25 q=-1.0 size= 326675kB time=01:13:38.89 bitrate= 605.6kbits/s
frame=110526 fps= 25 q=-1.0 size= 327025kB time=01:13:43.61 bitrate= 605.6kbits/s
negative cts, previous timestamps might be wrong
[flv @ 0000000004a72a60]
Non-monotonous DTS in output stream 0:0; previous: 4423587, current: -52282;
changing to 4423587. This may result in incorrect timestamps in the output file.

[flv @ 000000000039f900]
negative cts, previous timestamps might be wrong
[flv @ 0000000004a72a60]
Non-monotonous DTS in output stream 0:0; previous: 4423587, current: -52202;
changing to 4423587. This may result in incorrect timestamps in the output file.


So you can see at that point the the DTS/PTS status message is replaced by the "Non-monotonous DTS" error. The DTS/PTS status messages never come back. Also notice the "current" value is negative and then slowly climbs back to positive values.

Any idea if there is another way to recover or prevent DTS/PTS sync issues? Maybe I need to try a more aggressive approach by dropping frames to catch up?


Thanks for any insight.

rogerdpack
Posts: 1882
Joined: Fri Aug 05, 2011 9:56 pm

Re: Help with error: "Non-monotonous DTS in output stream"

Post by rogerdpack »

avirex wrote: DTS 4294905094, next:4418668000 st:0 invalid dropping


Those values look suspiciously close to the value for "max int" so my guess is that somehow the timestamp is "looping" and ffmpeg doesn't handle that (well? right? at all?) How can you ever have a negative PTS? Anyway seems like a bug in FFmpeg...I wonder if maybe you run ffmpeg -loglevel verbose it gives more information, and/or -debug_ts ?

vvillain
Posts: 2
Joined: Wed Oct 15, 2014 10:51 am

Re: Help with error: "Non-monotonous DTS in output stream"

Post by vvillain »

have you try to specify the encoder timebase: -copytb 1 to use the demuxer timebase.
See https://www.ffmpeg.org/ffmpeg.html#Advanced-options

sfichera
Posts: 2
Joined: Mon Jun 20, 2016 12:33 am

Re: Help with error: "Non-monotonous DTS in output stream"

Post by sfichera »

Hello avirex How are you?

Have you found the solution to this issue? I'm facing the same problem here...

Code: Select all

[mpegts @ 02f4d360] Invalid timestamps stream=0, pts=4413892767, dts=13003812344, size=8538=1.01x
[mpegts @ 02f4d360] Invalid timestamps stream=0, pts=4413904779, dts=13003824356, size=245491.01x
[mpegts @ 05ca3300] Non-monotonous DTS in output stream 0:0; previous: 8584532687, current: 8584529097; changing to 8584532688. This may result in incorrect timestamps in the output file.
[mpegts @ 05ca3300] Non-monotonous DTS in output stream 0:0; previous: 8584532688, current: 8584532100; changing to 8584532689. This may result in incorrect timestamps in the output file.
[mpegts @ 02f4d360] Invalid timestamps stream=0, pts=4413901537, dts=13003821114, size=100921.01x
[mpegts @ 02f4d360] Invalid timestamps stream=0, pts=4413895531, dts=13003824117, size=3327
[mpegts @ 02f4d360] DTS 4413892528 < 13003824117 out of order9 bitrate=15000.0kbits/s speed=1.01x
                                                                                          
Thanks & Regards!
Sebastián

billybitflipper
Posts: 6
Joined: Thu Apr 06, 2017 9:40 pm

Re: Help with error: "Non-monotonous DTS in output stream"

Post by billybitflipper »

I also am having the same issue on an encode right now, is there a known solution?

To be fair, I am using a nightlybuild of ffmpeg for x265, not x264 but it has actually been great for one particular set of files I'm converting (besides one small issue)

Gnitry
Posts: 1
Joined: Mon Sep 25, 2017 12:36 pm

Re: Help with error: "Non-monotonous DTS in output stream"

Post by Gnitry »

Did someone solved this issue? I'm expereincing the same problem.

I record video from 2 cameras simultaneously with rotation every minute by command:

Code: Select all

"ffmpeg\ffmpeg.exe" -i "rtsp://192.168.3.37:554/stream1" -vcodec copy -an -f segment -strftime 1 -segment_time 60 "D:\VideoRotation\TopView\TopView-%Y-%m-%d_%H-%M-%S.ts"
And I found that every ~13 hours both of ffmpegs stop recording with messages like

Code: Select all

2017.09.25 12:30:40.226  [segment @ 0000000001b7c280] Non-monotonous DTS in output stream 0:0; previous: 4289517827, current: -5445719; changing to 4289517828. This may result in incorrect timestamps in the output file.
2017.09.25 12:30:40.271  [NULL @ 0000000000a8c760] SEI type 5 size 448 truncated at 160
2017.09.25 12:30:40.271  [segment @ 0000000001b7c280] Non-monotonous DTS in output stream 0:0; previous: 4289517828, current: -5441964; changing to 4289517829. This may result in incorrect timestamps in the output file.
2017.09.25 12:30:40.286  [NULL @ 0000000000a8c760] SEI type 5 size 448 truncated at 160
2017.09.25 12:30:40.286  [segment @ 0000000001b7c280] Non-monotonous DTS in output stream 0:0; previous: 4289517829, current: -5438214; changing to 4289517830. This may result in incorrect timestamps in the output file.
2017.09.25 12:30:40.337  [NULL @ 0000000000a8c760] SEI type 5 size 448 truncated at 160
2017.09.25 12:30:40.338  [segment @ 0000000001b7c280] Non-monotonous DTS in output stream 0:0; previous: 4289517830, current: -5434465; changing to 4289517831. This may result in incorrect timestamps in the output file.
2017.09.25 12:30:40.352  [NULL @ 0000000000a8c760] SEI type 5 size 448 truncated at 160
2017.09.25 12:30:40.352  [segment @ 0000000001b7c280] Non-monotonous DTS in output stream 0:0; previous: 4289517831, current: -5430715; changing to 4289517832. This may result in incorrect timestamps in the output file.
2017.09.25 12:30:40.393  [NULL @ 0000000000a8c760] SEI type 5 size 448 truncated at 160
2017.09.25 12:30:40.394  [segment @ 0000000001b7c280] Non-monotonous DTS in output stream 0:0; previous: 4289517832, current: -5426963; changing to 4289517833. This may result in incorrect timestamps in the output file.
Interesting fact from last time: I started both of ffmpeg instances with 10 seconds between them, and the errors appeared exactly with 10 seconds time difference.

Post Reply