magiruuvelvet / jimaku-editor

A work-in-progress subtitle editor with first class Japanese language support. Renders subtitle images into a BDSup (PGS) file. Already functional for many use cases.
6 stars 0 forks source link

pgssup Stopping at Subtitle 1021 #6

Closed Masaki-Developer closed 1 year ago

Masaki-Developer commented 1 year ago

I hope this email finds you well. I am reaching out to report a recurrent issue I've experienced with the pgssup tool.

Description of the Issue: When I attempt to generate PGS subtitles using pgssup, the process consistently encounters an error at subtitle number 1021. Specifically, the tool reports the following error message:

javascript Copy code Error: file "/home/jimaku-editor/tests/spider/1021.png" could not be opened Despite verifying the existence, location, and permissions of the file, the issue persists.

Steps to Reproduce:

Run pgssup with an XML file referencing the subtitle PNG files. Observe the process halt at subtitle 1021 with the error mentioned above. Additional Information:

All PNG files, including "1021.png", are confirmed to be present in the specified directory. The permissions of the PNG files appear to be correct. I am running pgssup on Ubuntu 22.04.3 LTS. I would greatly appreciate any insights, suggestions, or fixes you might have regarding this issue.

Thank you for your time and consideration. I look forward to your response.

Warm regards,

magiruuvelvet commented 1 year ago

Can you check the PNG with the file command? (file 1021.png) Maybe the file is corrupt or in the wrong format, which should not happen. If possible, could you share the affected PNG file, and the generated XML file?

EDIT: I just remembered that PGS frames have a size limit, at least in this encoder. The size limit refers to the raw RGBA pixel size in bytes. The only thing you can do is to crop the image to remove as much border as possible. The PNG generator leaves some border behind. If the image is still to large, start to resize the image 1 pixel at a time until the error goes away. I never managed to fix this.

I did this cropping and resizing myself when generating a lot of subtitles in the past. The results can still look good when the size difference is small enough.

EDIT2: Another solution, which you can also try before resizing the images, is to reduce the color palette even further. The renderer already tries to keep the color palette small, but big subtitle frames might not fit into the current limitations of the PGS encoder which is used. See the color-limit option as documented in the README.

magiruuvelvet commented 1 year ago

I discovered a memory leak. The system is running out of file descriptors as the read PNG files are not closed. This issue isn't noticeable on systems which allow millions of file descriptors per process. Working on a fix.

magiruuvelvet commented 1 year ago

Should be fixed with bde5ce9be76281cd88907bf89bbe57dcc5a2f3ca