Thursday, January 2, 2025

Converting webm video to mp4 on Ubuntu

Ubuntu's built-in screen recorder saves videos in WebM format. Some social media platforms do not support it, so you might find yourself needing to convert them to MP4 format. Make sure you have FFmpeg installed first:

sudo apt install ffmpeg

After that, it's just a one-liner (command line parameters are explained below):

ffmpeg -i video_file.webm -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" -r 30 video_file.mp4

-vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" is a workaround for videos whose dimensions are not even numbers.

-r 30 sets the rate to 30 frames per second. You can set your own value here. FFmpeg actually keeps the frame rate of the original file, though it might get confused in case it is a variable rate.

No comments:

Post a Comment