[FFmpeg-devel] [PATCH] Pass "forced" flag to dvdsubenc

Anshul anshul.ffmpeg at gmail.com
Sun May 18 23:03:45 CEST 2014

On May 19, 2014 1:58:21 AM IST, Anshul <anshul.ffmpeg at gmail.com> wrote:
>On May 18, 2014 6:59:28 PM IST, Oliver Fromme <oliver at fromme.com>
>>I hope this is the right place to submit a patch.
>>Please let me know if there's something wrong with it.
>>The patch was made against a recent snapshot downloaded
>>from ffmpeg.org on 2014-05-16.  I'm not familiar with
>>git at all (my version-control background is rather cvs,
>>subversion and perforce), so I just used "diff -u".
>>The patch is fairly trivial and small, so it shouldn't
>>be an issue.
>>The problem is that I'm working with a lot with subtitle
>>tracks that are either completely forced or that contain
>>some captions that are forced (and some that are not).
>>At the moment, ffmpeg and libavcodec don't support this
>>very well.  I'll try to improve this in small steps.
>>My first observation when looking at the source code was
>>that there is already a flag:  AV_SUBTITLE_FLAG_FORCED.
>>However, at the moment this flag is only set by pgssubdec
>>dvdsubdec, but it is never used anywhere.  That means,
>>if subtitles are read from a PGS or VOBSUB track and
>>then later written to the destination file, the "forced"
>>flag is lost.
>>The patch presented below causes the flag to be used when
>>writing a VOBSUB track ("dvdsub" in ffmpeg parlance), so
>>the flag is preserved.  I've tested the patch with various
>>VOBSUB tracks successfully.
>>By the way, a good way for testing VOBSUB subtitles files
>>(i.e. pairs of *.idx and *.sub files) is the BDSup2Sub
>>utility.  It's written in Java and supports both a GUI
>>and a pure command-line interface (I only use the latter).
>>The good thing about it is that it has a very strict
>>parser.  If anything is wrong with the VOBSUB input, it
>>prints appropriate warnings and error messages.  It also
>>prints the number of captions marked as forced, and allows
>>to extract them separately.  ffmpeg doesn't support this
>>yet, but I'll try to implement something like that when
>>I have some spare time.  Yes, I know, there already is the
>>-forced_subs_only option, but it's specific to the PGS
>>decoder, and it doesn't work anyway because of a bug.
>>Best regards
>>   Oliver
>>PS:  Here's the patch to use the "forced" flag in dvdsubenc:
>>--- libavcodec/dvdsubenc.c.orig	2014-04-25 19:20:06.000000000 +0200
>>+++ libavcodec/dvdsubenc.c	2014-05-16 23:35:29.000000000 +0200
>>@@ -259,6 +259,7 @@
>>     AVSubtitleRect vrect;
>>     uint8_t *vrect_data = NULL;
>>     int x2, y2;
>>+    int forced = 0;
>>     if (rects == 0 || h->rects == NULL)
>>         return AVERROR(EINVAL);
>>@@ -267,6 +268,12 @@
>>             av_log(avctx, AV_LOG_ERROR, "Bitmap subtitle
>>             return AVERROR(EINVAL);
>>         }
>>+    /* Mark this subtitle forced if any of the rectangles is forced.
>>+    for (i = 0; i < rects; i++)
>>+        if ((h->rects[i]->flags & AV_SUBTITLE_FLAG_FORCED) != 0) {
>>+            forced = 1;
>>+            break;
>>+        }
>>     vrect = *h->rects[0];
>>     if (rects > 1) {
>>@@ -371,7 +378,7 @@
>>     bytestream_put_be16(&q, offset1);
>>     bytestream_put_be16(&q, offset2);
>>-    *q++ = 0x01; // start command
>>+    *q++ = forced ? 0x00 : 0x01; // start command
>>     *q++ = 0xff; // terminating command
>>     // send stop display command last
>>ffmpeg-devel mailing list
>>ffmpeg-devel at ffmpeg.org
>In dvb subtitle rfc,  I dont find anything related to force flag.
>If you are following some documentation then can u please point
>It would be better if you also share the input, where forced flag is

Sry I was looking in wrong rfc its dvd not dvb.

I am really wondering how start command set to 0 is forcing to display that rectangle,  logicaly it should not show any display till its set to 1. But cant say about anything surely till I read some rfc.


Sent from my Android device with K-9 Mail. Please excuse my brevity.

More information about the ffmpeg-devel mailing list