VideoHelp Forum
+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 30 of 37
Thread
  1. Member
    Join Date
    Feb 2011
    Location
    Croatia
    Search Comp PM
    I have a .mpg file that I wanna encode with MeGUI to x264 .mkv. I know how to do that, but I also wanna add a watermark(lets say that I have a .jpg or .png picture on my HDD). So I wanna know how to add it to the video(and if possible to a specific time in the video). I used Google but all I found was some shitty programs with which I need to re-encode the previously encoded x264 .mkv and that destroys the video quality. That is why I'm asking if it is possible to add the watermark when I'm encoding the video from the .mpg with MeGUI so that it needs only one encode. I hope you understand what I want

    btw the current script is :

    Code:
    LoadPlugin("C:\Program Files (x86)\MeGUI\tools\dgindex\DGDecode.dll")
    DGDecode_mpeg2source("E:\New folder\file.d2v")
    Load_Stdcall_Plugin("C:\Program Files (x86)\MeGUI\tools\yadif\yadif.dll")
    Yadif(order=1)
    crop( 2, 2, -2, -2)
    
    Spline36Resize(704,400) # Spline36 (Neutral)
    #denoise
    Quote Quote  
  2. Use the Overlay() filter.

    http://avisynth.org/mediawiki/Overlay

    Use an alpha mask for transparency. Here's a thread with some use of Overlay():

    https://forum.videohelp.com/threads/297982-Adding-Transparent-Logos-onto-VOB-Files
    Last edited by jagabo; 5th Jul 2011 at 14:42.
    Quote Quote  
  3. Member
    Join Date
    Feb 2011
    Location
    Croatia
    Search Comp PM
    Thank you very much I understood everything except how to add it at a precise time. I want it to appear somewhere in the beginning, then I want that the watermark disappears after, lets say 10 seconds, and then I want it to appear somewhere in the middle of the video and then that it disappears again after 5 seconds. How do I do that ?
    Quote Quote  
  4. You can use Trim() to divide up your video into segments that have or don't have the watermark, and then join them with "++" or aligned splice
    A ++ B ++ C ++ D

    This is an example using ReplaceFramesSimple
    https://forum.videohelp.com/threads/315776-Adding-Watermark-To-Video-using-Megui
    Quote Quote  
  5. Member
    Join Date
    Feb 2011
    Location
    Croatia
    Search Comp PM
    Thank you very much for your help. I managed to do it using ReplaceFramesSimple
    Quote Quote  
  6. Member
    Join Date
    Feb 2011
    Location
    Croatia
    Search Comp PM
    Is it possible to make the watermark rotate using Avisynth ?
    Quote Quote  
  7. You mean animated? Like a few degrees per frame?
    http://avisynth.org.ru/rotate/rotate.html
    Quote Quote  
  8. Member
    Join Date
    Feb 2011
    Location
    Croatia
    Search Comp PM
    Yes, animated. When I use this rotate plugin, it just rotates the entire picture with the watermark. There is no animated rotation of the watermark.
    Quote Quote  
  9. Originally Posted by AlienWare View Post
    Yes, animated. When I use this rotate plugin, it just rotates the entire picture with the watermark. There is no animated rotation of the watermark.
    You need to couple Rotate() with Animate():

    Animate(src, 0, 180, "Rotate", 0, 0, 0, 0, 360, 0, 0, 0)
    That will rotate src from 0 to 360 degrees over 180 frames.
    Quote Quote  
  10. Member
    Join Date
    Feb 2011
    Location
    Croatia
    Search Comp PM
    When I add your line, nothing works anymore The watermark is not animated, and it doesn't disappear when it should.

    The current script is :

    Code:
    LoadPlugin("C:\Program Files (x86)\MeGUI\tools\dgindex\DGDecode.dll")
    LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\RemapFrames.dll")
    LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\Rotate.dll")
    a1=DGDecode_mpeg2source("E:\New folder\1.d2v")
    Load_Stdcall_Plugin("C:\Program Files (x86)\MeGUI\tools\yadif\yadif.dll")
    a2=ImageReader("E:\New folder\watermark 1.png")
    a3=ImageReader("E:\New folder\watermark 1.png",pixel_type="RGB32").ShowAlpha(pixel_type="RGB32")
    a4=Overlay(a1,a2,mask=a3, x=20, y=20)
    ReplaceFramesSimple(a1, a4, mappings="[26 345][1250 1920][2699 2999]")
    Animate(a4, 0, 180, "Rotate", 0, 0, 0, 0, 360, 0, 0, 0) 
    Yadif(order=1)
    crop( 2, 2, -2, -2)
    Spline36Resize(704,400) # Spline36 (Neutral)
    #denoise
    Where is the problem ?
    Quote Quote  
  11. You can't just throw the line in anywhere. Add Animate to the watermark (a2) and its alpha channel (a3).
    Quote Quote  
  12. Member
    Join Date
    Feb 2011
    Location
    Croatia
    Search Comp PM
    Like this ?

    Code:
    LoadPlugin("C:\Program Files (x86)\MeGUI\tools\dgindex\DGDecode.dll")
    LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\RemapFrames.dll")
    LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\Rotate.dll")
    a1=DGDecode_mpeg2source("E:\New folder\1.d2v")
    Load_Stdcall_Plugin("C:\Program Files (x86)\MeGUI\tools\yadif\yadif.dll")
    a2=ImageReader("E:\New folder\watermark 1.png")
    a3=ImageReader("E:\New folder\watermark 1.png",pixel_type="RGB32").ShowAlpha(pixel_type="RGB32")
    a4=Overlay(a1,a2,mask=a3, x=20, y=20)
    Animate(a2, 0, 180, "Rotate", 0, 0, 0, 0, 360, 0, 0, 0)
    Animate(a3, 0, 180, "Rotate", 0, 0, 0, 0, 360, 0, 0, 0)
    ReplaceFramesSimple(a1, a4, mappings="[26 345][1250 1920][2699 2999]")
    Yadif(order=1)
    crop( 2, 2, -2, -2)
    Spline36Resize(704,400) # Spline36 (Neutral)
    #denoise
    I get a error :
    Rotate : image format must be RGB32 or YV12!
    Quote Quote  
  13. make separate video with animated logo/overlay - use this video in loop with overlay, this should be faster than complicated script
    Quote Quote  
  14. Member
    Join Date
    Feb 2011
    Location
    Croatia
    Search Comp PM
    Thank you pandy for the help, but I want to do it with AviSynth and I think that I'm almost there Plus your way sounds more complicated to me
    Quote Quote  
  15. LoadPlugin("C:\Program Files (x86)\MeGUI\tools\dgindex\DGDecode.dll")
    LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\RemapFrames.dll")
    LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\Rotate.dll")
    a1=DGDecode_mpeg2source("E:\New folder\1.d2v")
    Load_Stdcall_Plugin("C:\Program Files (x86)\MeGUI\tools\yadif\yadif.dll")
    a2=ImageReader("E:\New folder\watermark 1.png",pixel_type="RGB32").Animate(0, 180, "Rotate", 0, 0, 0, 0, 360, 0, 0, 0)
    a3=ImageReader("E:\New folder\watermark 1.png",pixel_type="RGB32").ShowAlpha(pixel_type="R GB32").Animate(a3, 0, 180, "Rotate", 0, 0, 0, 0, 360, 0, 0, 0)
    a4=Overlay(a1,a2,mask=a3, x=20, y=20)
    ReplaceFramesSimple(a1, a4, mappings="[26 345][1250 1920][2699 2999]")
    Yadif(order=1)
    crop( 2, 2, -2, -2)
    Spline36Resize(704,400) # Spline36 (Neutral)
    #denoise
    Quote Quote  
  16. I too was wondering how to do this and ended up with:
    Code:
    LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\rotate\Rotate.dll") #http://avisynth.org.ru/rotate/rotate.html
    
    image = ImageReader("logo.png",pixel_type="RGB32") #Image
    imageMask = ImageReader("logo.png",pixel_type="RGB32").ShowAlpha(pixel_type="RGB32") #Mask
    video = avisource("test.avi") #VideoSource
    
    #rotate logo&mask and then overlay them onto the clip 
    function myOverlay(clip video, clip image, clip imageMask, int rot) {
        return Overlay(video,image.Rotate(rot),mask=imageMask.Rotate(rot))    
    }
    
    length = video.framecount-1 #number of frames in the clip; -1 since Avisynth starts count at 0
    Animate(video, 0, length, "myOverlay", image, imageMask, 0, image, imageMask, length)
    Cu Selur
    Quote Quote  
  17. Member
    Join Date
    Feb 2011
    Location
    Croatia
    Search Comp PM
    Thanks you for your help I tried your script and it gave me an error :
    I don't know what "a3" means
    So I changed this line :

    Code:
    a3=ImageReader("E:\New folder\watermark  1.png",pixel_type="RGB32").ShowAlpha(pixel_type="RGB32").Animate(a3,  0, 180, "Rotate", 0, 0, 0, 0, 360, 0, 0, 0)
    to this :

    Code:
    a3=ImageReader("E:\New folder\watermark  1.png",pixel_type="RGB32").ShowAlpha(pixel_type="RGB32").Animate(0, 180, "Rotate", 0, 0, 0, 0, 360, 0, 0, 0)
    The watermark disappears when it should, but there is no animated rotating Where is the problem now ?
    Quote Quote  
  18. @jagabo: shouldn't the deinterlacer be called before doing any overlay&co? (otherwise it might cause problems)

    @Alienware: try:
    Code:
    LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\rotate\Rotate.dll") #http://avisynth.org.ru/rotate/rotate.html
    LoadPlugin("C:\Program Files (x86)\MeGUI\tools\dgindex\DGDecode.dll")
    Load_Stdcall_Plugin("C:\Program Files (x86)\MeGUI\tools\yadif\yadif.dll")
    video = DGDecode_mpeg2source("E:\New folder\file.d2v")
    video = video.Yadif(order=1)
    video = video.crop( 2, 2, -2, -2)
    video = video.Spline36Resize(704,400)
    
    image = ImageReader("logo.png",pixel_type="RGB32")
    imageMask = ImageReader("logo.png",pixel_type="RGB32").ShowAlpha(pixel_type="RGB32")
    
    function myOverlay(clip video, clip image, clip imageMask, int rot) {
        return Overlay(video,image.Rotate(rot),mask=imageMask.Rotate(rot))    
    }
    
    length = video.framecount-1
    Animate(video, 0, length, "myOverlay", image, imageMask, 0, image, imageMask, length)
    ConvertToYv12()
    Quote Quote  
  19. I wasn't even looking at the rest of the script.
    Quote Quote  
  20. Member
    Join Date
    Feb 2011
    Location
    Croatia
    Search Comp PM
    Thanks you very much, Selur Your script works, but how do I specify these options now ?

    1. The position of the watermark ? (now the watermark is located in the upper left corner)
    2. The opacity of the watermark ?
    3. And the most important is how do I specify on what frames do I want that watermark ? (I had this line for that purpose before - ReplaceFramesSimple(a1, a4, mappings="[26 345][1250 1920][2699 2999]")

    @jagabo

    Where is the problem in your script ?
    Quote Quote  
  21. 1&2-> You need to adjust the Overlay call accordingly (should be simple, if you read: http://avisynth.org/mediawiki/Overlay)
    3-> you got different options:
    a. you could simply add mutiple Animate calls, atm. there is a single Animate call which runs for 0 to length but you could do three calls each staring and ending at the frames you like
    b. you could use trim and split the video in multiple parts, call Animate on each part and then join them afterwards
    c. you could use multiple ApplyRange calls
    d. you could mix jagabos and my script

    All in all, in think with a bit time spend reading the Avisynth documentation and trying to unterstand how jagabo and I approached the problem you should be fine.

    Cu Selur
    Quote Quote  
  22. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    What you all appear to be missing is that you don't need to apply Animate to Rotate - the function itself has a built-in animation feature using the start, end and endAngle parameters. In fact, jagabo's script with
    Animate(0, 180, "Rotate", 0, 0, 0, 0, 360, 0, 0, 0)
    has no effect since the start and end frames passed to Rotate are always 0.

    Also, you can do the rotation once on the logo clip before splitting off the mask rather than doing it twice (and no need to load the image twice either).
    Try this:
    Code:
    ... # LoadPlugin etc
    a1=DGDecode_mpeg2source("E:\New folder\1.d2v").Yadif(order=1)
    a2=ImageReader("E:\New folder\watermark 1.png",end=a1.Framecount-1,pixel_type="RGB32")
    a2=a2.Rotate(endangle=360) # or some other angle, say 3600 for 10 rotations
    a3=a2.ShowAlpha()
    a4=Overlay(a1,a2,mask=a3, x=20, y=20)
    ReplaceFramesSimple(a1, a4, mappings="[26 345][1250 1920][2699 2999]")
    crop( 2, 2, -2, -2)
    Spline36Resize(704,400)
    Quote Quote  
  23. Originally Posted by Gavino View Post
    What you all appear to be missing is that you don't need to apply Animate to Rotate - the function itself has a built-in animation feature using the start, end and endAngle parameters. In fact, jagabo's script with
    Animate(0, 180, "Rotate", 0, 0, 0, 0, 360, 0, 0, 0)
    has no effect since the start and end frames passed to Rotate are always 0.
    It worked for me? Although it stopped at 360 degrees (eg, if I asked for 720 degrees). I didn't realize it had its own animation feature though.

    I just looked again and the version of Rotate() I have doesn't have an animation feature:

    Rotate (clip, float "angle", int "width", int "height", int "color")
    Last edited by jagabo; 6th Jul 2011 at 18:41.
    Quote Quote  
  24. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    Originally Posted by jagabo View Post
    I just looked again and the version of Rotate() I have doesn't have an animation feature:

    Rotate (clip, float "angle", int "width", int "height", int "color")
    Ah, that explains the difference, since I just tried your script on the latest version and it has no effect.
    Looking at the history, this feature was added in version 1.3 (16.12.2007).
    Quote Quote  
  25. Thanks. I thought I had downloaded the latest but somehow got version 1.0. Just updated to 1.3...
    Quote Quote  
  26. my version too did not have the endAngle Parameter,.. (but mine really was old)
    Quote Quote  
  27. Originally Posted by AlienWare View Post
    Thank you pandy for the help, but I want to do it with AviSynth and I think that I'm almost there Plus your way sounds more complicated to me

    My way use AviSynth also but instead rendering each frame with script You pre-rendering animated sequence then You overlay this sequence on video - this should be much faster than re-rendering each frame from scratch. - just split script on two independent - animate image with rotate, render to external images or avi, then use this as animation placed over video. that all - One big, complex script will be slow - i know this from my experience, especially if there is need to make high quality ie introducing to video some oversampling (pixel fractional scrolling or animation) - for decent quality you must work with videos at least 4 times oversampled thus you are able to represent very fine and smooth motion without stutter and jaggies

    but this is only advice based on some experience from past
    Quote Quote  
  28. Member
    Join Date
    Feb 2011
    Location
    Croatia
    Search Comp PM
    Originally Posted by Gavino View Post
    Try this:
    Code:
    ... # LoadPlugin etc
    a1=DGDecode_mpeg2source("E:\New folder\1.d2v").Yadif(order=1)
    a2=ImageReader("E:\New folder\watermark 1.png",end=a1.Framecount-1,pixel_type="RGB32")
    a2=a2.Rotate(endangle=360) # or some other angle, say 3600 for 10 rotations
    a3=a2.ShowAlpha()
    a4=Overlay(a1,a2,mask=a3, x=20, y=20)
    ReplaceFramesSimple(a1, a4, mappings="[26 345][1250 1920][2699 2999]")
    crop( 2, 2, -2, -2)
    Spline36Resize(704,400)
    This is what I have been looking for It works great
    Everybody, thank you very much for your help, I really appreciate it
    Quote Quote  
  29. Member
    Join Date
    Jul 2011
    Location
    Isfahan
    Search Comp PM
    very useful post
    what should i do to change the script for h264 video and *.mkv container.

    i'm newbie here.
    Quote Quote  
  30. Instead of DGDecode use FFMpegSource
    Quote Quote  



Similar Threads

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