Recoding videos with subtitles, I often have problems with subtitle streams, because the dts starts again with 0 after some time (I think, it is at jumping from DVD layer 1 to 2, but I'm not sure).
There is code in ffmpeg.c to handle such nonmonolithic dts errors in video and audio streams, but for subtitle streams it is not used. Some years ago the dts time fix has been used also for subtitle streams, but this has been removed while changing the code in ffmpeg.c. There is a bug report with an (old) patch for this in the ffmpeg, but this has never found its way to the release. I've adapted the patch for current ffmpeg and it works like a charm. Please add it to your repository. diff -u fftools.orig/ffmpeg.c fftools/ffmpeg.c --- fftools.orig/ffmpeg.c 2018-06-20 09:00:12.749632351 +0200 +++ fftools/ffmpeg.c 2018-06-20 09:00:29.262284733 +0200 @@ -772,7 +772,7 @@ - FFMIN3(pkt->pts, pkt->dts, ost->last_mux_dts + 1) - FFMAX3(pkt->pts, pkt->dts, ost->last_mux_dts + 1); } - if ((st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO || st->codecpar- >codec_type == AVMEDIA_TYPE_VIDEO) && + if ((st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO || st->codecpar- >codec_type == AVMEDIA_TYPE_VIDEO || st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) && pkt->dts != AV_NOPTS_VALUE && !(st->codecpar->codec_id == AV_CODEC_ID_VP9 && ost->stream_copy) && ost->last_mux_dts != AV_NOPTS_VALUE) { Regards Markus
--- fftools.orig/ffmpeg.c 2018-06-20 09:00:12.749632351 +0200 +++ fftools/ffmpeg.c 2018-06-20 09:00:29.262284733 +0200 @@ -772,7 +772,7 @@ - FFMIN3(pkt->pts, pkt->dts, ost->last_mux_dts + 1) - FFMAX3(pkt->pts, pkt->dts, ost->last_mux_dts + 1); } - if ((st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) && + if ((st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) && pkt->dts != AV_NOPTS_VALUE && !(st->codecpar->codec_id == AV_CODEC_ID_VP9 && ost->stream_copy) && ost->last_mux_dts != AV_NOPTS_VALUE) {
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel