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: 86
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 50 -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. Accepted values: [23.976, 24, 25, 29.97, 50, 59.94]         Default: 23.976
-q --quantize     Enables image palettization and sets the max number of colours to use.    Default: 0 (quantization disabled)
-a --fontdir      Specify an additional look-up directory for fonts.
-s --split        Sets the split behaviour and aggressiveness (value in {0, 1, 2, 3}).      Default: 0 (Not enabled).
-m --splitmargin  Sets the minimum vertical and opt. horizontal margins to do a split.      Format: VxH (E.g 10x200)
-p --par          Sets the pixel aspect ratio (PAR) to use in libass (e.g anamorphic clip)  Default: libass guess (generally PAR=1)
-o --offset       Sets the NDF TC offset to shift all of the BDN Timecodes.                 Default: 00:00:00:00 (no offset)
-z --negative     Flag to indicate a negative --offset. Ignored if no offset is provided
-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.
-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 --render-width  Specify the .ass width to use as frame/storage space.                    Default: video-format width
-h --render-height Specify the .ass height to use as frame space/storage space.             Default: video-format height
-g --hinting 	  Enables soft libass hinting.                                              Default: Not enabled
-d --dvd-mode 	  Uses 4 colors and increase contrast to make the subs visually pleasant.   Default: Not enabled
-x --width-store  ASS storage width to use in libass.         Default: libass guess (generally 1:1 to video-format unless --par is specified.)
-y --height-store ASS storage height to use in libass.        Default: libass guess (generally 1:1 to video-format unless --par is specified.)

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
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; 20th November 2023 at 16:13.
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: 86
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: 86
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: 86
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: 86
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,476
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: 86
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: 86
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: 1
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: 86
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
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 05:54.


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