[FFmpeg-devel] [PATCH 2/2] avcodec/libzvbi-teletextdec: formatted ass output

Marton Balint cus at passwd.hu
Tue May 8 02:07:17 EEST 2018



On Mon, 7 May 2018, Aman Gupta wrote:

> 
> 
> On Mon, May 7, 2018 at 12:50 PM, Aman Gupta <ffmpeg at tmm1.net> wrote:
> 
>
>       On Sun, May 6, 2018 at 2:05 PM, Marton Balint <cus at passwd.hu> wrote:
>             Inspired by the VideoLAN text decoder and its port to FFmpeg made by Aman
>             Gupta.
> 
> 
> Thanks for incorporating my changes.
> 
> I ran some tests, and colors work as expected. Positioning also works well, and is also pretty close to my version.
> 
> 
> I found that some live streams are not chopping empty lines correctly. I see extra newlines at the end:
> 
>   Dialogue: 0,0:13:21.66,9:59:59.99,Default,,0,0,0,,{\an1}Simson,\hPeter\hHartcher,\hRobyn\hParker \Nand\hBenjamin \N \N \N
> 
> Here's a sample which shows extra newlines: https://s3.amazonaws.com/tmm1/teletext/capture_live1.mpg

This is kind of intentional, in this case the new lines are kept to 
position the subtitles a bit higher, and not to the very bottom of the 
screen, to keep the rough position of the teletext subtitles. At first I 
used \pos as well, but it only worked once per line for me, so I had to 
use some kind of newline-positioning anyway, and using native vertical 
alignment instead of \pos seemed nicer. (E.g. it allows the user to change 
left/right alignment text margins more easily in the headers or by 
an override).

> 
> It also looks like the "erase page" command is not being processed, which causes stale captions to stay on the screen in some cases.
> This is especially confusing when part of an old caption remains on one line, but then newer captions appear on another line.
> 
> Here's a sample that shows lines not being cleared correctly: https://s3.amazonaws.com/tmm1/teletext/simple.mpg
> 
> 
> With this sample, for instance, my decoder produces:
> 
> Dialogue: 0,0:00:01.90,9:59:59.99,Default,,0,0,0,,{\an8}{\pos(192,213)}{\c&HFFFFFF&}and this, as you rightly say,\N
> Dialogue: 0,0:00:01.94,9:59:59.99,Default,,0,0,0,,{\an8}{\pos(192,213)}{\c&HFFFFFF&}and this, as you rightly say,\N{\an8}{\pos(192,231)}        {\c&HFFFFFF&}is American.\N
> Dialogue: 0,0:00:04.86,9:59:59.99,Default,,0,0,0,,
> Dialogue: 0,0:00:04.94,9:59:59.99,Default,,0,0,0,,{\an8}{\pos(192,231)}{\c&HFFFFFF&}It's rather nicely made.\N
> Dialogue: 0,0:00:06.62,9:59:59.99,Default,,0,0,0,,
> Dialogue: 0,0:00:06.70,9:59:59.99,Default,,0,0,0,,{\an8}{\pos(192,213)}{\c&HFFFFFF&}It's got this fabulous\N
> Dialogue: 0,0:00:06.74,9:59:59.99,Default,,0,0,0,,{\an8}{\pos(192,213)}{\c&HFFFFFF&}It's got this fabulous\N{\an8}{\pos(192,231)}   {\c&HFFFFFF&}cast finial here\N
> Dialogue: 0,0:00:10.34,9:59:59.99,Default,,0,0,0,,
> Dialogue: 0,0:00:10.42,9:59:59.99,Default,,0,0,0,,{\an8}{\pos(192,213)}{\c&HFFFFFF&}of a very muscular figure\N
> Dialogue: 0,0:00:10.46,9:59:59.99,Default,,0,0,0,,{\an8}{\pos(192,213)}{\c&HFFFFFF&}of a very muscular figure\N{\an8}{\pos(192,231)} {\c&HFFFFFF&}pulling this medallion.\N
> Dialogue: 0,0:00:15.50,9:59:59.99,Default,,0,0,0,,
> Dialogue: 0,0:00:15.58,9:59:59.99,Default,,0,0,0,,{\an8}{\pos(192,213)}{\c&HFFFFFF&}So it's got strength to it. It's a\N
> Dialogue: 0,0:00:15.62,9:59:59.99,Default,,0,0,0,,{\an8}{\pos(192,213)} {\c&HFFFFFF&}So it's got strength to it. It's a\N{\an8}{\pos(192,231)}{\c&HFFFFFF&}really characterful piece of silver.\N
> Dialogue: 0,0:00:19.14,9:59:59.99,Default,,0,0,0,,
> 
> And the decoder in this patch produces:
> 
> Dialogue: 0,0:00:02.02,9:59:59.99,Default,,0,0,0,,{\an2}and\hthis,\has\hyou\hrightly\hsay, \Nis\hAmerican. \N
> Dialogue: 0,0:00:05.02,9:59:59.99,Default,,0,0,0,,{\an2}and\hthis,\has\hyou\hrightly\hsay, \NIt's\hrather\hnicely\hmade. \N
> Dialogue: 0,0:00:06.82,9:59:59.99,Default,,0,0,0,,{\an2}It's\hgot\hthis\hfabulous \Ncast\hfinial\hhere \N
> Dialogue: 0,0:00:10.54,9:59:59.99,Default,,0,0,0,,{\an2}of\ha\hvery\hmuscular\hfigure \Npulling\hthis\hmedallion. \N
> Dialogue: 0,0:00:15.70,9:59:59.99,Default,,0,0,0,,{\an2}So\hit's\hgot\hstrength\hto\hit.\hIt's\ha \Nreally\hcharacterful\hpiece\hof\hsilver. \N
> Dialogue: 0,0:00:19.30,9:59:59.99,Default,,0,0,0,,{\an2}So\hit's\hgot\hstrength\hto\hit.\hIt's\ha \NBut\hmost\himportant\hof\hall, \N
> 
> At the ~5s mark, the text on the screen should say "It's rather nicely made", but this decoder still displays the line "and this as you rightly say" from the previous sentence.

The mix of different subtitles showing up seems like a libzvbi bug :( ... 
I will try to send a patch to sourceforge hoping it will get picked up and 
integrated to a future release...

Also there is a slight difference in how empty subtitles are forwarded. 
For empty subtitles I always used AVSubtitleRect type AVSUBTITLE_NONE, you 
used AVSUBTITLE_ASS. I prefer AVSUBTITLE_NONE, because with it
ffmpeg -fix_sub_duration creates a valid ass file without empty 
subtitles.

> I also have several other samples which use various features, available at the same URL:
> 
> capture_formatting1.mpg
> capture_formatting2.mpg
> capture_formatting3.mpg
> capture_live1.mpg
> capture_live2.mpg
> capture_notCaptionedMessage.mpg
> capture_threeLines1.mpg
> capture_threeLines2.mpg
> capture_threeLines3.mpg
> capture_threeLines4.mpg
> capture_yOffset1.mpg
> three.ts
> four.ts

I will have a look at those, thanks for your feedback.

Regards,
Marton


More information about the ffmpeg-devel mailing list