After finding the resolution was the source of all my webm to MP4 codec conversion errors on my Android. I came across another problem. To break down my question:
Wh
The standard ratio for widescreens is 16:9 and the typical list of resolutions used is
256x144, 426x240, 640x360, 854x480, 960x540, 1024x576, 1280x720, 1920x1080, 2560x1440, 3840x2160
If you directly use the scale filter, you can tell ffmpeg to maintain the aspect ratio:
ffmpeg -i old.webm -t 00:00:03 -vf scale=-2:240 new.mp4
In the command above, scale=-2:240
tells ffmpeg to scale to height 240, select a width so that aspect ratio is maintained, and then adjust that value so that the width & height is a multiple of 2 (required for H.264/MP4). If you did not care whether the value was even, you could just use -1
.