[FFmpeg-devel] ffmpeg patch for nonmonolithic increase dts error in subtitle

Markus Kohm markus.kohm at gmx.de
Wed Jun 20 10:09:11 EEST 2018


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ffmpeg-subtitle-dts-correction-24eb912.diff
Type: text/x-patch
Size: 758 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20180620/faea3cc6/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20180620/faea3cc6/attachment.sig>


More information about the ffmpeg-devel mailing list