Log in

View Full Version : Conditionally modify part of .ass files with Avisynth ?


wthreex
3rd October 2021, 12:06
Hey, I'm hardcoding subtitles into videos, The problem is the font size is slightly different when the video has black bar (1280x536p).

So i want to tell avisynth to modify .ass file (the font size part) when the video has fewer than 720p height i mean lower than: 1280x720p

I'm using VSFilter for this and my script is:


LoadPlugin("C:\Users\Downloads\Programs\MeGui\tools\avisynth_plugin\VSFilter.dll")
<input>
<resize>
TextSub("C:\Users\Downloads\Programs\MeGui\tag.ass")


.ass file:


[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Tahoma,20,&H0000FFFF,&H000000FF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,3,1,0.0671642,3,5,5,5,1


As you can see the font size is 20 for all the videos, is it possible to modify this part of file with avisynth on some condition ? Or forget about avisynth can we do this with Aegisub itself ?

FranceBB
3rd October 2021, 15:31
.ass subs should technically be scaling automatically according to the resolution, but only as long as the aspect ratio is maintained. In your case, AR ain't maintained, hence you see the issue. The best thing would be to change the resolution from aegisub itself.

P.s any particular reason for using vsfilter other than the fact that it's been around for years? You might wanna give AssRender() a shot. ;)

wthreex
3rd October 2021, 17:50
The best thing would be to change the resolution from aegisub itself.
thanks it helped!

wthreex
3rd October 2021, 18:10
Can we programmatically set aspect ratio for aeigsub? i dont want to manually edit the file for hundred of videos

FranceBB
3rd October 2021, 18:55
Can we programmatically set aspect ratio for aeigsub? i dont want to manually edit the file for hundred of videos

Yep, I think so.
I used to open corrupted .ass files with notepad, replace a bunch of stuff and then open them back with Aegisub, so I'm pretty sure that the AR is written somewhere in the syntax.

If you open the ass with a text editor you're gonna see a section called Script Info and that's what you gotta work with:

[Script Info]
; Script generated by Aegisub 2.1.8
; http://www.aegisub.org/
Title: Default Aegisub file
ScriptType: v4.00+
WrapStyle: 0
ScaledBorderAndShadow: yes
Collisions: Normal
Scroll Position: 618
Active Line: 654
Video Zoom Percent: 1
YCbCr Matrix: None
Last Style Storage: Default
PlayResX: 1280
PlayResY: 720
Video Aspect Ratio: 0
Video Zoom: 6
Video Position: 17
Video File: ?dummy:29.970000:999000:848:480:47:163:254:


this is just an example, but you can sort and replace the important bits automatically once you make a few tests. ;)

Back when I was working for Crunchyroll and Viewster I used to deal with .ass professionally a lot. Same goes for my early days as a fansubber (2006-2013). I remember I also wrote automation scripts in LUA to convert from 23.976 to 25 by speeding up the timecodes by 4% etc. I don't deal with those things that much nowadays (ever since I joined Sky in 2016); only when some movies need typesetting but that's pretty much it...

qyot27
3rd October 2021, 23:45
I don't find many occasions to edit .ass files without opening Aegisub to do it, but when I do, I use Prass (or if I'm being honest, sed; for loops optional).

The latest fork appears to be https://github.com/Ryu1845/Prass