Quantcast

How to associate a palette to DVD subtitle ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to associate a palette to DVD subtitle ?

Thierry Lelegard

Hello,

I have been playing a lot with DVD subtitles and ffmpeg recently. When getting well-formed
MKV files, the subtitle palette seems to be part of the file as "codec private data" in the
S_VOBSUB stream. When the ffmpeg overlay filter processes the subtitles, the characters
are rendered with their expected appearance, most of the time white with a black outline.

With VOB files from DVD's, the palette is in the IFO file. When ffmpeg extracts the DVD
subtitle stream, it does not have the palette and the subtitles are displayed with ugly colors
(black with yellow outline for instance). The same effect is observed with ffplay.

My final goal is to hardcode the subtitles in the video but this is a general question about
palette handling in ffmpeg.

I am looking for a way to make ffmpeg use or guess the correct palette. Is there any?

There are several possibilities.

First, I know how to extract the palette information from the IFO file. Is there a way to
specify the explicit palette content to ffmpeg? In a data file? With some parameter or filter?

Second, VLC always displays the DVD subtitles with the right color. On a given file,
either a VOB file or an MKV which is produced by a command such as the following
one, VLC displays the DVD subtitle stream in white with black outline (correct) while
ffplay or ffmpeg/overlay displays them in black with yellow outline (not correct).

Command I used to extract part of a VOB file into a MKV:
ffmpeg -i VTS_01_1.VOB -map 0:1 -codec:v copy -map 0:4 -codec:a copy -map 0:15 -codec:s copy -t 200 -y cat.mkv

So, VLC knows a way to find or guess the palette. How can I make ffmpeg behave
the same way?

If there is currently no way to do that, would it be eligible as new feature?
At least a way to specify the explicit palette content? Some parameter with
the 16*4 bytes in hexadecimal can be sufficient. Or from a data file.
What could be the best way, a parameter to the overlay filter or a new
dedicated filter to add private codec data to a stream?

Thanks for your feedback.
-Thierry

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to associate a palette to DVD subtitle ?

Nicolas George
Le jour du Génie, an CCXXI, Thierry Lelegard a écrit :
> I am looking for a way to make ffmpeg use or guess the correct palette. Is
> there any?

There is a "palette" option to the dvdsub decoder. It has the same syntax as
the "palette:" line in VOBSUB IDX files: a comma-separated list of 16
24 bits RGB values. It should do the trick.

Regards,

--
  Nicolas George

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

signature.asc (853 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to associate a palette to DVD subtitle ?

Thierry Lelegard
Thank you Nicolas, I did not see this one.

I will code the palette extraction from the IFO and I will try this
option in the ffmpeg command I generate.

Sorry if this question seems silly, but is the command line syntax simply:

  ffmpeg .. -i file -palette "xxxxxx,xxxxxx,..,xxxxxx" ...

Does ffmpeg recognize that -palette applies to the dvdsub decoder or is
there anything else to add?

Thanks for your help.
-Thierry

----- Mail original -----

> De: "Nicolas George" <[hidden email]>
> À: "FFmpeg user questions" <[hidden email]>
> Envoyé: Jeudi 19 Septembre 2013 19:19:39
> Objet: Re: [FFmpeg-user] How to associate a palette to DVD subtitle ?
>
> Le jour du Génie, an CCXXI, Thierry Lelegard a écrit :
> > I am looking for a way to make ffmpeg use or guess the correct
> > palette. Is
> > there any?
>
> There is a "palette" option to the dvdsub decoder. It has the same
> syntax as
> the "palette:" line in VOBSUB IDX files: a comma-separated list of 16
> 24 bits RGB values. It should do the trick.
>
> Regards,
>
> --
>   Nicolas George
>
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to associate a palette to DVD subtitle ?

Nicolas George
Le jour du Labour, an CCXXI, Thierry Lelegard a écrit :
> I will code the palette extraction from the IFO and I will try this
> option in the ffmpeg command I generate.
>
> Sorry if this question seems silly, but is the command line syntax simply:
>
>   ffmpeg .. -i file -palette "xxxxxx,xxxxxx,..,xxxxxx" ...
>
> Does ffmpeg recognize that -palette applies to the dvdsub decoder or is
> there anything else to add?

It should, but input options must come before the corresponding file.

> ----- Mail original -----

Please remember not to top-post.

Regards,

--
  Nicolas George

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

signature.asc (853 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to associate a palette to DVD subtitle ?

Thierry Lelégard
In reply to this post by Nicolas George
Le 19/09/2013 19:19, Nicolas George a écrit :
> Le jour du Génie, an CCXXI, Thierry Lelegard a écrit :
>> I am looking for a way to make ffmpeg use or guess the correct palette. Is
>> there any?
> There is a "palette" option to the dvdsub decoder. It has the same syntax as
> the "palette:" line in VOBSUB IDX files: a comma-separated list of 16
> 24 bits RGB values. It should do the trick.
>
I confirm that the following works:

1) Extract the palette info (16 x 4 bytes) from the VTS_xx_0.IFO file.
See http://dvd.sourceforge.net/dvdinfo/ifo.html
Follow the chain VTS_PGCI -> VTS_PGC -> palette in PGC

2) Convert the palette from YUV (0, Y, Cr, Cb) to RGB (0, R, G, B).
See http://en.wikipedia.org/wiki/Yuv and search for 'Integer operation of ITU-R standard for YCbCr(8 bits per channel) to RGB888'

3) Use command ffmpeg -palette rrggbb,rrggbb,...,rrggbb -i input ...

And you get the correct DVD subtitle colors.
Thanks to Nicolas (again) for pointing to the right options.
-Thierry

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Loading...