FFMPEG change videos size - ffmpeg

How do i change a video that is 1920x1080 to 1080x1920, and then "shrink" it so that it fills only half of the 1080x1920 screen size?
here is what i mean:
1920x1080 original
needs to be changed to
1080x1920 that covers 50% of screen space only

Use the scale filter, then the pad filter. The following command first scales the video from width x height to height x (width/2), then adds padding at the bottom, preserving the width and duplicating the height. The setsar filter changes the aspect ration for the output video. iw and ih stand for input width and height.
ffmpeg -i input.mp4 -vf "scale=ih:iw/2,setsar=1,pad=0:ih*2" output.mp4

Related

ffmpeg upscale 4/3 video to fullhd by crop vertically

I have some video 4:3 generally are 1280x960 and other resolutions.
I like to upscale it to 1920x1080 and crop vertically to avod horizontal black borders.
I have found this commmand:
ffmpeg -i intro_NR_Upscale_4x.mp4 -filter:v "pad=ih*16/9:ih:(ow-iw)/2:(oh-ih)/2" -c:a copy intro_NR_Upscale_4x_ouput.mp4
but not work and continue to show horizontal black borders.
There is a command line that upscale low resolution 4:3 video to 16:9 and crop it ?
Thanks !

Align text in top middle of any photo/video frame in ffmpeg

I would like to know how to align the text in any sized photo/video frame in the top middle. I understand how to center the text on the x axis in any frame, so how do I make it always be at the top as well?
Heres what I've been doing so far:
ffmpeg -i input.jpg -vf "drawtext=font='Impact': text='Test Text': fontcolor=white: borderw=3: fontsize-75: x=(w-tw)/2:y=((h-text_h)/2)" output.jpg
By top-middle, I assume you mean horizontally centered and vertically centered within the top-third of the frame. That means the text has to be vertically centered around 1/6th the height. So, x=(w-tw)/2:y=h/6-th/2

Continuously rotate image centered on background

Is it possible to continuously rotate an image or series of images and output as a video with ffmpeg? Rotating image should be centered over a background.
See example video.
Use the rotate filter to rotate the image, the color filter as a background, the overlay filter to place image over background, and the format filter to ensure widely compatible chroma subsampling for H.264 video.
ffmpeg -f lavfi -i color=c=00ff00:s=1280x720:d=10 -loop 1 -i image.png -filter_complex "[1]rotate=angle=PI*t:fillcolor=none:ow='hypot(iw,ih)':oh=ow[fg];[0][fg]overlay=x=(W-w)/2:y=(H-h)/2:shortest=1:format=auto,format=yuv420p" -movflags +faststart output.mp4
The speed is controlled by the rotate filter: specifically the angle parameter. Examples:
90 degrees clockwise per second: angle=90*PI/180*t
1 degree clockwise per frame: angle=PI/180*n
1 complete rotation (2 radians) per second counter-clockwise: angle=-2*PI*t
See the rotate filter documentation for more examples.
If you want GIF instead of MP4 see How do I output GIF using ffmpeg?

Add image with scale + rotation to video overlay with FFMPEG?

I want to add overlay images to videos with params
1: w:h --> is width and height of image on the video
2: r --> Radian is rotation of images
3: center (x,y) --> is center point of image in the video
This is my FFMPEG command :
-i video.mp4 -i image.png filter_complex [1:v]scale=w:h[scale];[scale]rotate=r:ow=iw:oh=ih[rotate];[0:v][rotate]overlay=x-(w/2):y-(h/2)
But the result not correct. It's Only work with scale=1 and rotate=0 radian
How can i do this ?
Ffmpeg command to rotate, scale, overlay and set image duration on a video
ffmpeg -i input.mp4 -i inputImg.png -filter_complex \"[1:v] rotate=90:c=none:ow=rotw(iw):oh=roth(ih) [rotate];[rotate]scale=100:-1[scale];[0:v][scale] overlay=0:0:enable='between(t,0,2)'[out]\" -map [out] -pix_fmt yuv420p -c:a copy output.mp4
Use
[1:v]scale=w:h,pad=iw+4:ih+4:black#0[scale];[scale]rotate=r:ow='rotw(r)':oh='roth(r)'[rotate]
A bit of transparent padding is added to the image before rotation. This is because the rotate filter will fill the gaps in the canvas with the input's border pixel color. Also, the output size has to be adjusted to accommodate the whole image after rotation. See the docs for the rotate filter.

Extend + scale a portrait video so the aspect ratio stays and the black borders become a blurry version of the video

I have a 720 x 1280 pixels video. How do I extend and scale it to 1920 x 1080 such that the aspect ratio is being kept and the black borders are a blurry version of the video, so you don't really notice that it's just a small vertical stripe.
Example
I started with
ffmpeg -i video720x1280.mp4 -vf "scale=608:1080,pad=width=1920:height=1080:x=656:y=0:color=black" video1920x1080.mp4
Use
ffmpeg -i video720x1280.mp4
-filter_complex
"[0]scale=hd1080,setsar=1,boxblur=20:20[b];
[0]scale=-1:1080[v];[b][v]overlay=(W-w)/2" video1920x1080.mp4
Adjust the two values in the boxblur filter for blur strength. Higher = more blurring.

Resources