Updated: Sep 18, 2020
If you have a large video or audio file, you can reduce the size of it using FFMPEG on Linux. FFMPEG is a nice little command line tool that, I know, works in Ubuntu and Debian based distros. The great thing about FFMPEG is that although it is a command line tool, you can easily use it without any programming knowledge whatsoever.
Resizing Videos On Linux Using FFMPEG
So here’s how you can resize videos on Linux. As an example I will use a video of Linus Torvalds to show you how to resize videos. The video is of 45.9 MB. Let’s go ahead and resize this video of the God of Linux. I know that it works in Ubuntu and Debian based distros. I can't vouch for other distros.
Pro Tip - If the name of the video has more than one word, rename it and use just one word. That way you can avoid some complexity.
I renamed the video as - Linux.webm
Download FFMPEG using Terminal -
sudo apt install ffmpeg
See, where exactly the video is located on your computer. Suppose you have kept the video on the desktop folder - basically on the desktop right in front of you.
Open the terminal of your Linux based OS by pressing ctrl+alt+T.
Your terminal must point to the directory ( in layman’s term - the folder) where that video is located. In my case, the video is located in the desktop folder. So you must change the directory that your terminal is pointing at. By default, the terminal points at - home/USERNAME.
In order to point it to the desktop folder type on your terminal -
( the username is the name that you selected while setting up the OS. In my case, my username is rahaman.) You can see your username in the terminal at the left hand side of the @ symbol.
So if I want to go to my desktop folder, I will type -
You can directly go to the desktop folder by typing
Pro Tip - Note that the D of Desktop is in capital.
Now, we have to know the bit rate of the video.
Assuming that your terminal is pointing to the folder where your file is located, type
ffmpeg -i videoname.format-type
[ Videoname is the name of the video, format type is the format of the video - webm or mp4 or whatever]
So in my case, I would write -
ffmpeg -i Linux.webm
[ Linux is the name of my video file and its format is webm]
So the bitrate of my file is 1386 kb/s
Now let's start the operation! DON'T FORGET TO POINT YOUR TERMINAL TO THE FOLDER WHERE YOUR FILE IS LOCATED USING THE CD COMMAND.
Objective - Reducing the bit rate of the video to reduce its size. Here's what you have to type in the terminal -
ffmpeg -i Linux.webm -b:v 800k -b:a 96k abc.mp4
So what I did there ?
First I wrote -i ~ this is to tell ffmpeg that the next thing that I will write is actually the input file. Please write the exact name of the original file
Second I wriote -b:v 800k ~ What I did here is I told ffmpeg to reduce the bit rate of the video from the original 1386 kb/s to 800 kb/s
Third I wrote -b:a 96k - I told ffmpeg that the audio bit rate should be 96 kb/s
Lastly I told ffmpeg that the output file sould have abc as its name. And I want the format of the output file to be mp4 - the format that is accepted everywhere.
So now, if I check the file size I see, that the output file is 22 MB. The original file size was 45.9 MB.