Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > General > Subtitles

Reply
 
Thread Tools Search this Thread Display Modes
Old 19th May 2023, 17:33   #1  |  Link
cubicibo
Registered User
 
Join Date: Feb 2022
Posts: 104
ass2bdnxml – direct ASS to BDNXML+PNG conversion without AviSynth

ass2bdnxml is a command line software that converts ASS files to BDN XML + PNG assets. It is a clone of avs2bdnxml, except that it interfaces directly with libass and does not need AviSynth or an AVS script and has fewer options.
This software was originally written by mia-0 for a project. I have forked it and made some basic fixes, like supporting embedded fonts and setting pixel ratio to render subtitles for anamorphic content. All credits to mia-0 and ps auxw for the software.

Usage:
Everything is in the readme. Generally, you will not need any advanced options. This should be enough most of the time:
Code:
./ass2bdnxml -f 25 -v 1080i ./subtitles.ass

-v --video-format Sets the video format. Accepted values: [480i, 576i, 720p, 1080i, 1080p]     Default: 1080p
-f --fps          Sets the FPS. Values: [23.976, 24, 25, 29.97, 50, 59.94, 60 (UHD BD only)]   Default: 23.976
-q --quantize     Enables image palettization and sets the max number of colours to use.       Default: 0 (quantization disabled, 32-bit RGBA PNGs)
-a --fontdir      Specify an additional look-up directory for fonts.
-s --split        Sets split mode. 0: Off, 1: Vertical, 2: V+Horizontal, 3: V+H Aggressive, 4: Ugly.  Default: 0 (Not enabled).
-m --splitmargin  Sets the minimum vertical and opt. horizontal margins to do a split.         Format: VxH (E.g 10x200)
-h --anamorphic   Flag to squeeze bitmaps for 16:9 SD anamorphic content.
-o --offset       Sets the NDF TC offset to shift all of the BDN Timecodes.                    Default: 00:00:00:00 (no offset)
-p --par          Sets a custom pixel aspect ratio (PAR) to use in libass.                     Default: inferred from --video-format and --anamorphic
-r --rleopt       Flag to prevent usage of palette ID 0 to avoid line encoding error at authoring.
-c --copyname     Flag to reflect the name of the ASS file to the output XML.
--dim             Dim subtitles by percentage, useful subtitles targeting HDR content. 33% is roughly 200 nits. Default: 0
-t --trackname 	  Sets the human-readable name of the subtitle track.                          Default: Undefined
-l --language 	  Sets the language of the subtitle track.                                     Default: und
-w --width-render Specify a custom ASS render width.          Default: --video-format width.
-x --width-store  ASS storage width to use in libass.         Default: libass guess (generally 1:1 to video-format unless --par is specified.)
-z --downsample   Additive flag for events downsampling. Specify the flag once to prevent events shorter than 2 frames, twice for 3 frames, and so on.

If --quantize N is used:
--liq-speed       Sets LIQ speed. Lower is better but slower. Value within [1; 10] incl.    Default: 4 
--liq-quality     Sets quantization quality. Values >85 are generally lossless and compress better. Default: 100
--liq-dither      Sets the dithering level, value must be within [0; 1.0] incl.             Default: 1.0

Special / debugging:
--height-store    ASS storage height to use in libass.           Default: libass guess (generally 1:1 to video-format unless --par is specified.)
--height-render   Sets the height to use as output ASS frame.    Defaults to BDN output height if unspecified.
--keep-dupes      Flag to not merge events that are reported as different by libass yet identical when composited (e.g ASSDraw).
--hinting 	  Enables soft libass hinting.                                              Default: Not enabled
--dvd-mode 	  Uses 4 colors and increase contrast to make the subs visually pleasant.   Default: Not enabled
--negative        Flag to indicate a negative --offset. Ignored if no offset is provided
XML + PNG assets are created in the current working directory.

SUP output
ass2bdnxml does not support exporting to SUP. Conversion to SUP/PGS is done by other softwares like SUPer. In this case, image splitting or quantization should NOT be used as SUPer recalculates it internally.

Download
https://github.com/cubicibo/ass2bdnxml

Windows binaries
https://github.com/cubicibo/ass2bdnxml/releases/

Last edited by cubicibo; 21st March 2024 at 09:59.
cubicibo is offline   Reply With Quote
Old 2nd June 2023, 18:05   #2  |  Link
HPotter
Registered User
 
Join Date: Nov 2010
Posts: 4
Hi, tried to Build this one from git, but failed.
Could you pls provide builded .exe version for Windows?
HPotter is offline   Reply With Quote
Old 2nd June 2023, 19:32   #3  |  Link
cubicibo
Registered User
 
Join Date: Feb 2022
Posts: 104
What error? I don't use Windows but I can build it on macOS and Ubuntu 20.04 without issues (Ubuntu needs libbsd-dev installed and libbsd specified in cflags, also some distrib wants "libpng" rather than "png" in the gcc command line).
Maybe someone knows how to cross compile libass with mingw... I don't.

I would recommend to install WSL so you can use all those nifty doom9 tools and filters on your favorite Windows machine but in a Linux command line window

Last edited by cubicibo; 2nd June 2023 at 19:38.
cubicibo is offline   Reply With Quote
Old 2nd June 2023, 20:26   #4  |  Link
HPotter
Registered User
 
Join Date: Nov 2010
Posts: 4
Error those:

meson builddir
The Meson build system
Version: 1.1.1
Source dir: \\testproject
Build dir: \\testproject\builddir
Build type: native build
Project name: ass2bdnxml
Project version: undefined
C compiler for the host machine: cl (msvc 19.36.32532 "��⨬������騩 ��������� Microsoft (R) C/C++ ���ᨨ 19.36.32532 ��� x86")
C linker for the host machine: link link 14.36.32532.0
Host machine cpu family: x86
Host machine cpu: x86
Did not find pkg-config by name 'pkg-config'
Found Pkg-config: NO
Found CMake: \Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.EXE (3.26.0)
Run-time dependency libass found: NO (tried cmake)

meson.build:6:4: ERROR: Dependency lookup for libass with method 'pkgconfig' failed: Pkg-config binary for machine 1 not found. Giving up.

A full log can be found at \\testproject\builddir\meson-logs\meson-log.txt
WARNING: Running the setup command as meson [options] instead of meson setup [options] is ambiguous and deprecated.
HPotter is offline   Reply With Quote
Old 3rd June 2023, 12:51   #5  |  Link
HPotter
Registered User
 
Join Date: Nov 2010
Posts: 4
Quote:
Originally Posted by cubicibo View Post
What error? I don't use Windows but I can build it on macOS and Ubuntu 20.04 without issues (Ubuntu needs libbsd-dev installed and libbsd specified in cflags, also some distrib wants "libpng" rather than "png" in the gcc command line).
Maybe someone knows how to cross compile libass with mingw... I don't.

I would recommend to install WSL so you can use all those nifty doom9 tools and filters on your favorite Windows machine but in a Linux command line window
Error those:

Code:
meson builddir
The Meson build system
Version: 1.1.1
Source dir: \\testproject
Build dir: \\testproject\builddir
Build type: native build
Project name: ass2bdnxml
Project version: undefined
C compiler for the host machine: cl (msvc 19.36.32532 " Microsoft (R) C/C++ 19.36.32532 x86")
C linker for the host machine: link link 14.36.32532.0
Host machine cpu family: x86
Host machine cpu: x86
Did not find pkg-config by name 'pkg-config'
Found Pkg-config: NO
Found CMake: \Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.EXE (3.26.0)
Run-time dependency libass found: NO (tried cmake)

meson.build:6:4: ERROR: Dependency lookup for libass with method 'pkgconfig' failed: Pkg-config binary for machine 1 not found. Giving up.

A full log can be found at \\testproject\builddir\meson-logs\meson-log.txt
WARNING: Running the setup command as meson [options] instead of meson setup [options] is ambiguous and deprecated.
HPotter is offline   Reply With Quote
Old 3rd June 2023, 13:48   #6  |  Link
cubicibo
Registered User
 
Join Date: Feb 2022
Posts: 104
There's no pkg-config on windows. You have to specify the (compiled) library paths for libass and libpng.

I would suggest you to try with msys2, you can get pkgconf (equivalent to pkg-config) and directly compiled libass and libpng ready to use with make.
Else, you could try to setup the project to be like assrender and to follow the build instructions, which lets you build libass. You would have to find your way with libpng.
cubicibo is offline   Reply With Quote
Old 24th July 2023, 20:40   #7  |  Link
cubicibo
Registered User
 
Join Date: Feb 2022
Posts: 104
Latest version adds event splitting across two graphics whenever possible. This may be handy to reduce PG buffer usage with some authoring tools.
cubicibo is offline   Reply With Quote
Old 26th July 2023, 22:03   #8  |  Link
cubicibo
Registered User
 
Join Date: Feb 2022
Posts: 104
I have managed to build ass2bdnxml on Windows. The .exe file can be obtained here: ass2bdnxml.exe v0.3.
cubicibo is offline   Reply With Quote
Old 27th July 2023, 13:06   #9  |  Link
Emulgator
Big Bit Savings Now !
 
Emulgator's Avatar
 
Join Date: Feb 2007
Location: close to the wall
Posts: 1,531
Many thanks, cubicibo !
__________________
"To bypass shortcuts and find suffering...is called QUALity" (Die toten Augen von Friedrichshain)
"Data reduction ? Yep, Sir. We're that issue working on. Synce invntoin uf lingöage..."
Emulgator is offline   Reply With Quote
Old 27th August 2023, 12:05   #10  |  Link
cubicibo
Registered User
 
Join Date: Feb 2022
Posts: 104
ass2bdnxml v0.4

This version greatly improve the time accuracy of the output. Combined with SUPer v0.2.0, you can now generate frame accurate masking effects in your (authoring compliant) PGS

In the next version, I will try to add support for libimagequant to output 8-bit palletized PNG for users who want to directly import the PNG in Scenarist BD. At the moment, ass2bdnxml outputs 32-bit images and Scenarist users must execute "pngquant.exe 255 -f --ext .png *.png" on the images.
cubicibo is offline   Reply With Quote
Old 5th October 2023, 20:32   #11  |  Link
cubicibo
Registered User
 
Join Date: Feb 2022
Posts: 104
ass2bdnxml v0.6a
Image quantization added with libimagequant. DO NOT use image quantization if you generate a BDN XML that will be converted to PGS with SUPer.

v0.6a changes
Quote:
• Improve TC accuracy (v0.6a)
• Fix imprecise seek of next subtitle event with NTSC framerates.
• Add --copyname (-c) to reflect the .ASS filename to the output XML.
• Add --liq-speed to set libimagequant speed (and hence, algorithms used). 1: slower, highest quality. 10: fastest, lowest quality. Default: 4
• Add --liq-quality to specify libimagequant quality (akin to JPEG quality parameter, minus the mosquito noise). Default is 100 but 80+ is in general visually lossless.
• Add --liq-dither to control the dithering behaviour of libimagequant. Value within 0.0 (no dithering) and 1.0 (maximum dithering, default)
--liq-x parameters are usable only when paired with "--quantize".

v0.5 changes
Quote:
• Add libimagequant to output palettized PNG images, required by some authoring suites. This is enabled by specifying --quantize (-q) followed by the maximum number of colours accepted (typically 255 for PGS).
• Add flag --rleopt (-r) to prevent the usage of palette entry zero. May fix the "Line could not be encoded" error seen on Scenarist.
• Change --split (-s) flag to parameter. 4 modes availables: {0: Disabled, 1: Vertical, 2: Vertical + opt. Horiz, 3: Both ("aggressive")}
• Add argument --offset (-o) to specify a TC offset to apply to all BDN timecodes.
• Add flag --negative (-z) to mark the TC offset specified with --offset as negative. Value warp-around is not implemented, use with care.
• Fix --par (-p) to be the real PAR and not 1/PAR.
• Add --splitmargin (-m) to specify a minimum margin between two crops to effectively split them. Argument format is VxH, where V is the minimum y axis difference, and H the minimum x axis difference. 'x' is a separator and is only required if H is provided. V can be provided alone. This argument greatly affects the behaviour of the split. It is very handy with the aggressive split mode --split 3.

Last edited by cubicibo; 9th October 2023 at 21:41.
cubicibo is offline   Reply With Quote
Old 20th November 2023, 09:05   #12  |  Link
Alllen
Registered User
 
Join Date: Nov 2023
Posts: 2
Hi! Is it possible to add compatibility support for the vsfiltermod plugin? With the help of filter, My ASS subs have more setting options to be able to handle and display some more complex dynamic subtitle effects, and realize more advanced and useful functions, e.g.: importing external image sequences... I have been using avs2bndxml to output xmlPNG, but this project has been discontinued for many years, it needs to write extra AVS scripts to load .dll filters for rendering, and the processing speed is so slow, it basically takes about 10 minutes to convert over thousand lines in ASS subs, which is really maddening.
Recently, I have changed to use ass2bdnxml to convert ASS, the same subtitles only need less than 1 minute, and then with SUPer, to make Blu-ray subtitles, the experience is simply amazing and easier, but the shortcoming is that ass2bdnxml does not have that filter and can not customize the output path, I hope that the project can be perfected, and finally still say thanks to cubicibo brought us such good tools!
Alllen is offline   Reply With Quote
Old 20th November 2023, 09:55   #13  |  Link
cubicibo
Registered User
 
Join Date: Feb 2022
Posts: 104
You are welcome.

I don't think I understand your request. Do you want ass2bdnxml to:
1) Offer the possibility to switch between libass or xy-VSFilter/VSFilterMod to render .ASS input files (or other types of files supported by VSFilter)? Akin to the user option in MPC-HC.
2) Be an actual VapourSynth/AviSynth filter, feed it a clip and expect it to output BDNXML using either libass/VSFilter?

VSFilter has tons of dependencies and is much less portable than libass. If it is option #1, maybe. Option #2 is less likely.

Also, what's the use case? Shouldn't libass mimicks VSFilter?


EDIT:
Looked into VSFilterMod, API is barely usable and it is C++, so I cannot add a dll and call it. Sorry, there's not much I can do for that. I will however fix the output path in the future.

Last edited by cubicibo; 20th November 2023 at 20:02.
cubicibo is offline   Reply With Quote
Old 13th December 2023, 23:16   #14  |  Link
cubicibo
Registered User
 
Join Date: Feb 2022
Posts: 104
ass2bdnxml v0.7a
This version fixes ASSDraw exports (before, it would often generate one XML/PNG event per frame...) and optimises the palette structure for the PGS format and Scenarist BD.

Changes
Quote:
• Detect false positive of "changed" ASS_Image by comparing the current blended RGBA composition to the last one. This fixes the excessive event generation whenever some ASSDraw were encountered.
• Optimise palette generation for the PGS format. 256 (255 with --rleopt) are now usable rather than 255 (254 resp.)
• Always allocate the background transparent pixel to the last palette entry (0xFF typically).
• Adaptively reduce the usable number of colors by one when no transparency is found in a blended image.
Hotfix v0.7a (14 Dec): fix blinking subtitles with new logic.

Last edited by cubicibo; 18th January 2024 at 08:26.
cubicibo is offline   Reply With Quote
Old 4th February 2024, 06:36   #15  |  Link
KSSW
Registered User
 
Join Date: Sep 2022
Location: China
Posts: 23
Can PNGs output 1920x1080 at full resolution
KSSW is offline   Reply With Quote
Old 4th February 2024, 12:12   #16  |  Link
cubicibo
Registered User
 
Join Date: Feb 2022
Posts: 104
Not supported.
What would be your use-case?
cubicibo is offline   Reply With Quote
Old 21st February 2024, 09:08   #17  |  Link
KSSW
Registered User
 
Join Date: Sep 2022
Location: China
Posts: 23
I don't need it anymore. Thank you!

You're very professional
KSSW is offline   Reply With Quote
Old 29th February 2024, 04:06   #18  |  Link
Alllen
Registered User
 
Join Date: Nov 2023
Posts: 2
Quote:
Originally Posted by cubicibo View Post
You are welcome.

I don't think I understand your request. Do you want ass2bdnxml to:
1) Offer the possibility to switch between libass or xy-VSFilter/VSFilterMod to render .ASS input files (or other types of files supported by VSFilter)? Akin to the user option in MPC-HC.
2) Be an actual VapourSynth/AviSynth filter, feed it a clip and expect it to output BDNXML using either libass/VSFilter?

VSFilter has tons of dependencies and is much less portable than libass. If it is option #1, maybe. Option #2 is less likely.

Also, what's the use case? Shouldn't libass mimicks VSFilter?


EDIT:
Looked into VSFilterMod, API is barely usable and it is C++, so I cannot add a dll and call it. Sorry, there's not much I can do for that. I will however fix the output path in the future.
What I mean is to provide the user with an option for switching to the VSFilterMod Filter Render.ASS file. Maybe you can refer to the source code of avs2bdnxml project (
https://github.com/koroban/avs2bdnxml), I saw it is also written in C, just porting and integrating it into your ass2bdnxml will be fine, if it is possible, multi-threading optimization during execution can improve efficiency, by the way, avs2bdnxml needs to be generated as an .avs script before running, like :"LoadPlugin("D:/VSFilterMod.dll")
MaskSubMod("D:/mysubs/2.ass", 1920, 1080, 23.97602397602398, 223752)
" , which has to be left to the main program to complete.
Alllen is offline   Reply With Quote
Old 29th February 2024, 10:04   #19  |  Link
cubicibo
Registered User
 
Join Date: Feb 2022
Posts: 104
avs2bdnxml and ass2bdnxml are very different. ass2bdnxml interfaces directly with libass and has its own frame rendering functions: it is very portable and efficient. avs2bdnxml is just differentiating contiguous frames and outputs PNG of whatever it gets. All of the code complexity is in VSFilter(Mod), AviSynth or any other AVS filter. I can't just pull kedaitinh12 VsFilterMod.dll and call it from ass2bdnxml easily.

Beside, I develop everything on macOS; I cannot build easily Windows apps, and VSFilter is a Windows-only technology.
When I have time (not these days), I will try to parrot that code. If it does not work out, I will not try any harder with VsFilterMod. Just request or add the missing ASSA commands to libass.
cubicibo is offline   Reply With Quote
Old 25th March 2024, 09:53   #20  |  Link
cubicibo
Registered User
 
Join Date: Feb 2022
Posts: 104
ass2bdnxml v0.7c
Very minor release again.

Changes
Quote:
• Add --downsample (-z) to subsample the ASS. "-z" prevents events shorter than 2 frames, "-z -z" 3 frames, and so on. Halving the subtitle framerate can help the subtitle decoder with HFR content, as subtitles effects do not need to have such a high framerate to be smooth. This option does not restrict the timing to even or odd frames, the grid is fully adaptive and most in and out time will be dully respected.
• Add --dim P to dim the subtitles for HDR exports. P is a percentage, and 33.3% would roughly results in 200-nits white.
• Fix --squarepx for SD 4/3 content.
cubicibo is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 18:07.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.