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. |
9th June 2018, 07:40 | #1 | Link |
Registered User
Join Date: Sep 2005
Posts: 178
|
Load subtitles and attachments from mkv?
I'd like to be able to do all of the following within an AviSynth script:
Right now I'm doing an ugly workaround by extracting both the subtitles and attached fonts, installing the fonts, and then loading the subtitles from the external file via TextSub(). This involves a lot of work outside of AviSynth that I'd like to avoid, particularly the full font installation. Edit: Even if I can't load attachments from the mkv, just loading subtitles would still be helpful. Last edited by `Orum; 9th June 2018 at 08:36. |
10th June 2018, 06:57 | #2 | Link |
Registered User
Join Date: Oct 2011
Posts: 275
|
Hello,
For the font installation you can maybe skip it with avisynth+, it can load non-installed fonts if you provide the name of the font and the location path, for example : Code:
Subtitle("SomeText", font="Olde English", font_filename="H:\fonts\OldeEnglish.ttf", size=50, text_color=$FF000000, halo_color=color_black) The link says that once the font is loaded there is no more need to give the name or path so it might be possible to then use it with some subtitle rendering plugins once loaded, maybe making a fake empty subtitle first , maybe only applied on the first frame, then trying to see if your plugins used to render the subtitles can then use the non installed font that was loaded using this trick. ( or creating a function loading the fonts just to trigger it maybe) I use non installed fonts to render text using avisynth native functions but never tried with subtitles plugins, need some testing i guess. For the necessity to demux the MKV and extract the subs + embedded fonts i don't know if it's possible directly in avisynth, some others will probably have answers to this. Last edited by Yanak; 10th June 2018 at 07:14. |
10th June 2018, 07:33 | #3 | Link | |
Registered User
Join Date: Sep 2005
Posts: 178
|
Quote:
|
|
10th June 2018, 07:45 | #4 | Link |
Registered User
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
|
attach the fonts with the .ass using aegisub then load it with TextSub/TextSubmod
it work with vsfiltermod and xyvsfilter, other may not since there was some bug that fixed later
__________________
See My Avisynth Stuff |
10th June 2018, 09:23 | #5 | Link | |
Registered User
Join Date: Oct 2011
Posts: 275
|
Just tested this quickly :
Code:
LoadPlugin("H:\avs\DSS2mod\DSS2.dll") Loadplugin("H:\VSFilterMod.dll") DSS2("H:\test.mkv") Subtitle("0", first_frame=0, last_frame=1,\ font="Pacific Again", font_filename="H:\Pacific Again.ttf", \ text_color=$FF000000, halo_color=$FF000000) TextSubMod("H:\testsub.ass") Probably only adding a space for the text will be enough and then no need for the colors part: Code:
Subtitle(" ", first_frame=0, last_frame=1, font="Pacific Again", font_filename="H:\Pacific Again.ttf") In the .ass file there is this, only thing i done is a manual editing to test the non installed font, was Arial before "Pacific Again" : Quote:
Don't know if i am missing something or doing something wrong or if i am lucky but seems to work ¯\_(ツ)_/¯ Last edited by Yanak; 10th June 2018 at 10:24. |
|
10th June 2018, 10:38 | #6 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Also on Wiki,
Not processing frames plugin with Avisynth AtExit function Quote:
AtExit:- http://avisynth.nl/index.php/Filter_...lus_API#AtExit
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
|
12th June 2018, 16:59 | #8 | Link |
Registered User
Join Date: Oct 2011
Posts: 275
|
Good, at least this is one less thing to deal with, I don't know a way to read and extract directly without passing by the demuxing tool step, nobody answered to this so i doubt it is even possible from avisynth directly.
Probably making a script or batch file that will execute the demuxing using something like mkvextract to get all files needed and then maybe having this script pre-writing the start of .avs script too will make it way easier if you have a lot of those tasks to do... Inside Staxrip i used to have a small powershell script that allowed me to browse for any non-installed font on my computer and add some watermark text into a video with avisytnh "Subtitle" function, and the power-shell script was reading directly the name of the font ( as it often differs from the font file name itself ) and adding it + the path i browsed the font to my staxrip filter. Long time i did not mess with this and hard to recall everything i made at this time, but this is a part of the powsrshell script used in staxrip in case it could help if you decide to go this way, at least you have here how to get the font name from the tff file : Code:
$FileBrowse = New-Object System.Windows.Forms.OpenFileDialog -Property @{ Multiselect = $false Filter = 'fonts (*.ttf)|*.ttf' } # File type(s) [void]$FileBrowse.ShowDialog() #Get the font name from the browsed file if ($FileBrowse.FileNames -like "*\*") {$file = "`"$($FileBrowse.FileName)`"" Add-Type -AssemblyName System.Drawing $getfontname = new-object System.Drawing.Text.PrivateFontCollection $getfontname.AddFontFile($FileBrowse.FileNames) $selectfont = $getfontname.Families[-1].Name $selectedfont = "`"$($getfontname.Families[-1].Name)`"" $font = "font=$selectedfont, font_filename=$file" It is probably possible to do something a bit more complex that will first extract the .ass subtitle + the font ( and the cover pictures if there is some or if it's needed ) then read the font file name from the tff file and create a starting avisynth script, well i guess, like i said long time I didn't put my hands in this and my brain is rusty now But probably a simple script or batch file would ease your task by automating the extraction process. Good luck Last edited by Yanak; 12th June 2018 at 17:25. |
|
|