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. |
2nd August 2016, 16:22 | #1 | Link |
unsigned int
Join Date: Oct 2012
Location: 🇪🇺
Posts: 760
|
Subtitle renderer for image subtitles
Edit: This plugin is shipped with VapourSynth since version R33, under the name Subtext.
It supports demuxed VOBSUB and PGS subtitles. Let me know how it works. I tested it about as much as usual, which is not a lot.
__________________
Buy me a "coffee" and/or hire me to write code! Last edited by jackoneill; 25th August 2016 at 15:08. |
2nd August 2016, 19:21 | #2 | Link |
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 7,277
|
Nice! Thanks!
quick test with vobsub subtitles seems to work, used: Code:
# Imports import vapoursynth as vs core = vs.get_core() # Loading Plugins core.std.LoadPlugin(path="G:/Hybrid/Vapoursynth/vapoursynth64/plugins/SubtitleFilter/LibSubtitle/libsubtitle.dll") core.std.LoadPlugin(path="G:/Hybrid/Vapoursynth/vapoursynth64/plugins/SourceFilter/FFMS2/ffms2.dll") # Loading Source: F:\TestClips&Co\Test-AC3-5.1.avi clip = core.ffms2.Source(source="F:/TESTCL~1/TEST-A~1.AVI",cachefile="H:/Temp/avi_54a4199c1a3d3b1476ea1d15dc267332_4827.ffindex",fpsnum=25) # loading subtitle TITLE_1_0_lang_en from ElephantsDream with LibSubtitle subs = core.sub.ImageFile(clip=clip, file="H:/Output/TITLE_1_0_lang_en.idx") alpha = core.std.PropToClip(subs) subs = core.resize.Bicubic(subs, width=clip.width, height=clip.height, format=clip.format.id, matrix_s="470bg") gray_format = core.register_format(vs.GRAY, clip.format.sample_type, clip.format.bits_per_sample, 0, 0) alpha = core.resize.Bicubic(alpha, width=clip.width, height=clip.height, format=gray_format.id) clip = core.std.MaskedMerge(clip, subs, alpha) # Output clip.set_output() Last edited by Selur; 2nd August 2016 at 20:15. |
3rd August 2016, 05:45 | #5 | Link |
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 7,277
|
Muxed the subtitles with the video stream into an mp4 and played the file with mplayer and ffplayer to compare and they both displayed the same white borders.
Uploaded the files (Test-AC3-5.1.avi, TITLE_1_0_lang_en.idx/.sub and muxed.mp4) I used to my GoogleDrive as subtitleTest.7z (no clue how to hardcode idx/sub subtitles with ffmpeg, but since ffplay displays the colors correctly on the muxed file I guess there is something wrong with the filter,...) Cu Selur |
3rd August 2016, 17:02 | #6 | Link | |
unsigned int
Join Date: Oct 2012
Location: 🇪🇺
Posts: 760
|
Quote:
https://github.com/dubhater/vapoursy...eleases/tag/v2 Code:
* Add parameter 'palette', which allows the user to pass a custom palette. * Add parameter 'gray'.
__________________
Buy me a "coffee" and/or hire me to write code! |
|
7th August 2016, 08:27 | #7 | Link |
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 7,277
|
Okay, so libavcodec applies some custom color adjustments?
When using Vapoursynth with libsubtitle: Code:
# Imports import vapoursynth as vs core = vs.get_core() # Loading Plugins core.std.LoadPlugin(path="G:/Hybrid/Vapoursynth/vapoursynth64/plugins/SubtitleFilter/LibSubtitle/libsubtitle.dll") core.std.LoadPlugin(path="G:/Hybrid/Vapoursynth/vapoursynth64/plugins/SourceFilter/LSmashSource/vslsmashsource.dll") # Loading Source: H:/Output/Test-AC3-5.1.avi clip = core.lsmas.LWLibavSource(source="H:/Output/Test-AC3-5.1.avi", cache=0) # loading subtitle TITLE_1_0_lang_en with LibSubtitle subs = core.sub.ImageFile(clip=clip, file="H:/Output/TITLE_1_0_lang_en.idx") alpha = core.std.PropToClip(subs) subs = core.resize.Bicubic(subs, width=clip.width, height=clip.height, format=clip.format.id, matrix_s="470bg") gray_format = core.register_format(vs.GRAY, clip.format.sample_type, clip.format.bits_per_sample, 0, 0) alpha = core.resize.Bicubic(alpha, width=clip.width, height=clip.height, format=gray_format.id) clip = core.std.MaskedMerge(clip, subs, alpha) # Output clip.set_output() using ffplay: Code:
ffplay c:\Users\Selur\Desktop\muxed.mp4 using mplayer: Code:
mplayer C:\Users\Selur\Desktop\Test-AC3-5.1.avi using Avisnth and VsFilter: Code:
LoadCPlugin("G:\Hybrid\AVISYN~1\ffms2.dll") LoadPlugin("G:\Hybrid\AVISYN~1\VSFilter.dll") # loading source: C:\Users\Selur\Desktop\Test-AC3-5.1.avi FFVideoSource("C:\Users\Selur\Desktop\TEST-A~1.AVI",cachefile="H:\Temp\avi_3c69763e8478b88d8cc19d0971dbb14d_4827_1_0.ffindex",fpsnum=25) # embedding subtitles VobSub("H:\Output\TITLE_1_0_lang_en") return last using using Vapoursynth with libsubtitle and gray=true: Code:
# Imports import vapoursynth as vs core = vs.get_core() # Loading Plugins core.std.LoadPlugin(path="G:/Hybrid/Vapoursynth/vapoursynth64/plugins/SubtitleFilter/LibSubtitle/libsubtitle.dll") core.std.LoadPlugin(path="G:/Hybrid/Vapoursynth/vapoursynth64/plugins/SourceFilter/LSmashSource/vslsmashsource.dll") # Loading Source: H:/Output/Test-AC3-5.1.avi clip = core.lsmas.LWLibavSource(source="H:/Output/Test-AC3-5.1.avi", cache=0) # loading subtitle TITLE_1_0_lang_en with LibSubtitle subs = core.sub.ImageFile(clip=clip, file="H:/Output/TITLE_1_0_lang_en.idx",gray=True) alpha = core.std.PropToClip(subs) subs = core.resize.Bicubic(subs, width=clip.width, height=clip.height, format=clip.format.id, matrix_s="470bg") gray_format = core.register_format(vs.GRAY, clip.format.sample_type, clip.format.bits_per_sample, 0, 0) alpha = core.resize.Bicubic(alpha, width=clip.width, height=clip.height, format=gray_format.id) clip = core.std.MaskedMerge(clip, subs, alpha) # Output clip.set_output() => Do you by chance know what custom palette ffplay/mplayer/vsfilter are using? Or is there something wrong with the way I call libsubtitle in Vapoursynth and apply it to the clip? (I followed the example from https://github.com/dubhater/vapoursy...ter/readme.rst) Cu Selur |
7th August 2016, 09:30 | #8 | Link | |
unsigned int
Join Date: Oct 2012
Location: 🇪🇺
Posts: 760
|
Quote:
You're calling it correctly. Tip: the yellow border is probably the fourth element of the palette.
__________________
Buy me a "coffee" and/or hire me to write code! |
|
7th August 2016, 10:01 | #9 | Link | ||
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 7,277
|
Quote:
Quote:
-> off testing around with different palettes now. Code:
palette=[rgba(0, 0, 0), rgba(255, 255, 255), rgba(0, 0, 0), rgba(0, 0, 0)] Cu Selur Last edited by Selur; 7th August 2016 at 10:14. |
||
17th September 2016, 14:16 | #10 | Link |
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 7,277
|
What happened to the filter?
https://github.com/dubhater/vapoursynth-subtitle gives a 404 now ah, seems like it got included into http://www.vapoursynth.com/doc/plugins/subtext.html Last edited by Selur; 17th September 2016 at 14:22. |
17th September 2016, 14:22 | #11 | Link | |
Professional Code Monkey
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,555
|
Quote:
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet |
|
|
|