Skip to content

Convert Videos in Terminal with avconv

Posted in Ubuntu

On Windows, video conversion software are countless, I guess. Switch over to the camp of Ubuntu, or the *nix clan in general, and the options aren’t countless.

Nonetheless, the *nix blessed us all with the Terminal, a place where, even when blind, you could still get something done, such as converting videos.

This is how I convert videos in terminal in my Ubuntu using avconv (FFmpeg).

Why convert video?

The reasons are many, but in my case, converting videos are kinda a must. After recording video with my phone, it’s time to edit. I use Lightworks on Ubuntu for my video editing.

The trick is video recorded by my phone, Xperia z2, always happen in a variable framerate. This variability in framerate prevents non-linear editing software like Lightworks to be able to import these kinda videos.

I recently purchased FV Camera Pro which gives the ability to record in a specific framerate, unlike the default camera app that comes on CyanogenMod, Stock Xperia Z2, or even using the Google Camera app.

Honestly, I won’t be able to go over why such variability in framerate exists when recording. All I can say at this point is, ‘they say’ it helps in reducing filesize.

So to get this video imported into Lightworks, they need to be converted, which brings us to the next subheading

Convert Videos in Terminal

I assume you have FFmpeg installed on your Ubuntu box. If not, do so, please, maybe with the command,

If that’s not working, please do read how to do so for your OS

Now, change directory to the folder in which you’ve got all your videos ready to be converted. In this video conversion, we’ll be taking variable framerate videos and fixing them at framerate of 30 compulsorily, so that we can import to Lightworks.

So, in the folder of the videos? Enter this:

That should do the conversion, one after another, prefixing each of the converted videos with “out-” . Of course, you can play with the snippet anyhow to perhaps output the files into a different directory etc.

Am I going to explain the commands? Yes, but I am not going to do the explanations. Head over to Explainshell.com to learn the meaning of every single line in the above snippet!

Commands Explained on Explainshell.com