I am trying to convert a large number of files from many sources into a standard format of 426x240 using ffmpeg with the following arguments:
-y -i input.mov -ac 2 -ab 96k -ar 44100 -vcodec libx264 -pix_fmt yuv420p -preset medium -threads 0 -level 1.3 -max_muxing_queue_size 1024 -b:v 438k -r 30000/1001 -s 426x240 output.mp4
Even though this command worked in the previous version of ffmpeg I was using (from many years ago) in the new version I am using (4.2.3), video is stretched to 16:9. While attempting to fix it, I found this answer with the arguments:
-vf "scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:-1:-1:color=black". This appears to work, though I am concerned that I am scaling the result twice, once to 1280:720, then down to 426:240. To prevent this, I found the aspect argument for pad in the documentation, but when I try to use it I get the following error:
[Parsed_pad_0 @ 00000130808eec80] Negative values are not acceptable.
[Parsed_pad_0 @ 00000130808eec80] Failed to configure input pad on Parsed_pad_0
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #0:0
The arguments used to get this error (though I have tried numerous versions):
-y -i input.mov -ac 2 -ab 96k -ar 44100 -filter:v "pad=x=-1:y=-1:color=black:aspect=16\:9" -vcodec libx264 -pix_fmt yuv420p -preset medium -threads 0 -level 1.3 -max_muxing_queue_size 1024 -b:v 438k -r 30000/1001 -s 426x240 output.mp4
Can some please provide a working example of how to use the aspect parameter of the pad filter?
- The video is from an iPhone X. The video was taken with the phone in portrait orientation. The video, when analyzed with ffprobe indicates that the rotation is 90.
I cannot update to the latest version due to the later versions having a dependency on MFPlat.DLL which is not available in my working environment.The new versions from gyan.dev do not have this issue.