VideoHelp Forum
+ Reply to Thread
Results 1 to 9 of 9
Thread
  1. I have some subtitles in PNG image sequence format. I was wondering if anyone knew of a way to use AVISynth to overlay this sequence of PNG subtitle files over a video source? I'm looking to "burn in" the subtitles and then do the transcode, so if anyone could please provide an example script it would be much appreciated. Thanks.
    Quote Quote  
  2. I assume you have transparency enabled on the png images? Otherwise you will get a big black block where they are overlayed

    You can do it for 1 at a time, but since the intervals and display time for each sub is different, there is no automated way to do this and it will take a long , long, long time for this project. It would be way faster in a NLE to do this, but you still have to do it manually for each subtitle segment to get the timings right.

    The basic syntax for a transparent overlay is this:

    Code:
    a1=avisource("movie.avi")
    a2=ImageReader("logo.png")
    a3=ImageReader("logo.png",pixel_type="RGB32").ShowAlpha(pixel_type="RGB32")
    Overlay(a1,a2,mask=a3)
    You would use the x,y positions in the Overlay() to denote position of the overlayed .png in pixels (e.g. at the bottom of the screen). e.g. Overlay(a1,a2,mask=a3,x=50,y=50) . But that is for 1 image... So you would have to manually do each sub using the Trim() command to specify each in terms of timing for a frame range...not fun...I hope you get the general idea...
    Quote Quote  
  3. Thanks. Yes, the PNGs have transparency. Would ImageSequence work for this too? The PNGs are synced to frame numbers, so frame 100 is PNG 100, and thus the overlay and timings aren't really that difficult. I would test this myself, but I don't have direct access to the PNGs at the moment.
    Quote Quote  
  4. OK that should be easier then, just use a wildcard for the naming. So assuming the .png images are the same dimensions as the video (if not, just use the x,y positions), and the fps is 23.976:

    Code:
    a1=AVISource("movie.avi")
    a2=ImageSource("sub%02d.png",01,99,23.976)
    a3=ImageSource("sub%02d.png",01,99,23.976,pixel_type="RGB32").ShowAlpha(pixel_type="RGB32")
    Overlay(a1,a2,mask=a3)
    That will overlay "sub01.png" to "sub99.png" sequentially on each frame (note that actually "sub01.png" will be overlayed on frame 0 which is the 1st frame in avisynth, so you may have to adjust the syntax or naming a bit).

    ImageSequence is the old plugin, and was replaced by ImageReader, which was replaced by ImageSource. The latter 2 are about the same and basically interchangable, although imagesource is supposed to be faster for single image loading

    You can find the other arguments, documentation and examples here, but that is the basic syntax.
    http://avisynth.org/mediawiki/ImageSource
    http://avisynth.org/mediawiki/Overlay
    Quote Quote  
  5. Thanks a lot for your assistance poisondeathray. I was hoping that ImageSource worked with image sequence masks. I use ImageSource when souring PNG or BMP files into a video sequence, and for adding simple stationary logo overlays, but I have never done image sequencing and masking together in the same script. Hopefully this will work out. I will let you know when I get the files tomorrow. Thanks again for your help!
    Quote Quote  
  6. Member
    Join Date
    Sep 2011
    Location
    Mother's Heart
    Search Comp PM
    i did not have it's script file i.e., .dill file. did you know where i can find it?
    Quote Quote  
  7. A three year old thread you're reopening? Are you talking about the AviSynth script file? Did you install AviSynth? Once that's done then you can use the script files you create.
    Quote Quote  
  8. Member
    Join Date
    Sep 2011
    Location
    Mother's Heart
    Search Comp PM
    yes i am bumping this thread. i found this thread in goole search. i have direct installation files of avisynth i use it from last 2 months. now i want to use overlay features. i had search all the installation files but did not find the script file of overlay, that's why i am asking it.
    Quote Quote  
  9. You find out the usage of the built-in filters at the AviSynth site. You find the usage of the third party filters usually in the included documentation.

    There's no ready made script for the built-in Overlay filter. You create the script yourself and modify it based on how you're using it (location or opacity, for example):

    http://avisynth.org/mediawiki/Overlay

    http://avisynth.org/mediawiki/Layer

    Here's an example of Overlay usage I have lying around:

    A=ImageSource("E:\Compilation DVDs\Padmini Final\Menu\IndianRed.bmp",End=1005)
    B=Import("E:\Compilation DVDs\Padmini Final\Menu\SongTemplate.avs")
    A=A.BilinearResize(640,480)
    A=A.ConvertToYUY2()
    Overlay(A,B,X=24,Y=60,Opacity=.75)
    Quote Quote  



Similar Threads

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