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. |
20th December 2013, 02:03 | #1 | Link |
Registered User
Join Date: Jul 2011
Posts: 1,121
|
Subtitle, Aspect ratio?
If i want to have a subtitle on a video with non square pixels, how am i supposed to do it?
The only thing i can think of is Resizing the Video to make in 1:1 then add it and save the video. But not sure if that is the optimal way to go. |
20th December 2013, 02:42 | #2 | Link |
Excessively jovial fellow
Join Date: Jun 2004
Location: rude
Posts: 1,100
|
Stretch the subtitles appropriately before applying them. If you're using VSFilter this is trivial, just change the vertical or horizontal scaling factor in the text style in the subtitles file.
|
20th December 2013, 19:04 | #4 | Link | |
Retried Guesser
Join Date: Jun 2012
Posts: 1,373
|
You can fake it pretty well...
Quote:
Code:
ColorBars.KillAudio Subtitle("ROYGBIV", x=-1, y=100, spc=-10, font_width=6) Subtitle("ROYGBIV", x=-1, y=150, spc=0, font_width=0) ## width=default Subtitle("ROYGBIV", x=-1, y=200, spc=10, font_width=10) Subtitle("ROYGBIV", x=-1, y=250, spc=20, font_width=20) Last edited by raffriff42; 18th March 2017 at 01:18. Reason: (fixed image link) |
|
22nd December 2013, 18:33 | #6 | Link |
Registered User
Join Date: Oct 2011
Posts: 52
|
Code:
function SubtitleEx(clip c, string "text", int "x", int "y", int "first_frame", int "last_frame", string "font", \ int "size", int "text_color", int "halo_color", int "align", int "spc", int "lsp", \ float "font_base_width", float "font_angle", bool "interlaced", val "par") { font = Default(font, "Arial") size = Default(size, 18) fbws = font.LUIsEq("Arial||Calibri||Verdana", true) font_base_width = Select(fbws+1, Default(font_base_width,0), 0.42, 0.44, 0.47 ) Assert(IsString(par) || IsFloat(par) || !Defined(par), "SubTitleEx: par must be either a float or a prest") if (IsString(par)) { par_p = LuIsEq(par, "ntsc_wide||ntsc_full||pal_wide||pal_full", true) Assert(par_p>=0, "SubtitleEx: unknown preset") par = Select(par_p, 155200./127953, 38800./42651, 4600./3159, 1150./1053) } font_width = Defined(par) ? font_base_width * size / par : Undefined return c.Subtitle(text, x, y, first_frame, last_frame, font, size, text_color, halo_color, align, spc, \ lsp, font_width, font_angle, interlaced) } Last edited by zero9999; 23rd December 2013 at 01:40. Reason: i'm stupid |
22nd December 2013, 21:16 | #7 | Link | |
Registered User
Join Date: Oct 2007
Posts: 135
|
Quote:
Download aegisub to edit your subtitles, set the style x width to 84% (based on your later post DVD 16:9 anamorphic expansion; yes there is a way to calculate it: 720/853 [the final width of a 16:9 expansion of 480p content... ish, it's slightly messy]), load its vsfilter.dll, use textsub(). Problem solved. |
|
23rd December 2013, 01:53 | #9 | Link |
Retried Guesser
Join Date: Jun 2012
Posts: 1,373
|
Definitely, VSFilter sounds like a better way to do it ...except I think zerowalker is generating timestamp titles on the fly, based on a previous thread of his.
|
4th January 2014, 04:08 | #10 | Link |
Registered User
Join Date: Jul 2011
Posts: 1,121
|
I am willin to try Aegissubs, i can add it in the MKV, will save image information (compared to Hardsubs which canīt be removed) and it will be in the MKV and not take upp "space".
How can i make new lines in it? If i want for example to write. Date: xxxx Time: xxx And want it to look, just like that? For me it just getīs together, even if i make line jumps. EDIT: Okay found it out, i tried \n as itīs usually "new line", but you hade to write \N , not sure what \n does then, but i solved it. Thanks for mentioning it, this is probably a lot better solution for this kind, as i donīt have a timestamp on-the-fly here, and just write the dates on the file for archiving. Last edited by zerowalker; 4th January 2014 at 05:01. |
9th February 2014, 22:31 | #11 | Link |
Registered User
Join Date: Mar 2009
Posts: 32
|
I'm using Avisynth and Virtualdub to convert some old NTSC MiniDV tapes to mp4 format. I am manually adding date and time information using Avisynth's Subtitle filter and using x264 to encode. In my command line I have specified a sample aspect ratio of 8:9 to match the original NTSC format (correct me if I should use something else). This makes the subtitle text narrow. Text is Arial, size 34. What value should I use for spc or font_width to compensate for the 8:9 SAR? I have been playing around with different values but would like to know an exact value, without researching Visual C++ documentation as the Wiki mentions.
|
9th February 2014, 23:47 | #12 | Link | |
Formerly davidh*****
Join Date: Jan 2004
Posts: 2,496
|
I think the aspect ratio is actually 10:11 (though someone may correct me shortly).
As for what value you should use for font_width, I have no idea. I did a test, and determined that the default value for font_width is about 12.9 when the size is 30, which is meaningless to me. As the documentation says: Quote:
On the other hand, there's nothing actually wrong about displaying a font at a slightly different aspect ratio. I'd just experiment until it looks good to you. If I had to determine it experimentally, I'd create a clip and resize it by 8:9 horizontally, then stack it with an unresized subtitled clip and change the values until they matched. David |
|
10th February 2014, 03:16 | #13 | Link |
Registered User
Join Date: Mar 2009
Posts: 32
|
Thanks. I did some more testing and discovered spc is not what I want since it only increases space between characters but does not make them wider. I used font_width. Based on your info of font size 30 having a width of 12.9, for my size of 34 and aspect ratio of 9:8, I used (34/30)*12.9*(9/8) = 16.45. Rounding to the nearest 0.125, font_width=16.5. It looks about right, but is there a way to calculate the value without experimenting?
|
13th February 2014, 04:26 | #14 | Link |
Registered User
Join Date: Mar 2009
Posts: 32
|
I couldn't find any information on the default value for font_width to be able to calculate a new one, so I did some tests using the following simple script:
ColorBars.KillAudio Subtitle("TEXT SIZE 34 FONT_WIDTH=14",x=50,y=125,size=34,font_width=14) Subtitle("TEXT SIZE 34 FONT_WIDTH=14.125",x=50,y=150,size=34,font_width=14.125) Subtitle("TEXT SIZE 34 FONT_WIDTH=14.5",x=50,y=175,size=34,font_width=14.5) Subtitle("TEXT SIZE 34 FONT_WIDTH=0",x=50,y=200,size=34,font_width=0) Subtitle("TEXT SIZE 34 FONT_WIDTH=14.625",x=50,y=225,size=34,font_width=14.625) Subtitle("TEXT SIZE 34 FONT_WIDTH=14.75",x=50,y=250,size=34,font_width=14.75) Subtitle("TEXT SIZE 34 FONT_WIDTH=14.875",x=50,y=275,size=34,font_width=14.875) Result is attached. The default font_width for Arial text size 34 is slightly more than 14.5. Hope this helps someone. |
13th February 2014, 06:18 | #15 | Link |
Registered User
Join Date: Mar 2011
Posts: 4,829
|
I found this thread due to having the opposite question. When using vsfilter to add subtitles, how does it (appear to) determine the aspect ratio of the video for idx subtitles?
When encoding video with a script such as this, the end result seems to be exactly the same whether the video is resized to square pixels (as per the script) or the resizing is removed and an aspect ratio set instead. ie For the anamorphic version the hardcoded subtitles have the same dimensions once the video is resized to the correct aspect ratio on playback. LoadPlugin("C:\Program Files\MeGUI\tools\dgindex\DGDecode.dll") DGDecode_mpeg2source("D:\VTS_01_1.d2v") Spline36Resize(852,480) LoadPlugin("C:\Program Files\MeGUI\tools\avisynth_plugin\VSFilter.dll") VobSub("E:\subs.idx") |
13th February 2014, 14:31 | #16 | Link | |
Retried Guesser
Join Date: Jun 2012
Posts: 1,373
|
I assume font_width adjusts arguments to Windows TextOut and related API routines. I messed about with these a long time ago, and all I can remember is, it's complicated For example:
Quote:
Last edited by raffriff42; 14th February 2014 at 06:49. |
|
15th September 2014, 07:06 | #18 | Link |
Retried Guesser
Join Date: Jun 2012
Posts: 1,373
|
This is kind of interesting:
Subtitle: Animated parameter demonstration (avisynth wiki) (alignment; inter-character spacing; character width; inter-line spacing; angle) |
15th September 2014, 12:34 | #19 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Perhaps this of use to somebody:
Subtitle Character set. Code:
Function RT_SubTitleCharSet() { GSCript(""" S="" for(y=0,15) { s=s+"$"+RT_Hex(y*16,2)+ " " for(x=0,15) { n=y*16+x c=(n<32 || n > 223) ? "." : Chr(n) s=s+c } s=s+Chr(10) } """) S } Function RT_DebugCharSet() { GSCript(""" S="" for(y=0,15) { s=s+"$"+RT_Hex(y*16,2)+ " " for(x=0,15) { n=y*16+x c=(n<32) ? "." : Chr(n) s=s+c } s=s+Chr(10) } """) S } Function SubtitleCharSet() { GSCript(""" S="" for(y=0,15) { s=s+"$"+RT_Hex(y*16,2)+ " " for(x=0,15) { n=y*16+x c=(n<32) ? "." : Chr(n) s=s+c } s=s+"\n" } """) S } colorbars colorbars(width=360,height=512).Trim(0,-1) s=RT_StrReplace(SubtitleCharSet,Chr(10),"\n") Subtitle(s,font="Courier New",size=32,lsp=0) return Last
__________________
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 ??? Last edited by StainlessS; 27th February 2020 at 12:08. |
15th September 2014, 13:44 | #20 | Link |
Retried Guesser
Join Date: Jun 2012
Posts: 1,373
|
Interesting, if tangential to the topic.
BTW what does Chr(2000) give you, can you guess? How about Chr(-2000) ? . . . . . . . . . . . . . . . (answer: input % 256 in unsigned 32 bit math) Last edited by raffriff42; 15th September 2014 at 15:34. |
Thread Tools | Search this Thread |
Display Modes | |
|
|