ffmpeg - scale not working on all my cases - ffmpeg

I'm using ffmpeg to scale and change speed of my videos.
And below script was not worked:
ffmpeg -i input.mp4 -filter_complex "[0:v]setpts=0.666*PTS[i]; [i]scale=640:640[j]; [0:a]atempo=1.5[p]" -map "[j]" -map "[p]" output.mp4 2>&1
More simple script I testes also not working
ffmpeg -i input.mp4 -filter_complex "scale=640:640" output.mp4 2>&1
Original video have resolution 1280x720, and I want to resize to 640x640, with padding 320 left and right.
What are my wrongs in script?
Sorry for my bad English!

I suspect you have problem with the scaling part, so try this:
ffmpeg -i input.mp4 -filter_complex "setpts=0.666,scale=w=min(iw*640/ih\,640):h=min(640\,ih*640/iw),pad=w=640:h=640:x=(640-iw)/2:y=(640-ih)/2; atempo=1.5" output.mp4
Here's the scaling filter:
scale=w=min(iw*HEIGHT/ih\,WIDTH):h=min(HEIGHT\,ih*WIDTH/iw),pad=w=WIDTH:h=HEIGHT:x=(WIDTH-iw)/2:y=(HEIGHT-ih)/2
Source:
ffmpeg resize down larger video to fit desired size and add padding

Related

FFMPEG watermark text / photo transparent opacity problem

I've came across two problems.
I'm trying to resize and set the opacity/transparency of a watermark, and I can't seem to do it in one command line.
command to rescale but not set transparency:
ffmpeg -i video.mp4 -i watermark.png -filter_complex "[1]scale=iw*0.1:-1[wm];[0][wm]overlay=x=15:y=10" output.mp4
Trying to set transparency of text but leave the border of the text greyish.
command to resize text and set border, but could not set transparency:
ffmpeg -i video.mp4 -filter_complex "drawtext=fontfile=wryh.ttf:text='sample':x=20:y=15:fontcolor=white#1:fontsize=15:fontcolor=white:bordercolor=black:borderw=0.51" output.mp4
Combined command:
ffmpeg -i video.mp4 -i watermark.png -filter_complex "[1]format=rgba,colorchannelmixer=aa=0.7,scale=iw*0.1:-1[logo];[0][logo]overlay=15:10:format=auto,drawtext=fontfile=wryh.ttf:text='sample':x=20:y=15:fontcolor=white#1:fontsize=15:fontcolor=white:bordercolor=black:borderw=0.51,format=yuv420p" -c:a copy video.mp4

Resize overlay video

I am overlaying a video on top of an image.
Using this command:
ffmpeg -i image.png -i input.mp4 -filter_complex "[0:v][1:v] overlay=10:10:enable='between(t,0,38)'" -pix_fmt yuv420p -c:a copy output.mp4
I understand the overlay=10:10 is the positioning but I can't seem to work out how to resize the overlay video (input.mp4).
I think I need to use scale but not sure how to.
Any help on scaling the overlay video would be appreciated!
With filter_complex you can combine commands and make named outputs
Try something like this:
ffmpeg -i image.png -i input.mp4 -filter_complex "[1:v]scale=320x240[scaled_v];[0:v][scaled_v] overlay=10:10:enable='between(t,0,38)'" -pix_fmt yuv420p -c:a copy output.mp4
Just change resolution to what you need instead of 320x240.
If you need image overlay on top of video, swap [1:v] and [0:v]

ffmpeg: sliding overlay for filter comparison

I am trying to get the effect demonstrated in this video: https://www.youtube.com/watch?v=xrMZSLb_gPs
Most of the sliding overlay solutions I've seen are for a sliding fixed image, but not for a progressive crop of each part of the video.
I've tried doing:
ffmpeg -i video1.mp4 -i video2.mp4 \
-filter_complex "[0]crop='min(iw*(1+n)/100,iw)':ih:0:0[left];[1]crop='max((1-n/100)*iw,1)':ih:1-'max((1-n/100)*iw,1)':0[right];[left][right]hstack[out]" -map '[out]' -y out.mp4
But it still does not work. Is there a way?
Thank you!
Use the xfade filter:
ffmpeg -i video1.mp4 -i video2.mp4 -filter_complex "xfade=transition=wiperight:duration=5:offset=1" output.mp4
transition chooses the style/effect.
duration is how long the transition lasts.
offset is number of seconds before transition begins.

FFmpeg how to add drawtext on filter complex along with watermark and palettegen

thanks to many posts on stack overflow I could come till here: How to add watermark in a gif with ffmpeg? which i can convert mp4 into animated gif with moderate quality and watermark on. But I'd like to add the drawtext too in these lines.
ffmpeg -i in.mp4 -i watermark.png -filter_complex "[0]fps=10,scale=320:-1:flags=lanczos[bg];[bg][1]overlay=W-w-5:H-h-5,palettegen" palette.png
ffmpeg -i in.mp4 -i watermark.png -i palette.png -filter_complex "[0]fps=10,scale=320:-1:flags=lanczos[bg];[bg][1]overlay=W-w-5:H-h-5[x];[x][2]paletteuse=dither=bayer:bayer_scale=3" output.gif
Would it be possible through filter_complex by adding another [ ]? Thanks a lot to everyone
You can add drawtext after overlay.
ffmpeg -i input.mp4 -i watermark.png -filter_complex "[0]fps=10,scale=320:-1[bg];[bg][1]overlay=main_w-overlay_w-10:main_h-overlay_h-10:format=auto,drawtext=text='your text here':fontsize=24:fontcolor=white:x=(w-text_w)/2:y=(h-text_h)/2,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" output.gif
This will add text centered in video and overlay will be placed in the lower right.

Ffmpeg video overlay

I am trying to create a video output from multiple video cameras.
Following the example given here Presenting more than 2 videos using FFmpeg
and other similar examples.
but Im getting the error
Output pad "default" for the filter "src" of type "buffer" not connected to any destination
when i run
ffmpeg -i /dev/video1 -i /dev/video0 -filter_complex "[0:0]pad=iw*2:ih[a];[a][1:0]overlay=w[b];[b][2:0]overlay=w:h" -shortest output.mp4
Im not really sure what this means or how to fix it.
Any help would be greatly appreciated!
Thanks.
When using the "padding" option, you have to specify which is the size of the output image and where you want to put the input image
[0:0]pad=iw*2:ih:0:0
tested under windows 7 with file of same size
ffmpeg -i out.avi -i out.avi -filter_complex "[0:0]pad=iw*2:ih:0:0[a];[a][1:0]overlay=w" -shortest output.mp4
and with WebCam Cap (vfwcap) and a still picture (as i have only o=1 WebCam). BTW you can see how to scale one the source to fit in the target (just in case your source have different resolution)
ffmpeg -y -f vfwcap -r 10 -i 0 -loop 1 -i photo.jpg -filter_complex "[0:0]pad=iw*2:ih:0:0[a];[1:0]scale=640:480[b];[a][b]overlay=w" -shortest output.mp4
under Linux:
ffmpeg -i /dev/video1 -i /dev/video0 -filter_complex "[0:0]pad=iw*2:ih:0:0[[a];a][1:0]overlay=w" -shortest output.mp4
if it doesn't work test a simple record of video 1 and after of video 0 and check their properties (type, resolution, fps).
ffmpeg -i /dev/video1 -shortest output1.mp4
ffmpeg -I output1.mp4
If you still have issue, update your question with ffmpeg console output (as text) for video and video 0 capture and also of the call with the overlay

Resources