Log in

View Full Version : HD subtitle ripping (SUPread)


Pages : 1 2 3 4 5 6 7 [8] 9 10 11 12 13 14 15 16

marco_ooo
24th February 2008, 21:49
yep :(

and is it possible to create 720p png's ?

jamos
24th February 2008, 23:00
Hmmm, it sounds interesting. Somebody reports succesfully import in Scenarist but it was about six month ago...
Are you sure Scenarist cannot load PNG24?
I don't want to degrade the picture quality if not neccessary.

Yes I am absolutly sure the manual states 8bit 256 color png.

Pelican9
25th February 2008, 00:00
Yes I am absolutly sure the manual states 8bit 256 color png.

I have to rewrite the whole png part... :(


yep :(

and is it possible to create 720p png's ?

Not easy. I'm afraid it could be too slow... I'll check it out.

jamos
25th February 2008, 00:12
I have to rewrite the whole png part... :(




Not easy. I'm afraid it could be too slow... I'll check it out.

thanks for any work on this. I do request the 720 also.

Pelican9
25th February 2008, 09:51
i changed the picures(png) for the one that subtitle workshop create png 8bit en then the xml works

hope this experiment helps

Could you send me a png which works in Scenarist?

jamos
25th February 2008, 10:15
Could you send me a png which works in Scenarist?

check your pm

vlada
25th February 2008, 11:22
I have one question. Would it be too much work to modify your program to also work with SD (DVD-Video) subtitles? I'm currently working on a GUI which would allow simple conversion between a lot of formats.

I need to do following things:
1) Convert text subtitles to SD SUP (for DVD-Video)
2) Convert DVD subtitles to text (SRT)
3) In future also add support for HD formats

Could you program be useful for me? Or do you know any other programs which can do this for me? I need it to be as simple as possible, my program is targeted mainly at beginners.

I know SubRip, which is unfortunately quite complicated. And SubtitleCreator relies on .NET. I would like my program to be as portable as possible, so I don't want to use any frameworks. So I'm looking for a replacement of these programs. I need to be able to run them from command line. Is (or will be) SUPread suitable for my needs? Or do you have any other suggestions?

Sorry for being slightly off-topic.

Thunderbolt8
25th February 2008, 12:23
any advice how I can improve the OCR results? when I use SUPread to orc a title e.g. the english subs from 'dawn of the dead' blu-ray then there are still many mistakes in each line for most of the time and considering that there are ~1200 lines overall its not too much fun having to go through each line seperately. im not really familiar with the topic of ocring subs, so what else can I do here?

Pelican9
25th February 2008, 13:32
Little bugfix in HD DVD export.

hm10
25th February 2008, 13:33
pelcian i have xml file and pngs that worked me before some month (i tried to found answer how to add subtitle to m2ts) in scenarist but when i tried to mux, just the audio and the video muxed and the pngs didn't

try it...
(i from israel so the write in the pngs in hebrew so leave it...)

Pelican9
25th February 2008, 13:38
any advice how I can improve the OCR results? when I use SUPread to orc a title e.g. the english subs from 'dawn of the dead' blu-ray then there are still many mistakes in each line for most of the time and considering that there are ~1200 lines overall its not too much fun having to go through each line seperately. im not really familiar with the topic of ocring subs, so what else can I do here?
Unfortunately when I wrote the OCR part, every HD DVD used the same font for the subtitles and I wrote an algorythm which works only that font. I'm planning to rewrite the OCR from zero, but until then I can make an image export for external OCR (I read this thread yesterday night and saw the conversation about using external OCR).

Pelican9
25th February 2008, 13:40
pelcian i have xml file and pngs that worked me before some month (i tried to found answer how to add subtitle to m2ts) in scenarist but when i tried to mux, just the audio and the video muxed and the pngs didn't

try it...
(i from israel so the write in the pngs in hebrew so leave it...)

Thank you. I'll check it.
Do you want to make a hebrew abc.png?

P.S.: Why you always write my name pelcian instead of pelican?

hm10
25th February 2008, 13:41
P.S.: Why you always write my name pelcian instead of pelican?

didn't see untill now =\

Thunderbolt8
25th February 2008, 15:44
I tried to follow this instruction here
http://forum.doom9.org/showthread.php?p=1050446#post1050446

but im stuck at step 4 of finereader configuration. I cant find a text block template or such, how can I create one? and how can I be sure it has the resolution of 1920x1080? :S

Rectal Prolapse
25th February 2008, 16:56
Could you send me a png which works in Scenarist?

You can also make your own pngs using the hdsup2bdn tool - just supply it with an HD-DVD .sup file along with the --xml option. The tool has been tested with several HD-DVDs and so far scenarist has accepted them all.

Rectal Prolapse
25th February 2008, 16:57
Thunderbolt: I hope my PM helped you. I think you can save a block template once you set the DPI and the text region.

jamos
25th February 2008, 17:13
You can also make your own pngs using the hdsup2bdn tool - just supply it with an HD-DVD .sup file along with the --xml option. The tool has been tested with several HD-DVDs and so far scenarist has accepted them all.

subtitleworkshop4 beta 2 will export pngs correctly for scenarist also.

Rectal Prolapse
25th February 2008, 17:25
Yeah - although hdsup2bdn is pixel-accurate for converting HD-DVD subtitles to PNGs (to save an OCR step and also avoid finding third party SRTs). It's nice to have many solutions. :)

Also, as far as I can tell, the PNGs made by hdsup2bdn are Rec.709 compliant - that is, the colors converted from YCbCr space to RGB space are done according to the rec.709 spec.

jamos
25th February 2008, 18:37
Yeah - although hdsup2bdn is pixel-accurate for converting HD-DVD subtitles to PNGs (to save an OCR step and also avoid finding third party SRTs). It's nice to have many solutions. :)

Also, as far as I can tell, the PNGs made by hdsup2bdn are Rec.709 compliant - that is, the colors converted from YCbCr space to RGB space are done according to the rec.709 spec.


That may be why subtitleworkshops subtitles are distorted when you import them into scenarist without chaging the colors first.

Pelican9
25th February 2008, 20:57
Also, as far as I can tell, the PNGs made by hdsup2bdn are Rec.709 compliant - that is, the colors converted from YCbCr space to RGB space are done according to the rec.709 spec.

Could you share this fancy converting formula? :)

Rectal Prolapse
25th February 2008, 21:26
Could you share this fancy converting formula? :)

You bet!

void SupPalette::YCrCbToRGB_Rec709()
{
double Kr = 0.2125, Kb = 0.0721;
double Kg = 1.0 - Kr - Kb;

double rp = Y + 2*(Cr-128)*(1.0-Kr);
double gp = Y - 2*(Cb-128)*(1.0-Kb)*Kb/Kg - 2*(Cr-128)*(1.0-Kr)*Kr/Kg;
double bp = Y + 2*(Cb-128)*(1.0-Kb);

R = fabs(rp); G = fabs(gp); B = fabs(bp);
}


Final result is in R, G, and B.

Pelican9
25th February 2008, 23:06
You bet!


These are the colors from Riddick (produced by hdsup2bdn):

0: (238, 14, 13) = (0xee,0x0e,0x0d)
1: ( 16, 16, 16) = (0x10,0x10,0x10)
2: ( 87, 87, 87) = (0x57,0x57,0x57)
3: (138,138,138) = (0x8a,0x8a,0x8a)
4: (159,159,157) = (0x9f,0x9f,0x9d)
5: (171,171,171) = (0xab,0xab,0xab)
6: (192,192,192) = (0xc0,0xc0,0xc0)
7: (186,186,184) = (0xba,0xba,0xb8)
8: (131,131,131) = (0x83,0x83,0x83)
9: ( 33, 33, 33) = (0x21,0x21,0x21)
10: (176,176,176) = (0xb0,0xb0,0xb0)
11: (101,101,101) = (0x65,0x65,0x65)
12: (181,181,179) = (0xb5,0xb5,0xb3)
13: (122,122,122) = (0x7a,0x7a,0x7a)
14: (153,153,153) = (0x99,0x99,0x99)
15: (165,165,165) = (0xa5,0xa5,0xa5)
16: (146,146,146) = (0x92,0x92,0x92)
17: (113,113,113) = (0x71,0x71,0x71)
18: ( 16, 16, 16) = (0x10,0x10,0x10)
...
255: ( 16, 16, 16) = (0x10,0x10,0x10)


Are you sure is this formula good?
I think it isn't. I'm not sure, but:
The Y values on the HD DVD (and on the BD) palette are always between 16 and 235.
Using your formula you never produce black (0,0,0) as seems in the above example.
My guess is you have to decrease the value of Y by 16.
Is fabs() mean absolute value?
If yes, why it needed?

My magic formula is:

rr:=(1164*(Y-16)+1596*(Cr-128)) div 1000;
gg:=((1164*(Y-16)-813*(Cr-128)-391*(Cb-128)) div 1000);
bb:=((1164*(Y-16)+2018*(Cb-128)) div 1000);
if rr>255 then rr:=255; if rr<0 then rr:=0;
if gg>255 then gg:=255; if gg<0 then gg:=0;
if bb>255 then bb:=255; if bb<0 then bb:=0;
Result:=rr+gg shl 8+bb shl 16;

jamos
26th February 2008, 01:15
These are the colors from Riddick (produced by hdsup2bdn):

0: (238, 14, 13) = (0xee,0x0e,0x0d)
1: ( 16, 16, 16) = (0x10,0x10,0x10)
2: ( 87, 87, 87) = (0x57,0x57,0x57)
3: (138,138,138) = (0x8a,0x8a,0x8a)
4: (159,159,157) = (0x9f,0x9f,0x9d)
5: (171,171,171) = (0xab,0xab,0xab)
6: (192,192,192) = (0xc0,0xc0,0xc0)
7: (186,186,184) = (0xba,0xba,0xb8)
8: (131,131,131) = (0x83,0x83,0x83)
9: ( 33, 33, 33) = (0x21,0x21,0x21)
10: (176,176,176) = (0xb0,0xb0,0xb0)
11: (101,101,101) = (0x65,0x65,0x65)
12: (181,181,179) = (0xb5,0xb5,0xb3)
13: (122,122,122) = (0x7a,0x7a,0x7a)
14: (153,153,153) = (0x99,0x99,0x99)
15: (165,165,165) = (0xa5,0xa5,0xa5)
16: (146,146,146) = (0x92,0x92,0x92)
17: (113,113,113) = (0x71,0x71,0x71)
18: ( 16, 16, 16) = (0x10,0x10,0x10)
...
255: ( 16, 16, 16) = (0x10,0x10,0x10)


Are you sure is this formula good?
I think it isn't. I'm not sure, but:
The Y values on the HD DVD (and on the BD) palette are always between 16 and 235.
Using your formula you never produce black (0,0,0) as seems in the above example.
My guess is you have to decrease the value of Y by 16.
Is fabs() mean absolute value?
If yes, why it needed?

My magic formula is:

rr:=(1164*(Y-16)+1596*(Cr-128)) div 1000;
gg:=((1164*(Y-16)-813*(Cr-128)-391*(Cb-128)) div 1000);
bb:=((1164*(Y-16)+2018*(Cb-128)) div 1000);
if rr>255 then rr:=255; if rr<0 then rr:=0;
if gg>255 then gg:=255; if gg<0 then gg:=0;
if bb>255 then bb:=255; if bb<0 then bb:=0;
Result:=rr+gg shl 8+bb shl 16;


try yours out i can test it..hehe

Pelican9
26th February 2008, 12:01
try yours out i can test it..hehe

:confused::confused::confused:

jamos
26th February 2008, 15:52
:confused::confused::confused:

I mean if you can get the subtitles bdn working then I can test it with scenarist. main thing is it needs to be 8bit.

Rectal Prolapse
26th February 2008, 17:23
Pelican9, I guarantee you that the colors are good. Why? Because 16-235 is how all Blu-rays and HD-DVDs are mastered. Sometimes the numbers go beyond these, but that is rare (it is more common on DVDs).

Trust me, they are correct. And will be necessary when you play on properly calibrated video equipment like standalone players on TVs that comply with the SMPTE video standard.

Most people on doom9 watch with PC levels, where video is expanded from 16-235 range to 0-255 (clipping all levels from 0-15 and 236-255). Why do they watch with PC levels? Because they use PC monitors and do not or can not calibrate them to the proper SMPTE video levels. Also, PC applications expect black to be at 0 and not 16 like all Blu-rays and HD-DVDs are mastered at. NOTE: ATI cards in the later catalyst drivers always outputs the incorrect PC levels expansion mode for HD video - whereas NVIDIA cards always output without the incorrect PC levels expansion unless the user overrides it (through VMR procamp controls or the registry tweak).

I guarantee you that the levels are correct in those subtitles...they are NECESSARY for proper playback on standalone players. If PC levels expansion is needed, it is the job of the player to do the 16-235 -> 0-255 expansion for RGB conversion.

I am making the assumption that Scenarist expects all PNGs to follow the video levels standard (16-235). As an experiment, you can import the PNGs made by hdsup2bdn, mux it into the needed m2ts file, then demux the subtitle track using xport then running hdsup2bdn on the resultant .sup file - if the PNGs come out the same, then we know scenarist expects video level ranges.

I can tell you that at least the generation of PNGs is correct from a strict video standard viewpoint - standalone players that are set to output RGB will use 16-235 internally.

Rectal Prolapse
26th February 2008, 17:32
Is fabs() mean absolute value?
If yes, why it needed?

Oh, that's just needed to tell the compiler to correctly round the floating point numbers to the nearest integer.

Pelican9
26th February 2008, 17:33
I mean if you can get the subtitles bdn working then I can test it with scenarist. main thing is it needs to be 8bit.

Please test this png: line0001_8bit.png (http://pel.hu/down/line0001_8bit.png)

Rectal Prolapse
26th February 2008, 17:47
Pelican9, the PNG looks good except for one thing - it is missing the transparency data (maybe the background option is needed?). Otherwise, it is 8 bit and should be accepted by Scenarist - although it may complain (and give up) because of missing transparency indexes. :)

The hdsup2bdn PNGs include transparency data - but there is no option yet to remove that for OCR purposes. :(

Rectal Prolapse
26th February 2008, 17:51
BTW, HDDemuxer from here, http://www.dvd-logic.com/hddemuxer.htm, doesn't seem to output 0 level blacks either - however, I think its output is wrong too - it's probably using the Rec.601 conversion same as DVD.

Pelican9
26th February 2008, 18:35
Pelican9, the PNG looks good except for one thing - it is missing the transparency data (maybe the background option is needed?). Otherwise, it is 8 bit and should be accepted by Scenarist - although it may complain (and give up) because of missing transparency indexes. :)

The trasparency information isn't missing. It has a tRNS chunk with 256 entries.

The hdsup2bdn PNGs include transparency data - but there is no option yet to remove that for OCR purposes. :(

I do the following:
Check the color of every pixel and if the color value is greater than the Level value then I draw a white pixel, if not then I draw a black pixel.
You can see the result when click OCR button in image page.

jamos
26th February 2008, 18:36
Please test this png: line0001_8bit.png (http://pel.hu/down/line0001_8bit.png)

worked perfectly no errors or warnings. I am at work though and cannot test how it looks as i cannot view output remotely. I did not get any transparency warnings like i do when i use subtitleworkshops export either. I have a 720p file so am not sure where the subtitle will show up in it though since its a 1080p. I hope you add a 720p output feature for pngs.

thanks

Pelican9
26th February 2008, 18:40
Pelican9, I guarantee you that the colors are good. Why? Because 16-235 is how all Blu-rays and HD-DVDs are mastered. Sometimes the numbers go beyond these, but that is rare (it is more common on DVDs).

Trust me, they are correct. And will be necessary when you play on properly calibrated video equipment like standalone players on TVs that comply with the SMPTE video standard.

Most people on doom9 watch with PC levels, where video is expanded from 16-235 range to 0-255 (clipping all levels from 0-15 and 236-255). Why do they watch with PC levels? Because they use PC monitors and do not or can not calibrate them to the proper SMPTE video levels. Also, PC applications expect black to be at 0 and not 16 like all Blu-rays and HD-DVDs are mastered at. NOTE: ATI cards in the later catalyst drivers always outputs the incorrect PC levels expansion mode for HD video - whereas NVIDIA cards always output without the incorrect PC levels expansion unless the user overrides it (through VMR procamp controls or the registry tweak).

I guarantee you that the levels are correct in those subtitles...they are NECESSARY for proper playback on standalone players. If PC levels expansion is needed, it is the job of the player to do the 16-235 -> 0-255 expansion for RGB conversion.

I am making the assumption that Scenarist expects all PNGs to follow the video levels standard (16-235). As an experiment, you can import the PNGs made by hdsup2bdn, mux it into the needed m2ts file, then demux the subtitle track using xport then running hdsup2bdn on the resultant .sup file - if the PNGs come out the same, then we know scenarist expects video level ranges.

I can tell you that at least the generation of PNGs is correct from a strict video standard viewpoint - standalone players that are set to output RGB will use 16-235 internally.

I think you mix things.
The Y values shall be in range 16-235, the Cr and Cb valus shall be in range 16-240. No exception.
When you convert it to RGB space the R,G,B values are in range 0-255.
I don't think if Scenarist expects any other range than 0-255 in rgb values.

Pelican9
26th February 2008, 18:42
worked perfectly no errors or warnings. I am at work though and cannot test how it looks as i cannot view output remotely. I did not get any transparency warnings like i do when i use subtitleworkshops export either. I have a 720p file so am not sure where the subtitle will show up in it though since its a 1080p. I hope you add a 720p output feature for pngs.

thanks

Thank you for the test.
The 720p export is ready, but I would like to fix this PNG8 first.

jamos
26th February 2008, 18:50
Thank you for the test.
The 720p export is ready, but I would like to fix this PNG8 first.
I cannot test further with the 1080p source because scenarist blows up when i try to mux due to that its size is bigger than my video size. Can you give me a 720p png8 to test with?

Rectal Prolapse
26th February 2008, 19:12
The Y values shall be in range 16-235, the Cr and Cb valus shall be in range 16-240. No exception.

Yeah, if the YCrCb color is gray, and Y is 16-235, then the RGB will also be 16-235. The output of hdsup2bdn is correct - please check the gray ramp from Digital Video Essentials DVD against a mpeg2 reference decoder (such as the DGMPGIndex program). DGMPGIndex also outputs correct studio (aka video) RGB levels.

However, there is no guarantee that scenarist assumes PNGs are in the 16-235 studio RGB range. One day I will test. :)

BTW, I opened your PNG in photoshop and the background wasn't transparent like it is for the HDDemuxer or hdsup2bdn output - but maybe photoshop only shows transparency for a certain index value? If so, then as long as scenarist accepts it then supread is fine. :)

Pelican9, maybe you can make which color conversion to use as an option? That will allow us to do whatever we want with the colors!

Pelican9
26th February 2008, 19:25
I cannot test further with the 1080p source because scenarist blows up when i try to mux due to that its size is bigger than my video size. Can you give me a 720p png8 to test with?

This is very ugly, but good enough for testing: http://pel.hu/down/line0001_720p.png

Pelican9
26th February 2008, 19:28
Yeah, if the YCrCb color is gray, and Y is 16-235, then the RGB will also be 16-235. The output of hdsup2bdn is correct - please check the gray ramp from Digital Video Essentials DVD against a mpeg2 reference decoder (such as the DGMPGIndex program). DGMPGIndex also outputs correct studio (aka video) RGB levels.

However, there is no guarantee that scenarist assumes PNGs are in the 16-235 studio RGB range. One day I will test. :)

I hope, somebody do this test with both type of the pngs and report the result.

BTW, I opened your PNG in photoshop and the background wasn't transparent like it is for the HDDemuxer or hdsup2bdn output - but maybe photoshop only shows transparency for a certain index value? If so, then as long as scenarist accepts it then supread is fine. :)

I think PS cannot handle the PNG8 with more than one transparent color. Fireworks works well. Even the pure Windows picture and fax viewer displays it correctly

Pelican9, maybe you can make which color conversion to use as an option? That will allow us to do whatever we want with the colors!

You are right, this will be the best solution.

jamos
26th February 2008, 20:14
This is very ugly, but good enough for testing: http://pel.hu/down/line0001_720p.png

no warnings or errors on import and muxed successfully.

Pelican9
26th February 2008, 20:20
no warnings or errors on import and muxed successfully.

Thank you. I'm thinking to rewrite the whole PNG stuff in SUPread from 24 bit to 8 bit so you have to wait a little for the next version.

Rectal Prolapse
26th February 2008, 20:58
Yeah I think you're right about photoshop not handling all the transparent colors. Damn!

Anyways, thanks again for your supread updates! Color conversion options would also be great for OCRing too - like an option to push certain range of colors to pure white and everything else to black (to get rid of the outlines around text, for example).

manusse
26th February 2008, 21:22
I'm thinking to rewrite the whole PNG stuff in SUPread from 24 bit to 8 bit so you have to wait a little for the next version.

Maybe you could use this one: http://wiki.lazarus.freepascal.org/PascalMagick

Manusse

Pelican9
26th February 2008, 22:25
Yeah I think you're right about photoshop not handling all the transparent colors. Damn!

Anyways, thanks again for your supread updates! Color conversion options would also be great for OCRing too - like an option to push certain range of colors to pure white and everything else to black (to get rid of the outlines around text, for example).

What format will be useful?
PNG8?
What size?
Full HD or subtitle only?

jamos
26th February 2008, 22:28
ok it worked on playback but the subtitle was basically transparent except for the border. would like to see pure white with no border as in the original.

Pelican9
26th February 2008, 22:34
ok it worked on playback but the subtitle was basically transparent except for the border. would like to see pure white with no border as in the original.

I know, I know, that was the reason why I said it's ugly...

Rectal Prolapse
26th February 2008, 22:44
Pelican9, I'm not sure - people that wish to only use OCR don't really need full HD. Their OCR software may not support PNGs. I guess those can all be options - but that makes things complicated. :(

Rectal Prolapse
26th February 2008, 22:46
New hdsup2bdn:

http://www.sendspace.com/file/1oij4n

Allowed options:
--help produce help message
--version print version number
--original output PNG images in the original size (suitable for
OCR)
--fullpng output 1920x1080 PNG images [DEFAULT]
--nobdnfixtimes do not divide BDN times by 1.001 (BDN output only)
--bdnfixtimes divide BDN times by 1.001 (BDN output only) [DEFAULT]
--srtfixtimes divide SRT times by 1.001 (SRT output only)
--nosrtfixtimes divide SRT times by 1.001 (SRT output only) [DEFAULT]
--framerate arg frame rate [DEFAULT: 29.97]
--input-file arg input file
--srt output SRT file
--xml output Scenarist HDMV BDN file
--forcedsubs make all subtitles forced (BDN output only)
--dropframes flag all subtitle times as drop frames (BDN output
only)
--nopng don't generate any PNGs
--blackbackground always make the transparent background black (index 0)
[RGB 0,0,0]
--blackemphasis make the HD-DVD emphasis pixels (index 2 and 3) black
--enhancecontrast make all pixels with Y < 127 black, and pixels with Y
>= 128 white (easier to OCR). Also forces background to
black.


Example usage:

C:\My Downloads\Subtitles\Mr. Bean's Holiday>C:\Projects\Blu-ray\hdsup2bdn\release\hdsup2bdn.exe --xml --enhancecontrast FEATURE_1_MERGED.Subpicture.14.sup
XML (BDN) output selected
Force all pixels to black except the main pattern
framerate defaults to 29.97
Input files are: FEATURE_1_MERGED.Subpicture.14.sup
hdsup2bdn version 1.04


--enhancecontrast forces all colors with Y < 127 to be black, and all other colors to be white. This is a cheap hack but hopefully works for most people!

Rectal Prolapse
26th February 2008, 22:53
Also, the --original option for hdsup2bdn can be really handy for OCRing as well - it doesn't output a full 1920x1080 picture, instead only what the subtitle uses.

Pelican9
26th February 2008, 22:58
New hdsup2bdn:

--enhancecontrast forces all colors with Y < 127 to be black, and all other colors to be white. This is a cheap hack but hopefully works for most people!

In SUPread the cut level value give me the best result around 140 but some subtitle needs around 200... that's why I've put it into the Options

Anyway, why don't you make an own OCR?

What happened with Taktaal's program? Is he still develop his program?

Why don't we make a really cool tool together? :)

Rectal Prolapse
26th February 2008, 23:11
ahh 140 or 200? Damn - maybe I'll have to add *another* option to make the program even more confusing. :)

I think Taktaal's suprip is at version 0.93. It's probably no more than a month old!

I know nothing about OCRing though - it's too complicated for me!