Welcome to Dream.In.Code
Become an Expert!

Join 150,120 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,979 people online right now. Registration is fast and FREE... Join Now!




using ffmpeg in asp.net

 
Reply to this topicStart new topic

using ffmpeg in asp.net, while converting the media file by using ffmpeg an exception wasrised

ravurirkk
20 Jun, 2008 - 08:33 PM
Post #1

New D.I.C Head
*

Joined: 20 Jun, 2008
Posts: 2

While executing this an exception was rised i.e win32 exception,
how to handle this exception.


csharp

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Diagnostics;
using System.Media;
using System.ComponentModel;
using System.ComponentModel.Design;


//using IsolatedStorageFileStream;

public partial class _Default : System.Web.UI.Page
{
Process ffmpeg;
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
string video;
string mpg;

video = HttpContext.Current.Server.MapPath("Uploads\\" + FileUpload1.FileName); // setting video input name with path
mpg = Page.MapPath("") + "\\video.flv"; // thumb name with path !

//String filePath = actualfilePath.Substring(0, actualfilePath.LastIndexOf("\\"));
ffmpeg = new Process();

ffmpeg.StartInfo.Arguments = " -i " + video + " -s 480*360 -deinterlace -ab 32 -r 15 -ar 22050 -ac 1 " + mpg; // arguments !
ffmpeg.StartInfo.FileName = Page.MapPath("ffmpeg.exe");

ffmpeg.Start(); // start !
ffmpeg.WaitForExit();
ffmpeg.Close();

string AppPath = Request.PhysicalApplicationPath; //This is the path of your application
Response.Write(AppPath);
string inputPath = AppPath + "ffmpeg\\myVideo.wmv"; //Source Video Path
inputPath = FileUpload1.PostedFile.FileName;
FileUpload1.SaveAs(MapPath("image/" + FileUpload1.FileName));

string outputPath = AppPath + "outputFolder\\" + FileUpload1.FileName.Split('.')[0] + ".flv"; //Destination Video Path
string fileargs = " -i ";
fileargs += "\"" + inputPath + "\"";
fileargs += " \"" + outputPath + "\"";//Command Line

/*Process proc = new Process();
proc.StartInfo.FileName = AppPath + "ffmpeg\\ffmpeg.exe"; //Path of FFMPEG
proc.StartInfo.Arguments = fileargs;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = false;
proc.StartInfo.RedirectStandardOutput = true;*/


Process process = new Process();
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.FileName = AppPath + "ffmpeg\\ffmpeg.exe"; //Path of FFMPEG
process.StartInfo.Arguments = fileargs;
process.StartInfo.WorkingDirectory = "C:\\Windows\\system32";

process.StartInfo.WorkingDirectory=Server.MapPath("~/ffmpeg.exe");
process.Start();
string output = process.StandardOutput.ReadToEnd();
//proc.Start();
//proc.Site;
System.Threading.Thread.Sleep(1000);
//string strErr = proc.StandardError.ReadToEnd();
//proc.WaitForExit();
//string output = proc.StandardOutput.ReadToEnd();

}
}


Mod Edit: Please use code tags when posting your code. Code tags are used like so => code.gif

Thanks
PsychoCoder smile.gif
User is offlineProfile CardPM
+Quote Post

eslam_is_1
RE: Using Ffmpeg In Asp.net
28 Jun, 2008 - 02:00 AM
Post #2

New D.I.C Head
*

Joined: 28 Jun, 2008
Posts: 1

hi kindly try this code it may help u to fix the errors

csharp

//converting video

Process ffmpeg; // creating process
string video;
string mpg;
video = Page.MapPath("x.wmv"); // setting video input name with path
mpg = Page.MapPath("") + "\\video.flv"; // thumb name with path !
ffmpeg = new Process();

string fileargs = " -i ";
fileargs += "\"" + video + "\"";
fileargs += " \"" + mpg + "\"";//Command Line

// ffmpeg.StartInfo.Arguments = " -i \"" + video + "\"-target vcd -bf 2\"" + mpg + "\""; // arguments !
ffmpeg.StartInfo.Arguments = fileargs;
ffmpeg.StartInfo.FileName = Page.MapPath("ff/ffmpeg.exe");
ffmpeg.Start(); // start !


Mod Edit: Please use code tags when posting your code. Code tags are used like so => code.gif

Thanks
PsychoCoder smile.gif
User is offlineProfile CardPM
+Quote Post

ravurirkk
RE: Using Ffmpeg In Asp.net
28 Jun, 2008 - 02:47 AM
Post #3

New D.I.C Head
*

Joined: 20 Jun, 2008
Posts: 2

QUOTE(eslam_is_1 @ 28 Jun, 2008 - 03:00 AM) *

hi kindly try this code it may help u to fix the errors

//converting video

Process ffmpeg; // creating process
string video;
string mpg;
video = Page.MapPath("x.wmv"); // setting video input name with path
mpg = Page.MapPath("") + "\\video.flv"; // thumb name with path !
ffmpeg = new Process();

string fileargs = " -i ";
fileargs += "\"" + video + "\"";
fileargs += " \"" + mpg + "\"";//Command Line

// ffmpeg.StartInfo.Arguments = " -i \"" + video + "\"-target vcd -bf 2\"" + mpg + "\""; // arguments !
ffmpeg.StartInfo.Arguments = fileargs;
ffmpeg.StartInfo.FileName = Page.MapPath("ff/ffmpeg.exe");
ffmpeg.Start(); // start !



Thank You for ur help
I solved my problem by using ur code.

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 01:19AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month