Log in

View Full Version : Change the subtitle alignment in avisynth script


nel-son
21st April 2025, 09:08
Hi,

can i change the alignment of subtitle files in a avisynth script so that all subtitles displayed at the top or bottom instead the position from the file?

nel-son

StainlessS
21st April 2025, 12:35
Might help if you post MediaInfo output for the source. [ie does it have subtitle stream, or is it hard coded (burnt into the video)]

nel-son
21st April 2025, 13:52
Off course its not hard Coded. Subtitles are files (SRT, SSA vor idx/VOB).

StainlessS
21st April 2025, 15:25
Subtitles are files (SRT, SSA vor idx/VOB).
Unless they're hard coded of course.

can i change the alignment of subtitle files in a avisynth script so that all subtitles displayed at the top or bottom instead the position from the file?
No, not in avisynth script, unless you are going to burn them into the video.

Now that you have established that they are indeed editable, perhaps you can expect a little assistance from those that deal in such.

You really should provide a little more specific info in your opening post, guesswork is perhaps not the forte of all D9 members.

EDIT: You might also want to specifiy if source video is to just be remuxed, or re-encoded, and to what output format,
anyone that may want to assist will likely want to know such things.

johnmeyer
21st April 2025, 17:37
StainlessS' question about whether they are hard-coded was actually a very sensible question. Why? Because the question about subtitle placement in AVISynth makes no sense if they are SRT files since it is the player which determines placement.

From the Google Gemini overview, when I ask how SRT subtitle placement on the screen is determined:

"SRT subtitle placement on screen is typically handled by the playback application (like a video player) and not directly within the SRT file itself. "

hello_hello
27th April 2025, 12:09
I don't know about doing it an Avisynth script, but you can set the position of SSA subtitles. For a GUI or converting subtitles from one format to another, try Subtitle Edit (https://github.com/SubtitleEdit/subtitleedit/releases), although I couldn't seem to get the alignment to work as expected using Subtitle Edit's preview (I was only playing with setting a vertical margin with the subtitle configured to display bottom/centre) but when I saved the subtitle and opened it in a script it seemed to display in the correct position. You could also try Aegisub (https://aegisub.org/downloads/).
The ssa subtitle position can be configured using the default style or using different styles for individual lines.

For subtitles that display all over the screen such as some bluray subtitles, or in fact for most non-text subtitles, I use Subtitle Edit to convert them to text in order to encode them that way. The OCR process can be a bit tedious though.
You might even be able to edit an idx file directly to change the subtitle position with VobSub (https://www.videohelp.com/software/VobSub), so you wouldn't need to convert to another format. It's been a long time since of used VobSub for that sort of thing though so I don't know for sure.

[Script Info]
; This is a Sub Station Alpha v4 script.
Title:
ScriptType: v4.00
Collisions: Normal
PlayDepth: 0

[V4 Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding
Style: Default,Arial,20,65535,65535,0,0,0,0,1,1,1,2,10,10,55,0,1

[Events]
Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: Marked=0,0:00:01.00,0:00:21.00,*Default,NTP,0000,0000,0000,,Subtitle Text

FFMS2(SomeVideo.mkv)
TextSub(SomeSubtitle.ssa", 1)

https://i.ibb.co/GvtmzLtt/sub.jpg