cubicibo / SUPer

HDMV PGS (BD SUP) subtitle encoder compatible with typesetting effects.
GNU General Public License v3.0
18 stars 3 forks source link

TypeError.......not NoneType #25

Closed KSSW closed 6 months ago

KSSW commented 6 months ago

Hello Cubicibo

There are some errors in the content in the following figure

image image

This is the BDN XML file

cubicibo commented 6 months ago

Hi, I can not access your BDN file, the file is set to private/request access mode. However, I know the issue. Your BDN is missing Width= and Height= fields in the <Graphic> tag.

This is how it should be: <Graphic Width="914" Height="183" X="500" Y="38">01.png</Graphic>

However, your BDN is like this: <Graphic X="500" Y="38">01.png</Graphic I could fix it by loading each image to find out the heigth and width, but this is sub-optimal and non-standard.

Which software did you use to generate such BDN? avs2bdnxml and ass2bdnxml both set Width and Height fields.

KSSW commented 6 months ago

I have updated the link again

KSSW commented 6 months ago

Hi, I can not access your BDN file, the file is set to private/request access mode. However, I know the issue. Your BDN is missing Width= and Height= fields in the <Graphic> tag.

This is how it should be: <Graphic Width="914" Height="183" X="500" Y="38">01.png</Graphic>

However, your BDN is like this: <Graphic X="500" Y="38">01.png</Graphic I could fix it by loading each image to find out the heigth and width, but this is sub-optimal and non-standard.

Which software did you use to generate such BDN? avs2bdnxml and ass2bdnxml both set Width and Height fields.

Generate XML file using Subtitle Edit

Generating PNG files using PGStoBDN

KSSW commented 6 months ago

PGStoBDN Command Line:

PGStoBDN.exe -- input file input. sup -- fullpng -- nodnfixtimes -- output file name prefix output folder

KSSW commented 6 months ago

Thank you. It has been resolved

cubicibo commented 6 months ago

Having no X, Y, Width, and Height is not correct for BDN.

Preprocess your file with this script, and use it like this:
python3 script.py --width 1920 --height 1080 --x 0 --y 0 "C:\path_to_xml\file.xml"

import re
import argparse
from pathlib import Path

ap = argparse.ArgumentParser()
ap.add_argument('bdnxml')
ap.add_argument('--width', default=1920, type=int)
ap.add_argument('--height', default=1080, type=int)
ap.add_argument('--x', default=0, type=int)
ap.add_argument('--y', default=0, type=int)

args = ap.parse_args()
fpa = Path(args.bdnxml)
assert fpa.exists()

with open(fpa, 'r') as f:
    content = f.read()

content = re.subn(r"<Graphic>", f"<Graphic Width=\"{args.width}\" Height=\"{args.height}\" X=\"{args.x}\" Y=\"{args.y}\">", content, flags=re.MULTILINE)[0]
with open(Path.joinpath(fpa.parent, fpa.stem + "2" + fpa.suffix), 'w') as f:
    f.write(content)
KSSW commented 6 months ago

There is one more question

Does it support Scenarist UHD

cubicibo commented 6 months ago

Yes? I do not have Scenarist, but here is what you need to be careful with:

I shall repeat once more, as many people do not understand: BDN PNGs for UHD BD is always 1080p. Never 2160p. If you see BDN or SUP files with 4K resolution, this is wrong and strictly illegal according to BD UHD format.

If you have issue with PES+MUI import in Scenarist UHD, please post the PES+MUI files with the error message.

KSSW commented 6 months ago

Mainly because I didn't explain in detail

Actually, what I want to say is color space image Actually, what I'm saying is not resolution ratio

Scenario UHD generation image

cubicibo commented 6 months ago

Please generate numerous PES + MUI file in Scenarist UHD, with different color spaces, and post the samples. I will add it to SUPer.

EDIT: What happens when you export and re-import a PES+MUI generated from Scenarist, in another project? Does it preserve the color space value?

KSSW commented 6 months ago

I was negligent, it's not a problem with SUPer This problem cannot be solved. Why Because the Scenarist UHD itself generates PES, It will display BT2020 correctly

Using Scenarist UHD version 2.0.0

If we forcefully delete and place it back in Scenarist UHD, it will display undefined Here is the video video

cubicibo commented 6 months ago

Thank you. Then it is metadata stored by Scenarist in the project. The PES contains the YCrCb values already encoded in the color space, so you just loose the "color space" selected field, but the encoding in the PES file will not change.