17 April 2008
On the fly video encoding with classic ASP and ffmpeg
Finding proper information about encoding videos uploaded to your site is quite hard. I have created couple of sites where users would upload videos and then script would take thumbnail of the video but couldn't managed to re-encode the video and/or insert a logo in it like those big companies who has the money and human power to do it.
Not anymore :). After 5 days i have managed to encode uploaded video en insert whatever i want in it. Code below can be implemented to run on the fly but it would be too much resource intensive, so i advise you to create may be an admin page where you can select uploaded videos and encode one by one.
You need;
- latest Ffmpeg (Win32 Shared build with devel libs includes VHooks) from http://arrozcru.no-ip.org/ffmpeg_builds/
- access to your server to set application pool of your site to run as local service (iis manager>application pools>your site's pool>properties>identity > predefined> local system.
Keep in mind that with this setting is a big security compromise, I would isolate it and close access from the internet. - a simple transparent logo in png format to insert in to video
Once you have done those settings use code below in your classic asp code to encode and insert your logo to any uploaded videos. Below code encodes videos as mobile mp4 but you can find information about detailed encoding options from http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html
<%
logo=Server.Mappath("logo.png")
encoderPath=Server.Mappath("bin")
originalFile=Server.Mappath("myfile.wmv")
encodedFile=Server.Mappath("encoded_myfile.wmv")
runme="ffmpeg.exe -i "&originalFile&" -vhook ""vhook/imlib2.dll -x 0 -y 0 -i "&logo&""" -acodec libfaac -ac 1 -ar 12000 -ab 12kb -vcodec mpeg4 -r 15 -s 240x184 -b 128kb "&encodedFile
set WShell = CreateObject("WScript.Shell")
WShell.CurrentDirectory = encoderPath
WShell.run runme, 0, TRUE
set WShell = nothing
%>
thank
<< Home
Subscribe to Posts [Atom]
