[FFmpeg-user] ffmpeg keep aspect ratio when scaling, keep dimensions divisable by n
Peter van den Houten
petervdh at gmail.com
Thu Apr 9 18:44:07 EEST 2020
On 09/04/2020 16:58, atticus via ffmpeg-user wrote:
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Thursday, April 9, 2020 1:00 PM, Peter van den Houten <petervdh at gmail.com> wrote:
>>
>> Try:
>>
>> ffmpeg -i video.MTS -vf scale=720:-2 -c:v libx264 -crf 20 -c:a copy -y padded.MTS
>>
>> Change -crf 20 up or down to suit quality and/or file size.
>>
>> Regards
>> Peter
>
> Yes I noticed that, the problem with this is that I want my script to be as general as possible so I don't know in advance which dimension has to be scaled.
>
> Cheers
>
This will extract the dimension which you can then use in your script:
for f in *; do echo "$f" $(mediainfo --Output='Video;%Width%\n' "$f"); done
Change %Width% to %Height% as needed.
I used mediainfo for analysis of stream parameters because I use a hidden feature in a much larger script:
mediainfo --parsespeed=1 [filename]
This is the easiest (not quickest) way I have found to determine the bit rate of certain files which don't reveal their bit rates.
Regards
Peter
More information about the ffmpeg-user
mailing list