Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue about using BDSup2Sub #5

Open
MonoS opened this issue Jan 22, 2023 · 9 comments
Open

Issue about using BDSup2Sub #5

MonoS opened this issue Jan 22, 2023 · 9 comments

Comments

@MonoS
Copy link

MonoS commented Jan 22, 2023

Hi quietvoid, i want to inform you that in the past i had quite some problem using BDSup2Sub resulting in cropped output, wrong colors/shade and missing subpic, that is one of the reason why i developed SupMover.
I was also thinking about if it could be a good idea to change the luminance/color value at a palette level instead at the image level so that the functionality of your tool would be a less lossy transformation, from what i can read from your code (i'm not experienced in rust) it seems you lower the color of all the RGB channel by the specified percentage, or with a fixed color, and save it, am i right?
Just for information PGS/Sup subtitle use a YCbCrA palette (from SubtitleEdit's code it seems that the matrix is determined from the video) in tv level (16-235/240) so do you think we could achieve the same effect multiplying the value from the Y channel in every paletted color with a percentage and then clamping to 16-235 range? Do you think we should take into account the Alpha value?

@quietvoid
Copy link
Owner

I'm aware that BDSup2Sub has limitations, it's just the only option I found at the time that could be easily exported/imported as images.
I've yet to find a complete library which allows this with a simple API.

@MonoS
Copy link
Author

MonoS commented Jan 22, 2023

If my idea about modifying the palette make sense i can make a dll for you, but from what i can see from your code you are more that capable of doing that by yourself, but if you need help with the sup file structure i've just uploaded a kaitai descriptor in my repo.

@quietvoid
Copy link
Owner

I had looked at other existing projects that dealt with subs and never really understood how this color change would be done.
https://github.com/cubicibo/SUPer
https://github.com/wswartzendruber/pgs-tools

I just need to look more into this.

@MonoS
Copy link
Author

MonoS commented Jul 23, 2023

Hi, last day i've implemented this functionality inside my application, you can see the commit here MonoS/SupMover@079f738
I didn't implement --fixed and --color functionality as i don't understand how they should work with the YCbCrA palette.

@quietvoid
Copy link
Owner

I didn't implement --fixed and --color functionality as i don't understand how they should work with the YCbCrA palette.

Assuming the matrix is fixed, you could always round trip to RGB, set color and convert back to YCbCr.

@Julianwan
Copy link

hey quietvoid, I'm having lots of issues with BDSup2Sup (primarily because I'm on Mac), have you seen this rust solution for exporting images:
https://github.com/robjtede/sup-decode

@quietvoid
Copy link
Owner

hey quietvoid, I'm having lots of issues with BDSup2Sup (primarily because I'm on Mac), have you seen this rust solution for exporting images: https://github.com/robjtede/sup-decode

I'm not sure if the actual issue is the images exporting or also the re-importing into a SUP file.
If someone has problematic files, I can look into it.

@Julianwan
Copy link

hey quietvoid... the issue was me. I kept receiving the error "BDSup2Sub should be in the same directory as this executable." on the release build. Turns out I was putting the .jar in the wrong spot, and also using the wrong jar (I was using a Mac BDSup2Sup; but actually using the windows BDSup2Sup.jar is what worked.

FWIW, here's how I solved my issue:

I built a release of subtitle_tonemap and installed it to my path using cargo.

I edited main.rs to print out where the code expected BDSup2Sup512.jar was searching.

// Make sure jar file exists in the same directory
    let mut java_jar = env::current_exe()?;
    java_jar.pop();
    java_jar.push("BDSup2Sub512.jar");
    println!("Searching for java jar at {:?}", java_jar);
    if !java_jar.exists() {
        let current_dir: PathBuf = env::current_dir()?;
        println!("Java jar file does not exist in {:?}", current_dir);
        return Ok(());
    }

Realized I needed to add the BDSup2Sup512.jar to /Users/{username}/.cargo/bin/BDSup2Sub512.jar

Got a few imagex errors using the Mac .jar, swapped it with a windows .jar and poof, everything worked.

So for Mac users, this may be helpful. And in general printing the path something is searching is helpful for newb users when using external dependencies.

Apologies for being vague above with my Mac bdsup2sup issues and it appears everything works fine now.

Thank you for making this!

@angelgraves13
Copy link

Easy fix...use the new beta version of BDSup2Sub and export the subtitle as it will have no warnings or issues.

Open the new exported SUP in the old version and you will see there are no more warnings.

Now you can tone map the subtitle without issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants