united states of america usa  linkedinfacebookgoogle
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.

 

#!/bin/bash 
ls -f /home/vids/*.flv | while read -r file;
do
#-- get just the file name --#
name="${file%.*}"
echo ffmpeg -y -i $name.flv -c:v libx264 -crf 19 -strict experimental $name.mp4
done

 

Our IT consultants can help you with any custom software or automation project. Contact us today for to find out more. 

ALT - your IT experts in Miami!

Tel: (786) 646-6461   |   Toll-Free: (877) 454-0758
1990 NE 163rd St, Suite 215, North Miami Beach, FL 33162, USA
Privacy Policy