slavanap
30th January 2016, 00:19
Render your 2D subtitles on 3D video with correct depth.
>>> CURRENT RELEASE AVAILABLE HERE <<< (https://github.com/slavanap/ssifSource/releases)
CASES THAT PLUGIN SUPPORTS
1. You have subtitles in xml format.
I know that BD3D2MK3D (http://forum.doom9.org/showthread.php?t=170828) tool somehow generates this format.
The output should be a folder with .xml file (descriptor) + .png images (subtitles).
.xml file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<BDN Version="0.93" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BD-03-006-0093b BDN File Format.xsd">
<Description>
<Name Title="FRA_2D" Content=""/>
<Language Code="eng"/>
<Format VideoFormat="1080p" FrameRate="23.976" DropFrame="False"/>
<Events Type="Graphic" FirstEventInTC="00:00:02:17" LastEventOutTC="00:04:33:18" NumberofEvents="47"/>
</Description>
<Events>
<Event InTC="00:00:02:17" OutTC="00:00:05:07" Forced="False">
<Graphic Width="840" Height="50" X="540" Y="875" Depth="24">FRA_2D_0001.png</Graphic>
</Event>
...
2. You have .srt, .ass or .ssa subtitle file.
3. You have a other software that can render subtitles over 2D video (AviSynth plugin is preferable, because rendering result must be lossless).
PLUGIN USAGE
It is AviSynth plugin, plugin API described in sub3d.avs. I'll just use function names here.
I assume, you are familiar with AviSynth a little bit.
3D subtitle rendering over 3D video consists of 2 steps:
1) subtitle depth computation, 2) rendering.
These steps are separate. That means, that after depth computation is performed, you will be able to tinker computed depths, and then render subtitles.
Case #1. If you have subtitles with .xml format.
Use CalcXMLDepths function to calculate depths: .xml file will be updated: to every Graphic tag Depth attribute with computed value will be added.
(This AviSynth function outputs nothing, just do it's job. Function input must be full-size horizontal stack of the views. Left view is on the left.)
Use RenderXML function to render subtitles over 3D video. This function input is horizontal stack video over that you want render .xml subtitles. Output is same horizontal stack, but with rendered subtitles.
Case #2. If you have .srt, .ass or .ssa subtitles.
First of all, you need vsfilter.klite.dll AviSynth plugin that provides a MaskSub function that renders subtitles with alpha channel. sub3d.dll uses this function internally. See script example sub3d-2.avs for reference. vsfilter.klite.dll is an .dll that comes with K-Lite Codec Pack (https://ru.wikipedia.org/wiki/K-Lite_Codec_Pack). There might be older version in my package.
Use CalcSRTDepths to calculate depths. This function returns nothing (i.e. no rendering), accepts 3D video (horizontal stack) as input + .srt filename. It will produce *.depths file that is needed by RenderSRT function. The *.depths file format is straight forward: every line contains:
<subtitle_number> <#frame_when_subtitle_starts> <subtitle_length_in_frames>
You may tinker around this file before using RenderSRT.
Use RenderSRT function to render *.depths file over 3D video.
Case #3. If you have some other software (AviSynth plugin) that can render subtitles over 2D video.
sub3d-3.avs script is demonstration of SupTitle.dll plugin usage that provides SupTitle function that can render .sup file over simple 2D video.
The pipeline here is more complex. First of all we need to pass rendered subtitles with alpha channel to CalcSRTDepths function, but SupTitle function renders only subtitles over video. That's where RestoreAlpha function comes to help. It accepts another AviSynth function name that can render subtitles over video in RGB32 format and a videoclip, from what it will take clip duration and video size. RestoreAlpha function outputs rendered subtitles with alpha channel.
Now we can pass this output to CalcSRTDepths function (it's 3rd parameter is a function name that provides subtitles with alpha channel) and finally calculate the depths. Subtitle rendering is performed (as in case #2) with RenderSRT function.
NOTICES
1. sub3d works with RGB32 colorspace. It output is in RGB32 too. Sometimes a color conversion is required.
2. Every Calc*Depths function uses sub3d.lua file for raw subtitle depth values processing. As shown in sub3d.lua, it may write .ofs planes file easily, if needed. For LUA Apis look at SetDepthComputationAlg description in sub3d.avs.
ACKNOWLEDGEMENTS
Thanks to r0lZ (http://forum.doom9.org/member.php?u=37912), who spend decent amount of time testing the plugin.
-
>>> CURRENT RELEASE AVAILABLE HERE <<< (https://github.com/slavanap/ssifSource/releases)
CASES THAT PLUGIN SUPPORTS
1. You have subtitles in xml format.
I know that BD3D2MK3D (http://forum.doom9.org/showthread.php?t=170828) tool somehow generates this format.
The output should be a folder with .xml file (descriptor) + .png images (subtitles).
.xml file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<BDN Version="0.93" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BD-03-006-0093b BDN File Format.xsd">
<Description>
<Name Title="FRA_2D" Content=""/>
<Language Code="eng"/>
<Format VideoFormat="1080p" FrameRate="23.976" DropFrame="False"/>
<Events Type="Graphic" FirstEventInTC="00:00:02:17" LastEventOutTC="00:04:33:18" NumberofEvents="47"/>
</Description>
<Events>
<Event InTC="00:00:02:17" OutTC="00:00:05:07" Forced="False">
<Graphic Width="840" Height="50" X="540" Y="875" Depth="24">FRA_2D_0001.png</Graphic>
</Event>
...
2. You have .srt, .ass or .ssa subtitle file.
3. You have a other software that can render subtitles over 2D video (AviSynth plugin is preferable, because rendering result must be lossless).
PLUGIN USAGE
It is AviSynth plugin, plugin API described in sub3d.avs. I'll just use function names here.
I assume, you are familiar with AviSynth a little bit.
3D subtitle rendering over 3D video consists of 2 steps:
1) subtitle depth computation, 2) rendering.
These steps are separate. That means, that after depth computation is performed, you will be able to tinker computed depths, and then render subtitles.
Case #1. If you have subtitles with .xml format.
Use CalcXMLDepths function to calculate depths: .xml file will be updated: to every Graphic tag Depth attribute with computed value will be added.
(This AviSynth function outputs nothing, just do it's job. Function input must be full-size horizontal stack of the views. Left view is on the left.)
Use RenderXML function to render subtitles over 3D video. This function input is horizontal stack video over that you want render .xml subtitles. Output is same horizontal stack, but with rendered subtitles.
Case #2. If you have .srt, .ass or .ssa subtitles.
First of all, you need vsfilter.klite.dll AviSynth plugin that provides a MaskSub function that renders subtitles with alpha channel. sub3d.dll uses this function internally. See script example sub3d-2.avs for reference. vsfilter.klite.dll is an .dll that comes with K-Lite Codec Pack (https://ru.wikipedia.org/wiki/K-Lite_Codec_Pack). There might be older version in my package.
Use CalcSRTDepths to calculate depths. This function returns nothing (i.e. no rendering), accepts 3D video (horizontal stack) as input + .srt filename. It will produce *.depths file that is needed by RenderSRT function. The *.depths file format is straight forward: every line contains:
<subtitle_number> <#frame_when_subtitle_starts> <subtitle_length_in_frames>
You may tinker around this file before using RenderSRT.
Use RenderSRT function to render *.depths file over 3D video.
Case #3. If you have some other software (AviSynth plugin) that can render subtitles over 2D video.
sub3d-3.avs script is demonstration of SupTitle.dll plugin usage that provides SupTitle function that can render .sup file over simple 2D video.
The pipeline here is more complex. First of all we need to pass rendered subtitles with alpha channel to CalcSRTDepths function, but SupTitle function renders only subtitles over video. That's where RestoreAlpha function comes to help. It accepts another AviSynth function name that can render subtitles over video in RGB32 format and a videoclip, from what it will take clip duration and video size. RestoreAlpha function outputs rendered subtitles with alpha channel.
Now we can pass this output to CalcSRTDepths function (it's 3rd parameter is a function name that provides subtitles with alpha channel) and finally calculate the depths. Subtitle rendering is performed (as in case #2) with RenderSRT function.
NOTICES
1. sub3d works with RGB32 colorspace. It output is in RGB32 too. Sometimes a color conversion is required.
2. Every Calc*Depths function uses sub3d.lua file for raw subtitle depth values processing. As shown in sub3d.lua, it may write .ofs planes file easily, if needed. For LUA Apis look at SetDepthComputationAlg description in sub3d.avs.
ACKNOWLEDGEMENTS
Thanks to r0lZ (http://forum.doom9.org/member.php?u=37912), who spend decent amount of time testing the plugin.
-