Convert flv to mp4 using ffmpeg

There are many tools, including free ones that allow for video conversion, however, many of them use GUIs and don't allow for automation of tasks. FFmpeg is a command line based tools which allows to do very neat video manipulations.

We would like to share this small script, which our IT specialists have used for one of our video conversion projects. It parses a directory, finds all flv (Flash video) files and converts them to mp4. This script can be added to a cronjob to run on a scheduled basis. Converted videos can be moved elsewhere upon completion.

As mentioned, we've used ffmpeg to accomplish this task, running under Ubuntu 14.04. FFmpeg doesn't come with Ubuntu 14.04 and a package repository needs to be added manually first.

If you don't have FFmpeg installed, you have to run this command first to add the repository:

sudo add-apt-repository ppa:mc3man/trusty-media

Once added, run update to get the ffmpeg package listing:

sudo apt-get update

Finally, install the package:

sudo apt-get install ffmpeg

In this particular example, both input output files are located in /home/vids. This can be changed as required.