The method to convert video to .flv is too easy. You can downlaod following files from here or .net.
1) ffmpeg.exe
2) ffplay.exe
3) pthreadGC2.dll
After dowloading all the files
Follow the steps wrtitren:-
1)Make a new .net web site or windows application.
2)Copy and paste all the 3 above written files to root location
3)Copy and Paste code written below
4)Put an upload to page and rename to “fileuploadImageVideo”
5)put and button and rename to btn_Submit
6)Make 3 folders OriginalVideo, ConvertVideo, Thumbs
7)Import Class “using System.IO;”
private bool ReturnVideo(string fileName)
{
string html = string.Empty;
//rename if file already exists
int j = 0;
string AppPath;
string inputPath;
string outputPath;
string imgpath;
AppPath = Request.PhysicalApplicationPath;
//Get the application path
inputPath = AppPath + "OriginalVideo";
//Path of the original file
outputPath = AppPath + "ConvertVideo";
//Path of the converted file
imgpath = AppPath + "Thumbs";
//Path of the preview file
string filepath = Server.MapPath("~/OriginalVideo/" + fileName);
while (File.Exists(filepath))
{
j = j + 1;
int dotPos = fileName.LastIndexOf(".");
string namewithoutext = fileName.Substring(0, dotPos);
string ext = fileName.Substring(dotPos + 1);
fileName = namewithoutext + j + "." + ext;
filepath = Server.MapPath("~/OriginalVideo/" + fileName);
}
try
{
this.fileuploadImageVideo.SaveAs(filepath);
}
catch
{
return false;
}
string outPutFile;
outPutFile = "~/OriginalVideo/" + fileName;
int i = this.fileuploadImageVideo.PostedFile.ContentLength;
System.IO.FileInfo a = new System.IO.FileInfo(Server.MapPath(outPutFile));
while (a.Exists == false)
{
}
long b = a.Length;
while (i != b)
{
}
string cmd = " -i "" + inputPath + "" + fileName + "" "" + outputPath + "" + fileName.Remove(fileName.IndexOf(".")) + ".flv" + """;
ConvertNow(cmd);
string imgargs = " -i "" + outputPath + "" + fileName.Remove(fileName.IndexOf(".")) + ".flv" + "" -f image2 -ss 1 -vframes 1 -s 280x200 -an "" + imgpath + "" + fileName.Remove(fileName.IndexOf(".")) + ".jpg" + """;
ConvertNow(imgargs);
return true;
}
private void ConvertNow(string cmd)
{
string exepath;
string AppPath = Request.PhysicalApplicationPath;
//Get the application path
exepath = AppPath + "ffmpeg.exe";
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = exepath;
//Path of exe that will be executed, only for "filebuffer" it will be "flvtool2.exe"
proc.StartInfo.Arguments = cmd;
//The command which will be executed
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.RedirectStandardOutput = false;
proc.Start();
while (proc.HasExited == false)
{
}
}
protected void btn_Submit_Click(object sender, EventArgs e)
{
ReturnVideo(this.fileuploadImageVideo.FileName.ToString());
}
Now run the application select a video file, that will get converted and come to ConvertVideo Folder
Reference: http://forums.asp.net/t/1356425.aspx
Roulette Tricks
Great idea, thanks for this tip!
Roulette Tip
Great idea, but will this work over the long run?
PaidOnlineSurveys
found your site today and really liked it.. i bookmarked it and will be back to check it out some more later ..
Carlos Correia
Hey Rana,
Thanks for this post.
I have a class that converts a video using fvec. The converted video is created in a different folder, but the problem is that while the process is running the flv video is created in this folder with 0 bytes and raises until it ends.
How can I “hide” the new flv and show it ONLY when the process finishes? (without write it in a temporarly file and then move it).
Thanks!
Mike
I’ve tried this source form wmv file and didn’t worked for me, it created 0KB flv file, may be there are some limitations for file size or formats?
Val
Great info !!!!!!!!
Thanks a looot !
Works great for my site !
johnalphen
Yes, you can also try Media Manager Pro at http://www.all4dotnet.com/features.aspx It can convert any format video into any other format video including flv, avi, mpg, mov, wma, wmv, 3gp etc. using .net applications. It can also grab thumbnails and post watermark on your videos in .net.
murali
Hi
Unable to Download Full Project. Help me
Regards
Murali
S.M. Saidur Rahman
Hi Murali
Sorry my server went down. Please check now.
-Rana
murali
Hi Rana
Thanks for your quick update and able to downloads the files.
-Murali
Mozhde
thank you for this post but,
the code convert the file to flv but when i want to open the .flv file it does not open . why??
Bishal
pthreadGC2.dll file is not loaded in my application
Bishal
unable to load pthreadGC2.dll file in my page . how to make accessible dll file in my page any idea, its urgent for me…
Sandeep Beniwal
I used the same code, But in ConverVideo i got the file of KB. Thats don’t solve my problem.
Atul Shende
very nice and exactly working code sir, from long time i am searching this type of code.
thank you for this post sir.
one suggestion sir add given line in web.config
this will allow upload a file up to size of 200Mb.
your code is very nice works for small size but for big size it won’t work..
Atul Shende
opening angle bracket httpRuntime executionTimeout=”1200″ maxRequestLength=”200000″ / closing angle bracket
Atul Shende
Sir,
R u know how to open pdf,doc,docx,ppt,pptx files on web as like google shows it as view mode