Sometimes, I inspire from some online videos that their logo continiously animated throughtout their length. Hence tried this work and FFmpeg command essentially takes two files as input - mp4 video file and an animated gif, apply various filters and then overlays the gif on the mp4, loops the gif infinitely and saves the final output as mp4 file (without audio).
ffmpeg -i input.mp4 -stream_loop -1 -i animals.gif -filter_complex "[1]colorchannelmixer=aa=1,scale=iw*1:-1[a];[0][a]overlay=x='35':y='35':shortest=1" -c:v libx264 -an output2.mp4
Breaking it down
-stream_loop -1 - This option tells ffmpeg to loop the gif file indefinitely.
-filter_complex - this option is used to specify a complex filtergraph, a chain of filter in a single instance. This complex filtergraph is composed of two filters:
a. [1]colorchannelmixer=aa=1 - This filter changes the color channel of the gif file.
b. scale=iw*1:-1[a] - this filter changes the scale of the gif.
[0][a]overlay=x='35':y='35':shortest=1 - this filter overlays the gif on the mp4 file. Here x and y specifies the position of the gif on the mp4 file. shortest=1 option tells the filter to end the output when the shortest input terminates.
-c:v libx264 - this option tells FFmpeg to encode the output file using the libx264 codec. The codec is responsible for compressing and decompressing the video data. This option is specific for the video codec.
-an - this option tells FFmpeg to drop the audio stream from the input file. This option is specific for the audio codec.
mp4 source: https://file-examples.com/storage/fea8fc38fd63bc5c39cf20b/2017/04/file_example_MP4_1920_18MG.mp4
Comments
Post a Comment