Combining two ffmpeg commands into single command - ffmpeg

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

Related

Scale and overlay in single command

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"

ffmpeg multiple text/logo elements

I am trying to add multiple items to an ffmpeg command and am getting stuck.
So far in the command I am automatically updating one image, which I'm using as a video, I also want to add a logo and two lines of text.
I have been successful until the last item, which is the logo overlay.
This is the relevant part of code:
ffmpeg \
-f image2 -loop 1 \
-y \
-i "/var/www/html/image_rotate.png" \
-re \
-i audio.mp3 \
-vf "movie=/var/www/html/overlay_logo.png [watermark]; [in][watermark] overlay=0:0 [out], drawtext=fontsize=10:fontfile=/var/www/html/OpenSans-Regular.ttf:textfile=/var/www/html/text1.txt:box=1:boxcolor=#000000:fontcolor=#FFFFFF:x=0:y=(h-text_h-20):reload=1, drawtext=fontsize=10:fontfile=/var/www/html/OpenSans-Regular.ttf:textfile=/var/www/htmltext2.txt:box=1:boxcolor=#000000:fontcolor=#FFFFFF:x=0:y=(h-text_h-30)" \
This gives me the following error:
Simple filtergraph ... was expected to have exactly 1 input and 1 output. However, it had >1 input(s) and >1 output(s). Please adjust, or use a complex filtergraph (-filter_complex) instead.
If I remove the last part I added (the overlay logo) I do not get the error.
If I add multiple -vf it only processes one (the text OR the logo).
I'm not sure how to achieve this.
When you need to work with multiple streams while filtering, the recommended method is to use a filter_complex.
ffmpeg \
-loop 1 \
-i "/var/www/html/image_rotate.png" \
-i "/var/www/html/overlay_logo.png" \
-i audio.mp3 \
-filter_complex "[0][1]overlay=0:0,drawtext=fontsize=10:fontfile=/var/www/html/OpenSans-Regular.ttf:textfile=/var/www/html/text1.txt:box=1:boxcolor=#000000:fontcolor=#FFFFFF:x=0:y=(h-text_h-20):reload=1, drawtext=fontsize=10:fontfile=/var/www/html/OpenSans-Regular.ttf:textfile=/var/www/htmltext2.txt:box=1:boxcolor=#000000:fontcolor=#FFFFFF:x=0:y=(h-text_h-30)" \
-y \
-shortest \
The logo is now fed as a regular input.

How to join multiple ffmpeg command

I am merging two .webm files using ffmpeg application(3.3.3) as follows,
ffmpeg -i input1.webm -c copy temp1.webm
ffmpeg -i input2.webm -c copy temp2.webm
ffmpeg -i temp1.webm -i temp2.webm -filter_complex [0:v]scale=640:360,setsar=1[l];[1:v]scale=640:360,setsar=1[r];[l][r]hstack;[0][1]amix" -vsync 0 -ac 2 -deadline realtime -cpu-used 8 output.webm
Above works fine for me but I want to do this in one step/ command. I am launching the ffmpeg.exe from my C++ application on windows so I have to do it for three times. I see that using | or && doesn't work for me. If I try from command prompt then it works using &&.
Please suggest.

How to cut video and add overlay at the same time?

I am currently cutting a video and after it is cut I am adding an layer of text like this:
$cut_video_cmd = 'ffmpeg -i "'.$video_path.'" -vf scale=640:-1 -ss 30 -t 10 "'.$video_path.'"';
$add_text_to_video_cmd = 'ffmpeg -i "'.$video_path.'" -vf drawtext="fontfile='.public_path('assets/fonts/Roboto-Regular.ttf').': \
text=\'Stack Overflow\': fontcolor=white: fontsize=24: box=1: boxcolor=black#0.5: \
boxborderw=5: x=(w-text_w)/2: y=(h-text_h)/2" -codec:a copy "'.$video_path.'.overlay.mp4"';
It works great, but I am wondering if there is a way to combine these two commands? Or any way to simplify this process? I am failing to figure this out.
Thanks a lot for any help!
Chain linear filters with a comma. Simplified example of your command:
ffmpeg -i input -ss 30 -t 10 -vf scale=640:-2,drawtext -codec:a copy output

ffmpeg - extract subtitles from piped input?

I have found two separate commands that I want to combine. One for taking piped input:
ffmpeg -i pipe:0
And another for extracting subtitles from a .ts file:
ffmpeg -i "movie=file.ts[out0+subcc]" -map s output.srt
But I can't work out how to combine them.
ffmpeg -i "movie=pipe:0[out0+subcc]" -map s output.srt
doesn't work. I'm kind of an ffmpeg newbie, so any ideas?
The solution requires escaping the colon after the "pipe".
Depending on your shell, and quoting rules, you'll need from 2 backslashes to... well, who knows :-)
Here's what has worked for me:
cat input.ts | ffmpeg -f lavfi -i 'movie=pipe\\:0[out+subcc]' -map s output.srt
If you use double quotes you'll need at least another backslash:
cat input.ts | ffmpeg -f lavfi -i "movie=pipe\\\:0[out+subcc]" -map s output.srt
Source: https://trac.ffmpeg.org/ticket/5229

Resources