View Full Version : Using AVISynth to overlay PNG subtitles?
csdesigns
31st March 2009, 21:49
Does anyone know if it is possible to use AVISynth to overlay a sequence of PNG subtitle files over a video source? If so, could you please provide an example script? Much appreciation to any help that can be provided on this.
Adub
1st April 2009, 01:24
This idea has been brought up before, but I believe that, in short, there is not easy way, or plugin. This could have changed in the several months since I last saw a similar topic (use search), but I am pretty sure we are still SOL on that aspect.
You would think it would be easy to write a plugin of some sort that would accept a pointer to a directory with a specific file naming scheme and have it burn each png onto every subsequent frame. I personally do not posses the knowledge to write my own Avisynth plugin yet, but there may be others who do.
csdesigns
1st April 2009, 02:49
Since the PNGs are transparent, and each PNG equates to a specific frame number (ie, there are as many PNGs as there are frames in the video source), I think something like the following will work:a1=DirectShowSource("movie.avi")
a2=ImageSource("%06d.png", start=000001, end=011789, fps=24, pixel_type="rgb32")
a3=ImageSource("%06d.png",pixel_type="rgb32").ShowAlpha(pixel_type="rgb32")
Overlay(a1,a2,mask=a3)
I won't have the PNGs for available to me for a few more days yet, but if Overlay can work for image sequences, then hopefully this will work. I have used Overlay for simple logo insertion in the past, but never anything like this.
mk456
13th April 2009, 09:02
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:
: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...
I really hope that you get your answer you want!!!!!!
luv to hear Your thoughts!!
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.