united states of america usa  linkedinfacebook   Call Us Today: (315) 646-4455

Convert flv to mp4 using ffmpeg

FFmpegThere 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.

ls -f /home/vids/*.flv | while read -r file;
#-- get just the file name --#
echo ffmpeg -y -i $name.flv -c:v libx264 -crf 19 -strict experimental $name.mp4


ALT IT Consulting is a full service IT services firm. Our IT consultants can help you with any custom software or automation project. Contact ALT today for to find out more.

Original article was published on ALT IT Consulting Miami.

Last updated Apr 13, 2024