The extradata contains the frame size of the subtitles images and the palette.
Signed-off-by: Nicolas George <geo...@nsup.org> --- tools/dvd2concat | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) And with this, we can encode DVDs correctly, and even have the hardcoded subtitles the right color. For muxing the subtitles, some more work to be done, probably: mencoder is still needed. If somebody wants, taking the code from lsdvd and creating a special demuxer that will create a ConcatContext internally would allow us to read DVDs directly. diff --git a/tools/dvd2concat b/tools/dvd2concat index ccc021c4cc..24809fbdf5 100755 --- a/tools/dvd2concat +++ b/tools/dvd2concat @@ -94,6 +94,28 @@ for my $subp (@{$track->{subp}}) { $concat .= "\nstream\nexact_stream_id " . $subp->{streamid} . "\n"; $concat .= "stream_codec dvd_subtitle\n"; $concat .= "stream_meta language " . $subp->{langcode} . "\n" if $subp->{langcode}; + my $extradata = ""; + if ($track->{width} && $track->{height}) { + $extradata .= "size: " . $track->{width} . "x" . $track->{height} . "\n"; + } + if (my $pal = $track->{palette}) { + my @pal; + for my $c (@$pal) { + # Adapted from mplayer/sub/vobsub.c + my $y = ((hex($c) >> 16) & 0xFF); + my $u = ((hex($c) >> 8) & 0xFF) - 128; + my $v = ((hex($c) >> 0) & 0xFF) - 128; + my ($r, $g, $b) = map { int($_ < 0 ? 0 : $_ > 255 ? 255 : $_) } + $y + 1.4022 * $u, + $y - 0.3456 * $u - 0.7145 * $v, + $y + 1.7710 * $v; + push @pal, sprintf "%06x", ($r << 16) | ($g << 8) | $b; + } + $extradata .= "palette: " . join(", ", @pal) . "\n"; + } + if ($extradata ne "") { + $concat .= "stream_extradata " . unpack("H*", $extradata); + } } my $chap_time = 0; for my $chap (@{$track->{chapter}}) { -- 2.33.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".