Once in a while, you need to convert media from one format to another, even in a cloud-centric world where everything is a “stream.” There can be different reasons for doing so. In most cases, I have to convert videos that I shoot or purchase so that I can play them on my mobile devices or other players, which support only certain formats.
Converting media files or transcoding is extremely easy in Linux, thanks to many open source projects.
I have a heterogeneous environment at home, a mix of Mac OS X, Linux desktops, Chrome OS devices, Android phones and tablets, Yamaha music system, and car infotainment. So, I always convert my videos in a format that is supported on all these platforms and, in most cases, the supported format is .mp4.
There are two ways you can convert your videos to mp4: either using a less-known feature of VLC or with the standalone app Handbrake.
Use VLC to Convert Videos
VLC is known as the media playback Swiss army knife because it can play virtually every media format out there. However, many features of VLC are less known, and transcoding is one of them.
To get started, open VLC and, from the main menu, choose Media > Convert/Save (see Figure 1 above).
Then, click on the Add button and browse the video file that you want to transcode. Click on the Convert/Save button at the bottom and it will open another window. Here you will see the source file, and under Settings, you can choose what format do you want to convert it into.
You can also click on the wrench/screwdriver icon, which will allow you to fine-tune your transcoding as you can choose the appropriate container, codecs for your video (Figure 2).
If you are transcoding for a particular device or platform, for example YouTube, you can choose appropriate format from the drop-down menu (Figure 3)
Once you have chosen the desired output format, it’s time to choose the destination. Click on the Browse button and choose the location where you want the converted file to be saved. At this point, you need to give a name to the file you are going to convert. (I wish it used the current name of the file.) Give it a name and then click on Save.
Once everything looks good, hit the Start button and VLC will start transcoding your video.
Handbrake for Batch Transcoding
Although VLC does an excellent job of transcoding, Handbrake is the open source app that was created just to do this. And, it can also do batch conversion. If you are on an Ubuntu-based system, you need to install two packages in order to get .mp4 support. Add the handbrake repository to your system and install those packages:
sudo add-apt-repository ppa:stebbins/handbrake-git-snapshots
sudo apt-get update
sudo apt-get install handbrake-cli handbrake-gtk
Open Handbrake and click on Source. Then, select the file you want to convert; once it’s loaded, click on the Enqueue button, and it will add the file to the queue. Click on Source again, select the next file, and add it to the queue. Repeat the process to add all the files that you want to convert (Figure 4).
Alternatively, if you want to make it easier, create a folder and copy all the files that you want to convert into that folder. Then select that entire folder -- instead of a file -- from Source. Once Handbrake scans all files, click on Queue from main menu and choose Add Multiple. Handbrake will then add all the files from that directory to the conversion queue.
Once all the files are added to the queue, choose the desired output format from the Preset List. You can further fine-tune it by adjusting the settings from the options on the main window.
Next, choose the destination for the exported/converted files. If everything looks good, go ahead and start conversion either from Queue > Start Queue or by hitting the Start button.
Handbrake will start converting your files (Figure 5).
Audio Conversion with Sound Converter
VLC can convert audio files as well, just follow the instructions above and choose audio files instead of videos files. But if you are looking for batch processing or a simpler app, then you can install the Sound Converter application on your Linux box; it’s available in the main repo of major distributions. The app has a very simple interface.
If you want to convert only one audio track, choose Add File, if you have more than one file, then choose Add Folder option.
Once all files are added, click on Preferences and change the destination in the Where to place results option. You can also choose how to rename files (if you want to).
The third and the most important option is output format. Most players support .mp3 format, so that’s the one I would prefer. Adjust the bitrate and quality, if you want to, and close the window (Figure 6).
You will see the list of all the files you added; select them all and click on Convert; Sound Convert will transcode all your files in the desired audio format.
One of the greatest features of Sound Converter is that it can also “extract” audio from video files. So, if you need to rip just the audio, this is the app for you. Just add the video files and convert them to the desired audio format. As you can see in Figure 7, there are three video files that I am converting to audio files.
That’s pretty much what you need to convert media in Linux. It’s Linux, so there’s more than three ways to do it; tell us how do you do it.