LoadPlugin([path]) loads the specified plugin function dll for use.
In my example script this line will be:
LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\DirectShowSource.dll")
DirectShowSource([path]) loads the specified video or audio file for processing using DirectShow.
In my example script this line will be:
aud=DirectShowSource("C:\videos\audio.mp3")
vid=DirectShowSource("C:\Videos\video.mpeg").ConvertToRGB32
ImageReader([path], start frame, end frame, frame rate, use DevIL, write info, pixel type) Loads the specified image file using the specified number of frames, frame rate, parser, and pixel type. If the image file is a single static image use start frame of 0 and end frame of 1. Frame rate should be set to match the frame rate of your original video (usually 29). The fields use DevIL and write info should be false. Pixel type must be RGB32 for the next video processing steps.
In my example script this line will be:
img=ImageReader("C:\Videos\logo.png", 0, 1, 29, false, false, "RGB32").ConvertToRGB32
ColorKeyMask(image, color code, tolerance)
If your image file does not have transparency built in (alpha channel) one color will need to be made transparent. Your logo file should have a single color background that does not appear anywhere else in the logo or else transparent 'holes' will appear wherever that color is present. The color code for white is $FFFFFF, black is $000000. Tolerance is best left at zero.
In my example script this line will be:
img=ColorKeyMask(img, $FFFFFF, $000000)
Layer(video,image,operation,mix,x,y)
The first parameter is the video clip we will be watermarking, the second is the image (or animation) the third is the type of operation we will perform (in this case add) with the specified mixture/opacity (255 is all image, 0 is all video) at the specified x,y position.
In my example script this line will be:
ovl=Layer(vid,img,"add",255,570,400)
AudioDub(video,audio)
Dub the audio stream of the second parameter over that of the first.
In my example script this line will be:
AudioDub(ovl,aud).ConvertToYUY2(matrix="rec709")
Now that I have provided a short description for each function in the script, here is the complete script for your modification. Simply change the path to the video, audio, and logo files to that of your own video, audio, and logo files then adjust the x,y position of the logo over your video.
#Load the DirectShowSource Plugin
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\DirectShowSource.dll")
#Load the audio source
aud=DirectShowSource("C:\videos\audio.mp3")
#Load the video source
vid=DirectShowSource("C:\Videos\video.mpeg").ConvertToRGB32
#Load the overlay image and convert to a clip
img=ImageReader("C:\Videos\logo.bmp", 0, 1, 29, false, false, "RGB32").ConvertToRGB32
#Make 'white' transparent
img=ColorKeyMask(img, $FFFFFF, $000000)
#Overlay the image onto the video
ovl=Layer(vid,img,"add",255,570,400)
#return the video with image overlay with audio remixed
AudioDub(ovl,aud).ConvertToYUY2(matrix="rec709")
Copy the example script and paste it into Notepad or another text editor (like Notepad ++) and save it with a .avs extention (instead of .txt).
Demo Your Video
Double click on your video, if prompted choose Windows Media Player or another media player.
If you see a message in red text, it indicates an error either with the script syntax, file location, or a plugin. Note the location (Line number etc) and look in your script.
Adjust your logo/watermark position as required (remember the last two parameters for Layer).
Using Avanti to Save Your Video
Launch Avanti and watch the status/log window towards the bottom. The last item displayed should be "Valid FFmpeg/AVISynth combo found ..." this means that the FFmpeg files were placed in the correct location and that the AVISynth engine is functioning correctly.
1. Click the folder next to the Source 1 field and find your avs script.
2. Click the folder next to the Destination field and select a location for the final video.
3. Choose your audio and video format and bitrate. I use 128kbps aac with 800kbps 720x480 mpeg4 video. Note that framerate conversion is often neccessary. 29.970 is normal for NTSC video.
4. Click Start process to begin the conversion process.
If everything goes as expected Avanti should produce a video where specified with your own logo.
If Avanti does not work for you, someone named Lukas has found a solution.
From his email he recommends to directly use FFmpeg - like this:
ffmpeg -i input.avs -sameq output.mpg
We would like to thank Lukas for his solution and thank you for reading!