Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ffmpeg scaling not working for video

Tags:

video

ffmpeg

I am trying to change the dimensions of the video file through FFMPEG. I want to convert any video file to 480*360 .

This is the command that I am using...

ffmpeg -i oldVideo.mp4 -vf scale=480:360 newVideo.mp4

After this command 1280*720 dimensions are converted to 640*360.

I have also attached video. it will take less than minute for any experts out there. Is there anything wrong ?

You can see here. (in Video, after 20 seconds, direclty jump to 1:35 , rest is just processing time).

UPDATE :

I found the command from this tutorial

like image 600
Neer Patel Avatar asked May 15 '18 09:05

Neer Patel


People also ask

How do I resize a video while keeping the quality high with FFmpeg?

In FFmpeg, if you want to scale a video while retaining its aspect ratio, you need to set either one of the height or width parameter and set the other parameter to -1 . That is if you set the height , then set the width to -1 and vice-versa.

How do I resize an image using FFmpeg?

FFMpeg is using the libswscale library to resize the input. The libswscale library contains video image scaling and colorspace/pixelformat conversion routines. When we scale an image without specifying the size, the input dimension is used as the default value. We set the width of the output image to 250 pixels.


1 Answers

Every video has a Sample Aspect Ratio associated with it. A video player will multiply the video width with this SAR to produce the display width. The height remains the same. So, a 640x720 video with a SAR of 2 will be displayed as 1280x720. The ratio of 1280 to 720 i.e. 16:9 is labelled the Display Aspect Ratio.

The scale filter preserves the input's DAR in the output, so that the output does not look distorted. It does this by adjusting the SAR of the output. The remedy is to reset the SAR after scaling.

ffmpeg -i oldVideo.mp4 -vf scale=480:360,setsar=1 newVideo.mp4

Since the DAR may no longer be the same, the output can look distorted. One way to avoid this is by scaling proportionally and then padding with black to achieve target resolution.

ffmpeg -i oldVideo.mp4 -vf scale=480:360:force_original_aspect_ratio=decrease,pad=480:360:(ow-iw)/2:(oh-ih)/2,setsar=1 newVideo.mp4
like image 146
Gyan Avatar answered Oct 03 '22 12:10

Gyan