VideoHelp Forum
+ Reply to Thread
Results 1 to 20 of 20
Thread
  1. I'm referring to image based subs. The reason I'm asking is because the alignment info is lost when an image based sub is converted into srt. And if I would have a list of the lines not aligned bottom I could manually fix the corresponding lines in the srt file.
    Last edited by teodargent; 5th Jun 2019 at 16:58.
    Quote Quote  
  2. Don't know of any tool which does what you want out of the box.
    There are multiple image based subtitle formats, assuming you have a format which contains position data it should be possible to read this data and output it together with the time stamp (and/or file position).
    Got a sample of an image based subtitle file which has subtitles placed at the bottom and subtitles that are not placed at the bottom?
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  3. One possible way to do this in AviSynth is to create an all black video, overly the subs, crop away the bottom line worth of subs, then detect frames that aren't black and output the timecode or frame number to a text file.
    Quote Quote  
  4. Originally Posted by Selur View Post
    Don't know of any tool which does what you want out of the box.
    There are multiple image based subtitle formats, assuming you have a format which contains position data it should be possible to read this data and output it together with the time stamp (and/or file position).
    Got a sample of an image based subtitle file which has subtitles placed at the bottom and subtitles that are not placed at the bottom?
    I have these Blade Runner subs (vobsub). At min 00:13:58 line 155 "Puņ sollevare 150 chili [...]" is aligned top.
    Image Attached Files
    Last edited by teodargent; 5th Jun 2019 at 16:58.
    Quote Quote  
  5. Originally Posted by jagabo View Post
    One possible way to do this in AviSynth is to create an all black video, overly the subs, crop away the bottom line worth of subs, then detect frames that aren't black and output the timecode or frame number to a text file.
    Do you have the code for doing that? I don't think I'm able to do it myself.
    Quote Quote  
  6. Here's an example using your Blade Runner sub/idx:

    Code:
    BlankClip(width=720, height=576, length=180000, fps=25, pixel_type="YV12")
    #Mpeg2Source("Blade Runner (1982).d2v").ColorYUV(gain_y=-256)
    VOBSUB("Blade Runner (1982)")
    Crop(0,0,-0,504)
    Subtract(last, Loop(2,0,0))
    WriteFileIf(last, "nonbottom.txt", "(AverageLuma(last) > 126.01)", "current_frame/framerate", append = false)
    I created a black clip with the properties of the video using BlankClip(). You can see an alternate method of creating a black clip by actually opening the source video and making it black (doing it this way takes a little longer). VOBSUB() is used to overlay the subtitles. Crop() was used to remove the bottom of the frame -- where single line subs usually appear. You may have to alter this for different sized subs, fonts, etc. Subtract() is used to subtract the current frame from the previous frame. This lets us only look at transitions -- when a subtitle first appears and when it disappears. WriteFile() is used to print the time (in seconds.xxxxxx format) each time a new subtitle appears. Single line subs at the bottom of the frame aren't included in the list because we cropped off the bottom of the frame earlier. The output file, nonbottom.txt, looks like:

    Code:
    126.879997
    131.520004
    135.639999
    139.199997
    144.440002
    147.720001
    151.639999
    156.679993
    162.279999
    165.720001
    ...
    I don't know of any built in filter for converting seconds to hh:mm:ss.xx format that will work with WriteFile(). It's possible to do with a bunch of algebraic manipulation but I don't feel like thinking that hard. You can load the list into a spreadsheet to do the conversion.

    The script took about 3 minutes to run with 64 bit AviSynth+.

    Oh, I forgot to mention: I used VirtualDub to play through the entire script as fast as possible via File -> Run Video Analysis Pass.
    Quote Quote  
  7. Thanks a lot! That worked perfectly! But how do I use it with pgs/sup subs?
    Quote Quote  
  8. You just have to find an AviSynth filter that renders pgs/sup subs. I've never used it but... http://avisynth.nl/index.php/SupTitle Then use it instead of VOBSUB().
    Quote Quote  
  9. By the way, you'll have to change the frame dimensions, cropping, and maybe the frame rate to match the BD.
    Quote Quote  
  10. I only changed crop to Crop(0,0,-0,400) and it worked fine even though the BD is 1080p 23.976 fps
    Quote Quote  
  11. Originally Posted by teodargent View Post
    I only changed crop to Crop(0,0,-0,400) and it worked fine even though the BD is 1080p 23.976 fps
    I don't know how VOBSUB() handles subs that are positioned outside the frame. Maybe it scales the output to the frame size. Or maybe it just doesn't render the parts that would fall outside the frame. So the script may have run and produced an output file, but that file may not reflect all subs that aren't on the bottom line. I recommend you try 1920x1080 and see how the list compares to your 720x576 run.
    Quote Quote  
  12. It looks like it scales the subs. The first screenshot is at 720x576, the second at 1920x800 (same as the subs source).
    Image
    [Attachment 49275 - Click to enlarge]

    Image
    [Attachment 49276 - Click to enlarge]

    Also the output was the same but at the higher resolution took a lot longer to complete. Is it possible to also have a visual output while processing? Like seeing the actual frames with the top aligned subs.
    Last edited by teodargent; 5th Jun 2019 at 16:59.
    Quote Quote  
  13. If you want to see the full frame with subtitles:

    Code:
    BlankClip(width=720, height=576, length=180000, fps=25, pixel_type="YV12")
    VOBSUB("Blade Runner (1982).idx")
    src=last
    Crop(0,0,-0,504) # remove bottom line of subs
    Subtract(last, Loop(2,0,0))
    WriteFileIf(last, "nonbottom.txt", "(AverageLuma(last) > 126.01)", "current_frame/framerate", append = false)
    StackHorizontal(src, last.AddBorders(0,0,src.width-last.width, src.height-last.height))
    That will stack the full black frame with subtitles and the cropped test clip side by side. It's necessary to use the output of Subtract() (WriteFile() doesn't count) in the output of the script (optimization within AviSynth will skip unused code paths). So one can't just return(src) at the end.

    Another possibility is to overlay the test clip onto the video. Instead of StackHorizontal() use:

    Code:
    Overlay(src, last, opacity=0.5) # use any opacity you want
    Quote Quote  
  14. Hi! I just tried SupTitle but I can't get it to work. I tried this and it worked:
    Code:
    LoadPlugin("C:\Program Files (x86)\AviSynth\plugins\ffms2.dll")
    FFVideoSource("v.avi")
    SupTitle("C:\Users\Teodor\Desktop\Extract subs alligned top\s.sup")
    Then i tried this but VirtualDub crashed after 20 seconds:
    Code:
    BlankClip(width=720, height=576, length=320000, fps=25, pixel_type="YV12")
    SupTitle("C:\Users\Teodor\Desktop\Extract subs alligned top\s.sup")
    Can you help me out with this? I attached a .sup file (line at 00:01:33 should be aligned top).
    Image Attached Files
    Quote Quote  
  15. Those sup subs probably came from a Blu-Ray disc. They expect a frame size of 1920x1080. You can upscale your source, add the subs, then downscale back to the original size -- but the subs will be really tiny.
    Quote Quote  
  16. Originally Posted by jagabo View Post
    Those sup subs probably came from a Blu-Ray disc. They expect a frame size of 1920x1080. You can upscale your source, add the subs, then downscale back to the original size -- but the subs will be really tiny.
    Sorry but I'm a total noob and I didn't understand what you meant. I tried this:

    Code:
    BlankClip(width=1920, height=1080, length=320000, fps=25, pixel_type="YV12")
    SubTitle("C:\Users\Teodor\Desktop\Extract subs alligned top\s.sup")
    src=last
    Crop(0,0,-0,500) # remove bottom line of subs
    Subtract(last, Loop(2,0,0))
    WriteFileIf(last, "nonbottom.txt", "(AverageLuma(last) > 126.01)", "current_frame/framerate", append = false)
    Overlay(src, last, opacity=0.5) # use any opacity you want
    but it didn't work. Is it possible that SubTitle does not work with BlankClip?
    Quote Quote  
  17. A black clip is ok. You called SubTitle() instead of SupTitle(). Cropping 500 lines seems excessive. Maybe you only care about the top half?
    Quote Quote  
  18. Originally Posted by jagabo View Post
    A black clip is ok. You called SubTitle() instead of SupTitle().
    *facepalm*

    Originally Posted by jagabo View Post
    Cropping 500 lines seems excessive. Maybe you only care about the top half?
    Yes, that is what I care about.

    Anyway, using SupTitle and 1920x1080 works fine but takes a long time to complete. Since Suptitle does not resize the subs like VOBSUB, I found that the best workaround is to convert the the .sup subs in vobsub using BDSup2Sub and then use the script with VOBSUB (240x100, very fast).
    Quote Quote  
  19. Originally Posted by teodargent View Post
    Anyway, using SupTitle and 1920x1080 works fine but takes a long time to complete.
    Yes, the larger frame takes longer to complete. And note that your script created a ~3.5 hour blank clip. Probably longer than the real movie. Specifying the real runtime of the movie would cut down the processing time. Or you can just terminate processing once the preview has exceeded the movie length.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!