VideoHelp Forum

Our website is made possible by displaying online advertisements to our visitors. Consider supporting us by disable your adblocker or Try ConvertXtoDVD and convert all your movies to DVD. Free trial ! :)
+ Reply to Thread
Results 1 to 11 of 11
Thread
  1. Hello Everyone,

    I have a huge list of video files (mp4) to transcode to the same format but with an animated logo burned in.

    What's the best/fastest way to do it?

    I want to avoid having to open each individual video on an video editor software and paste the animated logo over and over and over again.

    Looking forward for your help.

    Best
    Quote Quote  
  2. You can use ffmpeg for this - source called in main script loop and animated logo invoked trough https://ffmpeg.org/ffmpeg-filters.html#movie-1 in filter section then overlay (if you are interested in some alpha channel transparency then things are slightly more complicated bout still doable).

    How to process many files in loop - example here: https://forum.videohelp.com/threads/392195-Extracting-FPS-from-multiple-files#post2542544 by principle is same.

    Bellow example if ffmpeg syntax (working so excuse parameters) how to use alpha embedded in file source:
    Code:
    @ffmpeg.exe -hide_banner -v 32 -stats -strict -1 -i %filename% -an  -filter_complex "[0:v]scale=773:439:sws_flags=spline+accurate_rnd+full_chroma_int+full_chroma_inp:interl=-1:out_range=full,pad=1920:1080:990:224[a0];movie=bg.png,premultiply=inplace=1[b0];[a0][b0]overlay=0:0:alpha=premultiplied,scale=960:-2,format=pix_fmts=yuv420p" -c:v ffv1 -vsync 0 -f NUT - | ffplay.exe -hide_banner -loglevel 32 -autoexit -i -
    Depends on your sources and target it may be probably just more complex.
    Quote Quote  
  3. Originally Posted by pandy View Post
    You can use ffmpeg for this - source called in main script loop and animated logo invoked trough https://ffmpeg.org/ffmpeg-filters.html#movie-1 in filter section then overlay (if you are interested in some alpha channel transparency then things are slightly more complicated bout still doable).

    How to process many files in loop - example here: https://forum.videohelp.com/threads/392195-Extracting-FPS-from-multiple-files#post2542544 by principle is same.

    Bellow example if ffmpeg syntax (working so excuse parameters) how to use alpha embedded in file source:
    Code:
    @ffmpeg.exe -hide_banner -v 32 -stats -strict -1 -i %filename% -an  -filter_complex "[0:v]scale=773:439:sws_flags=spline+accurate_rnd+full_chroma_int+full_chroma_inp:interl=-1:out_range=full,pad=1920:1080:990:224[a0];movie=bg.png,premultiply=inplace=1[b0];[a0][b0]overlay=0:0:alpha=premultiplied,scale=960:-2,format=pix_fmts=yuv420p" -c:v ffv1 -vsync 0 -f NUT - | ffplay.exe -hide_banner -loglevel 32 -autoexit -i -
    Depends on your sources and target it may be probably just more complex.
    Thank you for your help.

    Yes, I have the animated logo on alpha channel (full hd) with only the logo on the corner.
    If I use that code, what do I need to change?

    Thanks
    Quote Quote  
  4. Originally Posted by zkazzay View Post
    Yes, I have the animated logo on alpha channel (full hd) with only the logo on the corner.
    If I use that code, what do I need to change?
    You need to provide more details? for example source resolution, logo overlay position etc.
    My example can be divided on few main groups:

    - common part where filename is your source - should be modified accordingly to loop processing
    Code:
    @ffmpeg.exe -hide_banner -v 32 -stats -strict -1 -i %filename%
    - filter part beginning with '-filter_complex' where two video sources are processed (thus filter complex must be used - one of crappiest solution in ffmpeg as there is no separate filter complex for video and audio...)

    - first video (source video) is processed by:
    Code:
    [0:v]scale=773:439:sws_flags=spline+accurate_rnd+full_chroma_int+full_chroma_inp:interl=-1:out_range=full,pad=1920:1080:990:224[a0]
    scale resize video and pad video to static resolution then video signal is available on [a0] pin
    I assume you will not resize your source video and perhaps no need to pad thus this can be significantly modified (or even removed)

    - secondly alpha channel source (in this case it was image with embedded alpha) is invoked and made to be present on pin [b0]
    Code:
    movie=bg.png,premultiply=inplace=1[b0]
    For video you should don't forget to loop your logo (movie command provide such functionality or you can use additional command loop)

    - third in this particular case transparent (trough alpha) image is overlayed on top of video (your case is very similar only logo will be smaller than video)
    Code:
    [a0][b0]overlay=0:0:alpha=premultiplied,scale=960:-2,format=pix_fmts=yuv420p
    Please remove resize (scale=960:-2) - it was used to speedup overall processing.

    Additionally you need to configure video codec (and audio - didn't covered audio path at all).

    Not sure if this helpful... it is difficult to create script for unknown usage case.
    Quote Quote  
  5. Originally Posted by pandy View Post
    Originally Posted by zkazzay View Post
    Yes, I have the animated logo on alpha channel (full hd) with only the logo on the corner.
    If I use that code, what do I need to change?
    You need to provide more details? for example source resolution, logo overlay position etc.
    My example can be divided on few main groups:
    Thank you so much for such dedication trying to help me, really appreciated!

    Now, yesterday after digging, testing, reading documentation (and with your help), I was able to come up with this script:

    Code:
    for %%A in (*.mp4) do ffmpeg -i "%%A" -filter_complex "[0:v]scale=1920:1080:sws_flags=spline+accurate_rnd+full_chroma_int+full_chroma_inp:interl=-1:out_range=full,pad=1920:1080:990:224[a0];movie=filename=FTV_BUG_GENERIC.mov:loop=0, setpts=N/(25*TB),premultiply=inplace=1[b0];[a0][b0]overlay=0:0:alpha=premultiplied,scale=1920:-2,format=pix_fmts=yuv420p" -an "exported\%%A"
    But I have 2 questions:
    what is this? pad=1920:1080:990:224
    what encoding options is it doing?
    (frame rate, Bit rate, etc..) The same as source?

    Thanks again for your effort.

    Best Regards
    Quote Quote  
  6. what is this? pad=1920:1080:990:224
    Add paddings to the input image, and place the original input at the provided x, y coordinates.
    For more details read: https://www.ffmpeg.org/ffmpeg-all.html#pad-1
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  7. Originally Posted by zkazzay View Post
    But I have 2 questions:
    what is this? pad=1920:1080:990:224
    what encoding options is it doing?
    (frame rate, Bit rate, etc..) The same as source?
    padding already answered by Selur (sorry Selur, my apologies) (i think you can safely remove it from command line, not sure if your intention is resize all source files to 1920x1080)

    encoding options are "setup parameters" for selected video and audio codecs, so video/audio codec, bitrates, encoding option encoding options

    Bellow removed from your cmdline pad and last scale (it had functionality accordingly to my needs but not necessary for you).

    I've highlighted '-an' command - this disabling audio - not sure if this is your goal - to disable (remove) audio and process all source files only video

    Code:
    for %%A in (*.mp4) do ffmpeg -i "%%A" -filter_complex "[0:v]scale=1920:1080:sws_flags=spline+accurate_rnd+full_chroma_int+full_chroma_inp:interl=-1:out_range=full[a0];movie=filename=FTV_BUG_GENERIC.mov:loop=0, setpts=N/(25*TB),premultiply=inplace=1[b0];[a0][b0]overlay=0:0:alpha=premultiplied,format=pix_fmts=yuv420p" -an "exported\%%A"
    To select video and audio codec (and setup both ) i can recommend this:
    https://trac.ffmpeg.org/
    https://trac.ffmpeg.org/wiki/EncodingForStreamingSites
    Quote Quote  
  8. Originally Posted by pandy View Post
    Originally Posted by zkazzay View Post
    But I have 2 questions:
    what is this? pad=1920:1080:990:224
    what encoding options is it doing?
    (frame rate, Bit rate, etc..) The same as source?
    padding already answered by jagabo (i think you can safely remove it from command line, not sure if your intention is resize all source files to 1920x1080)

    encoding options are "setup parameters" for selected video and audio codecs, so video/audio codec, bitrates, encoding option encoding options

    Bellow removed from your cmdline pad and last scale (it had functionality accordingly to my needs but not necessary for you).

    I've highlighted '-an' command - this disabling audio - not sure if this is your goal - to disable (remove) audio and process all source files only video

    Code:
    for %%A in (*.mp4) do ffmpeg -i "%%A" -filter_complex "[0:v]scale=1920:1080:sws_flags=spline+accurate_rnd+full_chroma_int+full_chroma_inp:interl=-1:out_range=full[a0];movie=filename=FTV_BUG_GENERIC.mov:loop=0, setpts=N/(25*TB),premultiply=inplace=1[b0];[a0][b0]overlay=0:0:alpha=premultiplied,format=pix_fmts=yuv420p" -an "exported\%%A"
    To select video and audio codec (and setup both ) i can recommend this:
    https://trac.ffmpeg.org/
    https://trac.ffmpeg.org/wiki/EncodingForStreamingSites
    Thank you once again.

    Just one more question, whats the best loop option so that the overlay loops for the total length of the main video?

    thanks
    Quote Quote  
  9. Originally Posted by zkazzay View Post
    Thank you once again.

    Just one more question, whats the best loop option so that the overlay loops for the total length of the main video?

    thanks
    NP, IMHO best loop for animated logo is endless (infinite) loop (remove uncertainty related to unknown duration of the source).
    For https://ffmpeg.org/ffmpeg-filters.html#movie-1 ':loop=0' means infinite loop
    Quote Quote  
  10. Originally Posted by pandy View Post
    Originally Posted by zkazzay View Post
    Thank you once again.

    Just one more question, whats the best loop option so that the overlay loops for the total length of the main video?

    thanks
    NP, IMHO best loop for animated logo is endless (infinite) loop (remove uncertainty related to unknown duration of the source).
    For https://ffmpeg.org/ffmpeg-filters.html#movie-1 ':loop=0' means infinite loop
    I made a conversion using loop=0 but a 7min video turned into 35min (i manually stopped the conversion).
    Quote Quote  
  11. Originally Posted by zkazzay View Post
    I made a conversion using loop=0 but a 7min video turned into 35min (i manually stopped the conversion).
    add to main command line (not filter) '-shortest' - should fix problem.

    https://ffmpeg.org/ffmpeg-all.html
    -shortest (output)

    Finish encoding when the shortest input stream ends.
    Quote Quote  



Similar Threads