04 May 2007

Streaming video files with FLV | On the fly converting video to flv files


I have to convert the video files into flv files using asp / PHP script. For this we are using ffmpeg.exe tool. This is a command line tool It will execute in comman prompt and will convert the video files into .flash files. For this we are using Dynu component in asp to call the exe file. We have to use "FFmpeg -i GLOBE.AVI -r 25 -acodec mp3 -ar 22050 -s 320x240 -y GLOBE_21.flv"this line in command line tool so that it will convert into .flv files.

php error_reporting(E_ALL);$obj = new COM("Dynu.Exec");echo "

";echo $obj->execute("C:\Inetpub\wwwroot\php_streaming\Video\ffmpeg\batch.bat");echo "
";//Response.Write(oExec.execute("C:\Inetpub\wwwroot\php_streaming\Video\ffmpeg\batch.bat"))

In ASP you can use it like:
Set oExec = Server.Createobject("Dynu.Exec")Response.Write("

")REM Execute the command "ipconfig" and display its result.Response.Write(oExec.execute("ipconfig"))REM Execute the command "nslookup -type=mx microsoft.com" and display its result.Response.Write(oExec.execute("C:\Inetpub\wwwroot\new\enginetest\ffmpeg.exe"))REM Execute the batch file and display its result.' Response.Write(oExec.execute("C:\Inetpub\wwwroot\new\test.bat"))'oExec.parameters("-i GLOBE.AVI -r 25 -acodec mp3 -ar 22050 -s 320x240 -y GLOBE_21.flv")Response.Write("

")Set oExec = nothing

if you have avi file and want to convert it to flv then use:

$command = "CALL C:\Inetpub\wwwroot\streaming\ffmpeg.exe -y -i ".$dir." -acodec mp3 -ar 22050 -f flv ".$flvpath;

where dir is the file path of avi file.

Enjoy Programming

- Jankit

No comments: