Перейти к содержимому

FFmpeg - весы и накладка

2

У меня есть видео, которое я хочу улучшить, но я не хочу терять соотношение сторон исходного видео.

Разрешение моего исходного файла - 864 x 692и я хочу увеличить его до1280 x 720

Я нашел это на суперпользователя, но, честно говоря, я не мог понять, как это сделать.

Если вы можете помочь мне создать команду ffmpeg, которая подходит для моего случая, это действительно поможет мне.

Спасибо

Обновление Я использовал это руководство, и я приблизился ко всему, что я хотел сделать https://superuser.com/a/690211

8 721 просмотр
Levan спросил 10 лет назад
L 214

1 ответ

8
Принятый ответ

You have two main options to make it fit after using scale: pad or crop. Take a look at these examples and the documentation for each filter.

pad

This will pillarbox the image.

enter image description here

ffmpeg -i input -vf "scale=-1:720,pad=1280:ih:(ow-iw)/2" output 

A more generic command that will work for all input file aspect ratios will use force_original_aspect_ratio=1 as an option to scale:

ffmpeg -i input -vf "scale=w=1280:h=720:force_original_aspect_ratio=1,pad=1280:720:(ow-iw)/2:(oh-ih)/2" output 

crop

This will cut off the top and bottom.

enter image description here

ffmpeg -i input -vf "scale=1280:-1,crop=iw:720" output 

A more generic command that will work for all input file aspect ratios will use force_original_aspect_ratio=2 as an option to scale:

ffmpeg -i input -vf "scale=w=1280:h=720:force_original_aspect_ratio=2,crop=1280:720" output 

Use your player

If you don't want to bother with re-encoding, then any player worth using should allow you to do this upon playback. Example using ffplay:

ffplay -vf "scale=-1:720,pad=1280:ih:(ow-iw)/2" input 

Or see "Video Effects" in VLC.

LordNeckbeard ответил 10 лет назад
L 24 701