Thursday, January 2, 2025

Converting webm video to mp4 and mp4 to mp3 on Ubuntu

Converting webm to mp4

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.

Converting mp4 to mp3

ffmpeg -i input.mp4 -map a output.mp3


No comments:

Post a Comment