Scale and overlay in single command - ffmpeg

I want to convert and resize a video and put a logo on it. I am doing this with 2 different command line like this.
Command 1:
D:\Logo\ffmpeg -i "D:\Logo\video.mxf" -vf scale=1280:720 "D:\Logo\video.mxf_fullHDtoHD.mp4"
Command 2:
D:\Logo\ffmpeg -i "D:\Logo\video.mxf_fullHDtoHD.mp4" -i D:\Logo\logo_720p.png -filter_complex "[0:v][1:v] overlay=60:50" "D:\Logo\output_720p_with_logo.mp4"
Can I do this in just one command?

Combined command:
ffmpeg -i "D:\Logo\video.mxf" -i D:\Logo\logo_720p.png -filter_complex "[0:v]scale=1280:720[bg];[bg][1:v]overlay=60:50" "D:\Logo\output_720p_with_logo.mp4"

Related

Is it possible to reduce ffmpeg commands in a single file pass?

I need to add the logo and telephone number on video, therefore I run the following command twice with different parameters:
ffmpeg -i input.mp4 -i ./assets/logo.png -filter_complex "[1][0]scale2ref=w='iw*1/5':h='ow/mdar'[wm][vid];[vid][wm]overlay=main_w-overlay_w-5:5" 'uploads/output.mp4' 2>&1
ffmpeg -i ./uploads/output.mp4 -i ./assets/telephone.png -filter_complex "[1][0]scale2ref=w='iw*9/10':h='ow/mdar'[wm][vid];[vid][wm]overlay=10:main_h-overlay_h-10" './uploads/output2.mp4'
I'm looking to optimize speed, maybe is possible to have a single file pass instead of 2?
Thank you very much!
I tried
ffmpeg -i input.mp4 -i ./assets/logo.png -filter_complex "[1][0]scale2ref=w='iw*1/5':h='ow/mdar'[wm][vid];[vid][wm]overlay=main_w-overlay_w-5:5" -i ./assets/telephone.png -filter_complex "[1][0]scale2ref=w='iw*9/10':h='ow/mdar'[wm][vid];[vid][wm]overlay=10:main_h-overlay_h-10" './uploads/output2.mp4'
but does not add the telephone number.
I found a way:
ffmpeg -i uploads/input.mp4 -i ./assets/logo.png -i ./assets/telefon.png -filter_complex "[1][0]scale2ref=w='iw*1/5':h='ow/mdar'[v1];[2][0]scale2ref=w='iw*9/10':h='ow/mdar'[v2];[0][v1]overlay=main_w-overlay_w-5:5[vid];[vid][v2]overlay=10:main_h-overlay_h-10" uploads/output.mp4
BUT
if input file type is an image
ffmpeg -i uploads/input.png -i ./assets/logo.png -i ./assets/telefon.png -filter_complex "[1][0]scale2ref=w='iw*1/5':h='ow/mdar'[v1];[2][0]scale2ref=w='iw*9/10':h='ow/mdar'[v2];[0][v1]overlay=main_w-overlay_w-5:5[vid];[vid][v2]overlay=10:main_h-overlay_h-10" uploads/output%d.png
without %d in the output file name I get this error:
[image2 # 0x55fff1a6af80] Could not get frame filename number 2 from pattern 'uploads/output.png'. Use '-frames:v 1' for a single image, or '-update' option, or use a pattern such as %03d within the filename.
Error writing trailer of uploads/output.png: Invalid argument
Now I have 3 output files but a single file pass, could you please give me an ideea to have only one output image file?

How to apply any mask.png on a video with ffmpeg

I am adding a 1.mp4 on a video 2.mp4, and i want to add a mask on overlay video(1.mp4)
I want to apply this mask on 1.mp4
I'm using chrome key right now
ffmpeg -t 5 -r 30 -f lavfi -i color=c=black:s=640x360
-i 1.mp4
-i mask2.png
-i 2.mp4
-filter_complex "
[1:v]scale=500x281[v1];
[2]scale=500x281[mask];
[v1][mask]overlay, chromakey=0x00FF00:0.25:0.08 [v2];
[3:v]scale=640x360[v3];
[0][v3]overlay [out1];
[out1][v2]overlay=0:0"
-y output.mp4
But it also removes color from videos.
I'm not sure but i think it can be done by negate
also i don't need audio command, i already done that part
Thanks

How do we redirect the output of 1 ffmpeg processing as input in the same command?

I want to attach 2 videos using hstack filter and this is what I am doing, resizing 1 of the video files (to match same height) and then proceeding to merge. This is happening as 2 different steps,
ffmpeg -y -i inputVideo1 -vf scale=-2:900 outputVideo1
ffmpeg -y -i outputVideo1 -i inputVideo2 -c:v libx264 -filter_complex hstack outputVideo2.mp4
This is taking longer time. How do I make this happen in a single step? Something like,
ffmpeg -i inputVideo1 (something here) outputVideo1 (take this as input) -i inputVideo2 (hstack and stuff) outputVideo2.mp4```
Combined command:
ffmpeg -i inputVideo1 -i inputVideo2 -c:v libx264 -filter_complex "[0:v]scale=-2:900[left];[left][1:v]hstack" outputVideo.mp4

FFMPEG Add 2 watermarks to an Image using single command

How to add 2 watermarks to one image using ffmpeg. This is the command I am using for adding single watermark
ffmpeg -i actual-image.jpg -i watermark.png -filter_complex "overlay=5:5" output.jpg
But i am not able to add 2 arguments for this. Thanks for help in advance
Apply 2 overlays. The 2nd overlay will use the result of the first overlay as its base input.
ffmpeg -i actual-image.jpg -i watermark1.png -i watermark2.png -filter_complex "[0][1]overlay=5:5[vid1];[vid1][2]overlay=300:300" output.jpg

Combining two ffmpeg commands into single command

I want to combine two ffmpeg commands to single ffmpeg command.
exec("ffmpeg -i mimic/api/video/1560754087943.mp4 -i logo.png -filter_complex"." overlay=20:20"." topleft.mp4");
exec('ffmpeg -i topleft.mp4 -vf drawtext="fontfile=ARIBLK.ttf: text=sonukh3921: fontcolor=white: fontsize=20: x=20: y=65" output_video.mp4');
Is this possible to use the output from the first command for the second line, without using two separate commands?
The below single command is just for you:
ffmpeg \
-i mimic/api/video/1560754087943.mp4 \
-i logo.png \
-filter_complex "overlay=20:20[video];[video]drawtext=fontfile=ARIBLK.ttf:text=sonukh3921:fontcolor=white:fontsize=20:x=20:y=65" \
output_video.mp4

Resources