[FFmpeg-devel] Question: about "igndts" flag, and how to handle DTS output problems.
Daniel Cantarín
canta at canta.com.ar
Thu Mar 2 21:16:18 EET 2023
I'm having trouble with DTS values in a single dvbsub stream while
receiving LIVE MPEGTS with muxed video, audio, subs, and other data
(like scte35) over multicast UDP. I'm doing transcoding tasks, and then
output that to another MPEGTS stream that feeds other services. This are
the problems I'm facing:
```
(...)
[mpegts @ 0x5591147cf280] Non-monotonous DTS in output stream 0:3;
previous: 5729374, current: 5292077; changing to 5729375. This may
result in incorrect timestamps in the output file.
[mpegts @ 0x5591147cf280] Non-monotonous DTS in output stream 0:3;
previous: 5729375, current: 5293810; changing to 5729376. This may
result in incorrect timestamps in the output file.
[mpegts @ 0x5591147cf280] Non-monotonous DTS in output stream 0:3;
previous: 5729376, current: 5300564; changing to 5729377. This may
result in incorrect timestamps in the output file.
[mpegts @ 0x5591147cf280] Non-monotonous DTS in output stream 0:3;
previous: 5729377, current: 5302255; changing to 5729378. This may
result in incorrect timestamps in the output file.
(...)
```
This has the effect that, later in my work's pipeline, subtitles give
trouble with players.
I would like to avoid this ffmpeg DTS correction ("with the error", if
you prefer that interpretation), and thus I tested lots of options
without success, including the `+igndts` flag. It actually doesn't seem
to do anything. So I went to check what it actually does, and found
this.
```
user at computer:/path/to/ffmpeg/repo$ grep -rn "AVFMT_FLAG_IGNDTS" .
2>/dev/null
./libavformat/options_table.h:48:{"igndts", "ignore dts", 0,
AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_IGNDTS }, INT_MIN, INT_MAX, D,
"fflags"},
./libavformat/avformat.h:1228:#define AVFMT_FLAG_IGNDTS 0x0008
///< Ignore DTS on frames that contain both DTS & PTS
./libavformat/demux.c:963: if ((s->flags & AVFMT_FLAG_IGNDTS) &&
pkt->pts != AV_NOPTS_VALUE)
user at computer:/path/to/ffmpeg/repo$
```
It seems it's only used on demux (input), and not at mux time (output).
So I went to check what's going on with that "Non-monotonous" thing, and
found that `fftools/ffmpeg_mux.c` has a code in line 108 where it checks
for DTS values without any consideration for skipping such check.
With this in mind, I would like to ask a some questions here about my
situation, which I'm unsure if it's worthy of a ticket.
1. Is there a way to ignore this DTS issue at mux time and just output
whatever DTS is on the packet? Sounds like "igndts" would be useful at
output too, by just adding it to that line 108 check. But perhaps there
are other way to achieve it.
2. Do you know of some way I could fix this my own way without this
ffmpeg mux auto-fix? I would do some setpts filter magic if I could, but
as this is a subtitle stream I have no way to use filters on it. And
being live streams is really troublesome to apply fixes: I'm trying
several other tools as proxies right now.
3. I see another code before that 108 line. It involves
`s->oformat->flags & AVFMT_TS_NONSTRICT`. But I'm not sure of how to
toggle AVFMT_TS_NONSTRICT from command line to see its effects. Is it
perhaps "-strict experimental"?
Thanks,
Daniel.
More information about the ffmpeg-devel
mailing list