Im trying yo upload a video. The video has to be converted from its original video format to an .swf format. To conver the video i am using ffmpeg. To play the video i am using an swf player.
The problem is that when i upload a video file (either wmv, mpeg of avi) the file is not being saved in the file system but the details are saved in the database. What would cause this error.
This is the c# code i have for the ffmpeg and for saving the database details.
I do see that you are avinf the file using SaveAs of FileUpload and then at the end of code you are Removinf the file using File.Delete()...i think thaat is the reason whhy you are not able to see the file...
From the code you provided, it seems like OK. In order to resolve your issue, please debug step by step and see whether filename
and imgname exist. And check whether there is an exception is thrown out when execute the sqlstatement.
Best wishes,
Please mark the replies as answers if they help or unmark if not.
Feedback to us
TheInteracti...
Member
15 Points
55 Posts
Uploaded media not being saved on file system
Jan 24, 2013 05:50 PM|LINK
Im trying yo upload a video. The video has to be converted from its original video format to an .swf format. To conver the video i am using ffmpeg. To play the video i am using an swf player.
The problem is that when i upload a video file (either wmv, mpeg of avi) the file is not being saved in the file system but the details are saved in the database. What would cause this error.
This is the c# code i have for the ffmpeg and for saving the database details.
Default.aspx
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.IO; using System.Diagnostics; using System.Data.SqlClient; public partial class _Default : System.Web.UI.Page { string postedfilename, SavePath, Filenamewithpath; protected void Page_Load(object sender, EventArgs e) { lblmsg.Text = ""; } protected void btnsub_Click(object sender, EventArgs e) { if (FileUpload1 != null || FileUpload1.PostedFile != null) { postedfilename = FileUpload1.PostedFile.FileName; SavePath = AppDomain.CurrentDomain.BaseDirectory + "Video\\"; string NewFName = postedfilename; NewFName = NewFName.Substring(NewFName.LastIndexOf("\\") + 1, NewFName.Length - NewFName.LastIndexOf(".")) + "." + NewFName.Substring(NewFName.LastIndexOf(".") + 1); Filenamewithpath = SavePath + NewFName; //Save The file FileUpload1.PostedFile.SaveAs(Filenamewithpath); //Start Converting string inputfile, outputfile, filargs; string withoutext; //Get the file name without Extension withoutext = Path.GetFileNameWithoutExtension(Filenamewithpath); //Input file path of uploaded image inputfile = SavePath + NewFName; //output file format in swf outputfile = SavePath + "SWF\\" + withoutext + ".swf"; //file orguments for FFMEPG filargs = "-i " + inputfile + " -ar 22050 " + outputfile; string spath; spath = Server.MapPath("."); Process proc; proc = new Process(); proc.StartInfo.FileName = spath + "\\ffmpeg\\ffmpeg.exe"; proc.StartInfo.Arguments = filargs; proc.StartInfo.UseShellExecute = false; proc.StartInfo.CreateNoWindow = false; proc.StartInfo.RedirectStandardOutput = false; try { proc.Start(); } catch (Exception ex) { Response.Write(ex.Message); } proc.WaitForExit(); proc.Close(); //Create Thumbs string thumbpath, thumbname; string thumbargs; string thumbre; thumbpath = AppDomain.CurrentDomain.BaseDirectory + "Video\\Thumb\\"; thumbname = thumbpath + withoutext + "%d" + ".jpg"; thumbargs = "-i " + inputfile + " -vframes 1 -ss 00:00:07 -s 150x150 " + thumbname; Process thumbproc = new Process(); thumbproc = new Process(); thumbproc.StartInfo.FileName = spath + "\\ffmpeg\\ffmpeg.exe"; thumbproc.StartInfo.Arguments = thumbargs; thumbproc.StartInfo.UseShellExecute = false; thumbproc.StartInfo.CreateNoWindow = false; thumbproc.StartInfo.RedirectStandardOutput = false; try { thumbproc.Start(); } catch (Exception ex) { Response.Write(ex.Message); } thumbproc.WaitForExit(); thumbproc.Close(); File.Delete(inputfile); lblmsg.Text = "Video Uploaded Successfully"; hyp.Visible = true; hyp.NavigateUrl = "Play.aspx"; } } private void Savedetails() { string filename, imgname; filename = Session["outputfile"].ToString(); imgname = Session["thumbname"].ToString(); SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["VideoConnectionString"].ConnectionString); con.Open(); SqlCommand cmd = new SqlCommand("insert into Videos(Video_File,Video_Image) values('" + filename + "','" + imgname + "')", con); cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); } }is there an error in the code? or is there another way to convert the upload video files to swf.
Any ideas please help?
ignatandrei
All-Star
137690 Points
22151 Posts
Moderator
MVP
Re: Uploaded media not being saved on file system
Jan 25, 2013 04:10 AM|LINK
remove the try/catch and let the error flow.
TheInteracti...
Member
15 Points
55 Posts
Re: Uploaded media not being saved on file system
Jan 25, 2013 12:06 PM|LINK
Thank you, ive tried your suggestion.
However its still operating the same way.
ignatandrei
All-Star
137690 Points
22151 Posts
Moderator
MVP
Re: Uploaded media not being saved on file system
Jan 26, 2013 08:04 AM|LINK
it does not show any error?!
TheInteracti...
Member
15 Points
55 Posts
Re: Uploaded media not being saved on file system
Jan 27, 2013 08:50 AM|LINK
i still have the error. Its still not working correctly.
ive tried using a different version of ffmpeg.exe but it hasnt made a difference.
ramiramilu
All-Star
97899 Points
14509 Posts
Re: Uploaded media not being saved on file system
Jan 27, 2013 08:54 AM|LINK
I do see that you are avinf the file using SaveAs of FileUpload and then at the end of code you are Removinf the file using File.Delete()...i think thaat is the reason whhy you are not able to see the file...
Thanks
JumpStart
TheInteracti...
Member
15 Points
55 Posts
Re: Uploaded media not being saved on file system
Jan 27, 2013 09:02 AM|LINK
Ive tried deleting but still unsuccessful.
Could i be able to email u the sample?
thanks
Catherine Sh...
All-Star
23382 Points
2490 Posts
Microsoft
Re: Uploaded media not being saved on file system
Jan 30, 2013 12:05 AM|LINK
Hi,
From the code you provided, it seems like OK. In order to resolve your issue, please debug step by step and see whether filename and imgname exist. And check whether there is an exception is thrown out when execute the sql statement.
Best wishes,
Feedback to us
Develop and promote your apps in Windows Store