View Full Version : Merging a picture with a set amount of frames
Typhoon792
4th May 2009, 04:02
Is there a way, using AviSynth, to basically merge a picture with the video source from a certain point in time/frame to another point?
poisondeathray
4th May 2009, 05:13
Is there a way, using AviSynth, to basically merge a picture with the video source from a certain point in time/frame to another point?
Define "merge"
If you mean: frame of video - picture - frame of video, you can use the ImageSource() and Trim() commands
or do you mean like a blended mask?
Typhoon792
4th May 2009, 06:04
Define "merge"
If you mean: frame of video - picture - frame of video, you can use the ImageSource() and Trim() commands
or do you mean like a blended mask?
Umm.. I'm not sure what I mean. I just want to lay a PNG with transparent properties over a certain area of the video I'm encoding. I don't want it to be a separate video stream. The picture and video are already the same resolution so I don't need to position it. I think I mean frame of video + picture = new frame in video.
poisondeathray
4th May 2009, 06:08
Yep you can do it, it's called transparent overlay :) , e.g. a logo
You can do it with the combination of ImageSource, ShowAlpha, Overlay and your source filter
Typhoon792
4th May 2009, 06:15
Yep you can do it, it's called transparent overlay :) , e.g. a logo
You can do it with the combination of ImageSource, ShowAlpha, Overlay and your source filter
Lol, umm.. I've never used any of those methods so just to save me the trouble, you think you can put the actual code for it?
Instead of the actual file names, just put whatever.d2v and whatever.png or... whatever, lol. Obviously, just everything random, like the time between where that picture is placed. Thanks ;)
poisondeathray
4th May 2009, 06:19
You should read the documentation, both to learn and to see the other commands e.g. if you wanted to overlay on a range, or move the overlay x,y coordinates, etc...
Here is the basic syntax for one way of doing it:
a1=avisource("file.avi")
a2=ImageReader("logo.png")
a3=ImageReader("logo.png",pixel_type="RGB32").ShowAlpha(pixel_type="RGB32")
Overlay(a1,a2,mask=a3)
PS What happened to your other account :)
Typhoon792
4th May 2009, 06:21
You should read the documentation, both to learn and to see the other commands e.g. if you wanted to overlay on a range, or move the overlay x,y coordinates, etc...
Here is the basic syntax for one way of doing it:
a1=avisource("file.avi")
a2=ImageReader("logo.png")
a3=ImageReader("logo.png",pixel_type="RGB32").ShowAlpha(pixel_type="RGB32")
Overlay(a1,a2,mask=a3)
PS What happened to your other account :)
My other account?.. <whistles>
Anyway, umm, yeah. I'll look into the documentation, but I wasn't sure what does what till I actually saw the code. Uh, one thing though. What's the a= stuff?...
EDIT: NVM.. I'm dumb. You're setting values to pass into Overlay.. Thanks
Typhoon792
4th May 2009, 08:53
You should read the documentation, both to learn and to see the other commands e.g. if you wanted to overlay on a range, or move the overlay x,y coordinates, etc...
Here is the basic syntax for one way of doing it:
a1=avisource("file.avi")
a2=ImageReader("logo.png")
a3=ImageReader("logo.png",pixel_type="RGB32").ShowAlpha(pixel_type="RGB32")
Overlay(a1,a2,mask=a3)
PS What happened to your other account :)
Hmm... It doesn't appear to be working. Might I be missing some DLL files for this? I mean, I didn't get any error message though.
Anyway, here's my code:
MPEG2Source("D:\David\Source Material\For Encoding or Editing\DBZ Remastered\Episode 231\DBZ.d2v")
Import("D:\David\Encoding\Encoding Settings\AviSynth\DBZ Remastered - Seasons 3 (2nd half), 4, 5, & 7-9 (720p).avs")
a1=MPEG2Source("D:\David\Source Material\For Encoding or Editing\DBZ Remastered\Episode 231\DBZ.d2v")
a2=ImageReader("D:\David\Source Material\For Encoding or Editing\DBZ Remastered\Episode 231\Ep. 231.png")
a3=ImageReader("D:\David\Source Material\For Encoding or Editing\DBZ Remastered\Episode 231\Ep. 231.png",pixel_type="RGB32").ShowAlpha(pixel_type="RGB32")
Overlay(a1,a2,mask=a3)
The avs I'm importing is:
/*DBZ Remastered (720p) AVS, by Typhoon859*/
LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\ColorMatrix.dll")
LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\FFT3DFilter.dll")
LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\UnDot.dll")
LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\RemoveGrain.dll")
LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\FluxSmooth.dll")
LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\Toon-v1.0.dll")
LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\Warpsharp.dll")
Import("C:\Program Files (x86)\AviSynth 2.5\plugins\LimitedSharpenFaster.avs")
ColorMatrix(mode="Rec.601->Rec.709")
crop(2,2,-2,-2,true)
FFT3DFilter(sigma=2.5)
UnDot()
FluxSmoothST(7,7)
Toon(.4)
LimitedSharpenFaster(ss_x=1.0,ss_y=1.0,Smode=3,strength=30)
WarpSharp(10,1)
Tweak(hue=-1.5, bright=-2, cont=1.01, sat=1.1)
LanczosResize(1280,720)
/*h264 @ 3500kbps*/
Without the additional code, it works fine. With the code, nothing from what I imported works and neither does the picture appear.
Here's a link to the picture: http://fs9.mybloop.com/image-handler/optimized/30/3802287
*Also, if this ends up working, in which method do I set the time in between which I want this image to appear? I don't want the image to be throughout the entire video..
Gavino
4th May 2009, 10:09
Don't just cut and paste - try and understand what the script is doing and adapt it to your needs. You want the overlay to be applied to the video after the imported script has done its work? Then instead of a1=MPEG2Source(...), just set a1=last.
Also, instead of calling ImageReader twice, you can do it like this:
a2=ImageReader("logo.png",pixel_type="RGB32")
Overlay(a1,a2,mask=a2.ShowAlpha())
To apply the overlay to just a portion of the video, you would need to trim and splice the sections involved, or use stickboy's JDL_ApplyRange (http://avisynth.org/stickboy/jdl-range.avsi) function.
Typhoon792
4th May 2009, 10:21
Don't just cut and paste - try and understand what the script is doing and adapt it to your needs. You want the overlay to be applied to the video after the imported script has done its work? Then instead of a1=MPEG2Source(...), just set a1=last.
Also, instead of calling ImageReader twice, you can do it like this:
a2=ImageReader("logo.png",pixel_type="RGB32")
Overlay(a1,a2,mask=a2.ShowAlpha())
To apply the overlay to just a portion of the video, you would need to trim and splice the sections involved, or use stickboy's JDL_ApplyRange (http://avisynth.org/stickboy/jdl-range.avsi) function.
Yeah, it works now. Thanks. And yeah, I'll definitely look into the script itself. I'm just in a rush right now - busy. And yeah, Stickboy's JDL_ApplyRange function looks perfect.
Now that we're at this point already, time to ask for something that might be pushing it a little. Aside from just appearing, is there a way to get the image to fade in and fade out?
Gavino
4th May 2009, 10:35
Aside from just appearing, is there a way to get the image to fade in and fade out?
Sure. A little thought (you're not that busy, surely ;)) would indicate that using a2.FadeIO(...) in the Overlay will do this.
Well actually, it's just the mask that needs to be faded in and out, so I should have thought just a bit longer. :)
Overlay(a1, a2, mask=a2.ShowAlpha().FadeIO(...))
Typhoon792
4th May 2009, 10:44
Sure. A little thought (you're not that busy, surely ;)) would indicate that using a2.FadeIO(...) in the Overlay will do this.
Lol, well currently I am. In two days I'll be able to check it out. It's 5:42 in the morning and I have to leave my house at 7... Still haven't slept and still a lot to do. I'm busy XD.
Anyway, cool, thank you. I really appreciate it. 100% solved. That's what I like to see.
EDIT: Erm.. spoke to soon. I get an error saying that it doesn't know what a1 is. It stopped working when I added the JDL_ApplyRange. I don't understand what one has to do with another.
MPEG2Source("D:\David\Source Material\For Encoding or Editing\DBZ Remastered\Episode 231\DBZ.d2v")
Import("D:\David\Encoding\Encoding Settings\AviSynth\DBZ Remastered - Seasons 3 (2nd half), 4, 5, & 7-9 (720p).avs")
a1=last
a2=ImageReader("D:\David\Source Material\For Encoding or Editing\DBZ Remastered\Episode 231\Ep. 231.png", pixel_type="RGB32")
JDL_ApplyRange(1377, 1553, "Overlay(a1, a2, mask=a2.ShowAlpha())")
In the AVS I'm importing, I added the necessary plugin and imported JDL-Range.avsi.
Gavino
4th May 2009, 11:18
A quick and nasty solution (since you're in a hurry :)) is just to make a1 and a2 global.
Or you could do the trim and splice manually:
a1.Trim(0,1376) + Overlay(a1.Trim(1377,1553),a2,mask=a2.ShowAlpha()) + a1.Trim(1554,0)
Typhoon792
4th May 2009, 11:34
A quick and nasty solution (since you're in a hurry :)) is just to make a1 and a2 global.
Or you could do the trim and splice manually:
a1.Trim(0,1376) + Overlay(a1.Trim(1377,1553),a2,mask=a2.ShowAlpha()) + a1.Trim(1554,0)
No idea what trim and splice means so I'll just make them global, although I hate doing that. Why exactly do they have to be global in this situation?
EDIT: Lol, wow, I suck.. All I need to do to make them global is to move them above my import line for the AVS right? I did it but the issue remains.
EDIT_2: Uhh, what's the actual right solution here? I decided I'm not going to school, screw it. Too much I still haven't finished. Plus, it's like the last marking period of high school - what's it going to matter? So yeah, I have time now until sleep wins and I fall unconscious.
Gavino
4th May 2009, 12:00
You make a variable global (see here (http://avisynth.org/mediawiki/Script_variables)) by saying "global a1 = ..." instead of "a1=..." (not moving it).
a1 and a2 need to be global here because JDL_ApplyRange is a script function, not a plugin. Probably, one of the functions in stickboy's RemapFrames plugin would work better here - check it out when you have time.
Trim (http://avisynth.org/mediawiki/Trim) and splice (http://avisynth.org/mediawiki/Splice) is just what I wrote, using the Trim and + (or ++) functions, to select and join a range of frames.
Typhoon792
4th May 2009, 12:13
You make a variable global (see here (http://avisynth.org/mediawiki/Script_variables)) by saying "global a1 = ..." instead of "a1=..." (not moving it).
a1 and a2 need to be global here because JDL_ApplyRange is a script function, not a plugin. Probably, one of the functions in stickboy's RemapFrames plugin would work better here - check it out when you have time.
Trim (http://avisynth.org/mediawiki/Trim) and splice (http://avisynth.org/mediawiki/Splice) is just what I wrote, using the Trim and + (or ++) functions, to select and join a range of frames.
I see. Now that I thought about where the code is jumping back and forth between, I see that they would only work not global if it weren't a script function. Alright thank you. That problem is solved, but yet again, I get a new one.
It says that there is no function named "Trim2" and that the problem is on line 53 of JDL-Range.avsi via the JDL_ApplyRange method call (line 7 of my main AVS). Is this just me missing something?
Gavino
4th May 2009, 12:30
It says that there is no function named "Trim2" and that the problem is on line 53 of JDL-Range.avsi via the JDL_ApplyRange method call (line 7 of my main AVS). Is this just me missing something?
If you look at the source of JDL_ApplyRange, it says it requires jdl-util.avsi - get it from stickboy's page (http://avisynth.org/stickboy/), which has many other useful goodies.
(or revert to doing the trim manually instead, as I showed)
Typhoon792
4th May 2009, 12:49
If you look at the source of JDL_ApplyRange, it says it requires jdl-util.avsi - get it from stickboy's page (http://avisynth.org/stickboy/), which has many other useful goodies.
(or revert to doing the trim manually instead, as I showed)
Thank you, I actually forgot to copy that to the actual plug-ins folder. I read that it had to be there - my bad... It all cleared now but there's still a problem. Sigh.. Sorry. Without JDL_ApplyRange, the fade in that I added worked. With it, it doesn't.
global a1=last
global a2=ImageReader("D:\David\Source Material\For Encoding or Editing\DBZ Remastered\Episode 231\Ep. 231.png", pixel_type="RGB32")
JDL_ApplyRange(1350, 1553, "Overlay(a1, a2, mask=a2.ShowAlpha().FadeIn(27))")
This I can't even relate to anything at all o.0;; You're the master though - I'm sure you'll get it.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.