View Single Post
Old 20th April 2009, 20:11   #1  |  Link
ps auxw
Registered User
 
Join Date: Apr 2009
Posts: 102
AviSynth rendered subtitles to BluRay SUP/PGS and BDN XML (v2.08)

AVS to BluRay SUP/PGS and BDN XML


News

As of version 2.00, avs2bdnxml supports direct conversion to the BluRay SUP format. This is still somewhat experimental, but seems to work for many people.


History

First, a bit of history. I wrote avs2bdnxml in late 2008 as the result of a discussion with Daiz in the x264 IRC channel. Back then, there wasn't a reasonable way to actually do something useful with BDN XML files, so I mostly forgot about it. Now there are at least two programs, which can convert BDN XML+PNG to BD-SUP format. This resulted in me fixing a couple of bugs, and then deciding to post it here.


Purpose

Now, what does it do, you might ask. The answer to this is pretty simple. avs2bdnxml takes an AviSynth script which outputs RGBA, and turns it into a BDN XML file + PNG files. Now, it seems that Ulf wrote something similar. The main difference is that avs2bdnxml can convert anything AviSynth can generate to BDN XML (just make sure it still looks good after being palletized), not just subtitles.

For example you can turn the following (and combinations thereof) into BluRay subtitles:
  • Anything that VSFilter can render. SRT, (animated) ASS/SSA, etc..
  • Logos/pictures.
  • RGBA video overlays made with Adobe AfterEffects.


Usage
  1. First you'll need an AviSynth script. If you have a regular subtitle file you want to render using VSFilter (you'll need at least VSFilter 2.39), do something like this:
    Code:
    video=AviSource("video.avi")
    MaskSub("subtitles.ext",video.width,video.height,video.framerate,video.framecount)
    If you have an RGBA video, do something like this instead:
    Code:
    AviSource("subtitles_RGBA.avi")
    FlipVertical()
  2. Now you'll have to run avs2bdnxml. Since it is a command line application, you'll either have to use cmd, some other shell or write a batch file.
    Code:
    Usage: avs2bdnxml [options] -o output input
    
    Input has to be an AviSynth script with RGBA as output colorspace
    
      -o, --output <string>        Output file in BDN XML format
                                   For SUP/PGS output, use a .sup extension
      -j, --seek <integer>         Start processing at this frame, first is 0
      -c, --count <integer>        Number of input frames to process
      -t, --trackname <string>     Name of track, like: Undefined
      -l, --language <string>      Language code, like: und
      -v, --video-format <string>  Either of: 480i, 480p,  576i,
                                              720p, 1080i, 1080p
      -f, --fps <float>            Either of: 23.976, 24, 25, 29.97, 50, 59.94
      -x, --x-offset <integer>     X offset, for use with partial frames.
      -y, --y-offset <integer>     Y offset, for use with partial frames.
      -d, --t-offset <string>      Offset timecodes by this many frames or
                                   given non-drop timecode (HH:MM:SS:FF).
      -s, --split-at <integer>     Split events longer than this, in frames.
                                   Disabled when 0, which is the default.
      -m, --min-split <integer>    Minimum length of line segment after split.
      -e, --even-y <integer>       Enforce even Y coordinates. [on=1, off=0]
      -a, --autocrop <integer>     Automatically crop output. [on=1, off=0]
      -p, --palette <integer>      Output 8bit palette PNG. [on=1, off=0]
      -n, --null-xml <integer>     Allow output of empty XML files. [on=1, off=0]
      -z, --stricter <integer>     Stricter checks in the SUP writer. May lead to
                                   less optimized buffer use, but might raise
                                   compatibility. [on=1, off=0]
      -u, --ugly <integer>         Allow splitting images in ugly ways.
                                   Might improve buffer problems, but is ugly.
                                   [on=1, off=0]
      -b, --buffer-opt <integer>   Optimize PG buffer size by image
                                   splitting. [on=1, off=0]
    Example:
    Code:
    avs2bdnxml -t Undefined -l und -v 1080p -f 23.976 -a1 -p1 -b0 -m3 -u0 -e0 -n0 -z0 -o output.xml input.avs
    Input and output are required settings. The rest are set to default, as per the example. Please note that the image files will be named 00000000_0.png, ..., 99999999_1.png, and will be written to the same directory as the XML file. Existing files with these names will be overwritten. XML files created with -b1 might not be supported by anything but Scenarist and EasyBD. You can generate SUP and BDN-XML output at the same time by specifying -o twice.
  3. To get SUP output, just change the output filename extension to .sup, for example: -o output.sup
  4. Wait until it's done. You should now have a nice BDN XML file, and a bunch of PNG files.
  5. For some programs, you have to convert the PNG files to 8bit RGBA palette. This doesn't apply to BDSup2Sub and BDSupEdit. You can also do this, using the -p switch.
  6. Use a program like BDSupEdit or BDSup2Sub to convert the BDN XML stuff to a BD-SUP file. The rest is left as an exercise for the reader.


Download

avs2bdnxml v2.08
Website


Changes

Version 2.08
  • Fix PNG filename references when used with timecode offsets.

Version 2.07
  • Fix two bugs in timecode parsing function
  • Move most inline assembly to yasm

Version 2.06
  • Add option to add an offset to output timecodes
  • Change return value when no events were detected to 0
  • Add option to allow writing of empty output files
  • Add option to enforce even Y coordinates (may help avoid problems with interlaced video in DVD related use cases)
  • Fix SSE2 with more recent GCC versions
  • Add option for stricter checks on buffer/palette limits for SUPs
  • Fix bug where LastEventOutTC could be one frame early
  • Add additional checks to commandline argument parsing
  • PNG files are now always placed in the same directory as the XML file

Version 2.05
  • Fix crash when using XML and SUP output

Version 2.04
  • Minor fixes
  • Code cleanup regarding linked lists
  • Add new minimal window finding code
  • Fix PGS output more, especially WDS handling
  • Fix old bug in RLE encoder

Version 2.03
  • Output some statistics about previous epoch in pgsparse in end packet
  • Fix unnecessary epoch splits due to bad buffer calculation and more.
  • Some small fixes

Version 2.02
  • It is now possible to use -o twice, with different output formats
  • Corrections to SUP timestamp calculation
  • PGS decode buffer should contain palettized image data, not RGBA. Buffer usage calculation fixed.

Version 2.01
  • Restrict number of composition objects within an epoch to 64

Version 2.00
  • Options --seek and --count were added, to allow for partial processing of input video
  • For debug purposes, a stand-alone SUP file parser was added in debug/
  • Experimental SUP output support

Version 1.13
  • By default, images are no longer split into to composition objects, if the result would look ugly. For example, descenders should no longer get put into their own image. Reverting back to the old behaviour is possible using the --ugly option.
  • Ensure minimum size of 8x8 for composition objects

Version 1.12
  • Fix error in example
  • Fix double free, which could result in broken images when image splitting and palletized output were enabled.

Version 1.11
  • Add option to not split lines, if the rest isn't a minimum of 3 (default) frames long
  • Images are now autocropped by default
  • Images are now converted to 8bit palette by default
  • Misc bugfixes that should've been fixed before

Version 1.10b
  • Splitting of images is now disabled by default

Version 1.10
  • Add option to split events longer than a given number of frames, to allow better seeking
  • Change image filename format to XXXXXXXX_X.png
  • Add option to optimize for Presentation Graphics buffer usage, by auto-cropping images, and splitting them into two separate ones to minimize surface area, when necessary (enabled by default)
  • Use getopts for commandline argument parsing
  • Add Makefile

Version 1.9
  • Correct calculation of timecodes. Integer only, now.
  • Remove support for drop timecodes. If anybody really needs them, and has a way to check calculated timecodes are correct, please tell me.

Version 1.8
  • Fix crash with certain frame sizes (unaligned buffer used with SSE2)

Version 1.7
  • Terminate using exit/return instead of abort (no more "crashes")

Version 1.6
  • Zero transparent pixels to guard against invisible color information (Slight slowdown, but more robustness)
  • Add SSE2 runtime detection
  • Correctly set DropFrame attribute

Version 1.5
  • Validate framerates
  • Make non-drop timecodes the default for 23.976, 29.97 and 59.94
  • Fix bad timecode calculation due to float math optimization
  • Add integer SSE2 optimization (but most time is spent in AviSynth)
  • Don't uselessly swap R and B channels

Last edited by ps auxw; 21st March 2015 at 17:44. Reason: Release of avs2bdnxml 2.08
ps auxw is offline   Reply With Quote