Automatically converting video files

Issues related to software problems.
Post Reply
liamk1993
Posts: 1
Joined: 2014/07/10 16:31:52

Automatically converting video files

Post by liamk1993 » 2014/07/10 16:40:40

Hello guys I am new here and quite new to linux and CentOS, I'm using CentOS 5.9 because I thought it might have been most stable and have most support due to it's age, please correct me if I am wrong.

I have a server setup with a website for sharing videos (from myself not public) but the videos are uploaded to the server and I would like then to be automatically converted when they are uploaded, I'm wondering if there are any scripts available to do this as there are a lot of files to convert, a bit of info about the files:

There are lots of them
They are different types, avi, mp4, mkv
They are all in different folders and the folders have spaces in them too (I know this might matter if there is a script doing the work)

I really need to change them all into MP4 and would love a shell script to do it using ffmpeg or something similar, it doesnt matter if its not really automatic when they are added in there I dont mind running the script myself on an as needed basis but I would like it to find the files it's self at least.

So the question is, are there any scripts or software like this available? or any examples available that I can work from as I have no idea where to start at all.

Any help is really appreciated, thank you all in advance.

wintpe
Posts: 17
Joined: 2014/08/26 08:56:59

Re: Automatically converting video files

Post by wintpe » 2014/08/27 13:22:32

centos 5.9 probably is not the best choice for video conversion.

you are right its very stable because its based on a very conservative attitude to
the concept of shiny.

in otherwords shiny is not always better.

but in the case of video conversion, you probably want the most upto date versions of mencoder
or ffmpeg, etc.

and for that centos 7 is probably a better approach.

as for how to do it.

1: write a script that uses mencoder or ffmpeg to take an argument.

so a script needs top be something like

#!/bin/sh
mencodercommandline $1 ${1}.mpeg4


$1 is the argument to the script, so if the script was called as follows

script videofile1

then mencodercommandline will be called with videofile1 videofile1.new

ie input and output file.

theres more to mencoder read up on it for all the options its quite deep.

then second as follows.

use find, to run the script

find /myvideocollectiondirectory -name "videofile*" -exec script {} \;

everything found from the find, will call script and pass the found to the {}

so every file that matches videofile1 all the way down your directory tree will be presented to script will run with that as $1

now to automate it

add the find command to a file and place it in /etc/cron.daily

other things you can do are inside script remove the old file once done.

do some fancy logic to strip off the old file extension, and not reprocess already processed files.

anyway hope all those ideas help, much more for you to do to implement that, but its a way to head.

regards peter
Redhat 6 Certified Engineer

Post Reply