-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a way to run Aegisub's resolution resampler in a python script? #29
Comments
Would something like this help? :) def resize_subs(subs, res_x_dest=1920):
res_x_src = int(subs.info["PlayResX"])
res_y_src = int(subs.info["PlayResY"])
scale = res_x_dest / float(res_x_src)
res_y_dest = int(scale * res_y_src)
# metadata
subs.info["PlayResX"] = str(res_x_dest)
subs.info["PlayResY"] = str(res_y_dest)
# styles
for style in subs.styles.values():
style.fontsize *= scale
style.marginl *= scale
style.marginr *= scale
style.marginv *= scale
style.outline *= scale
style.shadow *= scale
style.spacing *= scale
# events
# XXX If you have override tags in individual subtitles, fixing those would be more tricky, though perhaps fixing Aegisub's resolution resampler is implemented in C++ ( https://github.com/Aegisub/Aegisub/blob/ce658d070925effea8c626b2ada2f819d01ab4fb/src/resolution_resampler.cpp ) and is not exposed in its Lua API, as far as i can tell ( http://docs.aegisub.org/3.2/Automation/ ). |
Yeah that's more or less what I have. It's the individual subtitle tags that I'm having an issue with. I can set up the regex but I have to find all the tags I have to scale. So far I just have The tags look like this: I'm not really sure what the There are also I downloaded the aegisub source code from the github and want to send the needed parameters to resolution_resampler.cpp to scale everything before running the main script but can't get C++ (clang) to work with VSCode. |
Aegisub docs have a list of ASS override tags and their parameters: http://docs.aegisub.org/manual/ASS_Tags You should scale everything which is given in pixels: font size and spacing, outline, shadow, margins, If I remember correctly, the resolution given in ASS info section is virtual, anyway; during playback, the renderer rasterizes it depending on the actual video resolution (with some supersampling, 2x or 4x I think). So even if you have 640x480 ASS subtitles, they should not look blocky with full HD video. At least that was my experience with MPC-HC some years back. The C++ code I linked more for reference, it would most likely be faster to reimplement it from scratch in Python than frankenstein the backend of a monolithic C++ app to do something useful :) |
The issue I'm facing is that one .ass file is 720p and another is 1080p, so when I bring the styles and subs from 720 into 1080, all the 720 ones are drawn in a 1080 window, meaning they're essentially in their own little 720p layer on top of the already present 1080p subs. Re-implementing the C++ in Python requires knowing the C++ syntax :( Most of the syntax is easy enough but other parts are a bit confusing. For example:
What does the |
....and I've pretty much reimplemented the backend in Python. Just a couple classes left. |
I Would like this function too, i have many problem wiith this too |
If anyone wants to implement this, please feel free to open a pull request. Sketch of the implementation is in #29 (comment) but it would also need to support |
Filtering and merging two .ass files of differing PlayRes's makes the subs from the lower resolution file minuscule and off center.
The text was updated successfully, but these errors were encountered: