简体   繁体   中英

ffmpeg scaling and padding error

I am trying to scale a video of any dimension to be 720x720, and then centered on a padded background of 1280x720.

ffmpeg -y -i test.mp4  -vf "scale=-1:720,pad=width=1280:height=720:x=280" -c:a copy processed/test.mp4

This command gives the error: "Warning: data is not aligned! This can lead to a speedloss", although the video does scale and center properly.

The same command without the x coordinate of 280px gets rid of the error, but then the video is not centered properly: ffmpeg -y -i test.mp4 -vf "scale=-1:720,pad=width=1280:height=720" -c:a copy processed/test.mp4

Is there another way I can center the video and get rid of the error?

Scale to size

Here's a method that will scale-to-fit into a 720x720 box then pad to 1280x720:

"scale=720:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2"

Depending on the aspect ratio of the input it will letterbox or pillarbox to fit into 720x720 unless the input is 1:1 aspect ratio.

See Resizing videos with ffmpeg to fit into static sized player for visuals and other examples.

Speed loss warning

It's a warning and not an error. Ignore it: I've never seen a significant enough loss to worry about it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM