c# - .net application returns a connection reset when converting non-wav or non-mp3 files using FFmpeg -
i making .net application allows user upload audio file , convert mp3. using ffmpeg. works .wav , .mp3, application returns "connection reset" (i use firefox 4 testing) when try upload formats .wma or .m4a. naturally, when testing errors uploading unsupported files .jpg returned same thing. command line argument worked intended when did using cmd.
here code:
using system; using system.collections.generic; using system.linq; using system.web; 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 system.text.regularexpressions; namespace audioconvert { public partial class _default : system.web.ui.page { process ffmpeg; protected void page_load(object sender, eventargs e) { } protected void btnupload_click(object sender, eventargs e) { string audio; string mp3; if (fileupload1.hasfile) { fileupload1.saveas(@"\temp\"+fileupload1.filename); } //fileupload1.saveas(server.mappath("") + system.io.path.getfilename(fileupload1.filename)); audio = @"\temp\"+fileupload1.filename; //audio filepath mp3 = page.mappath("") + "\\media\\"+fileupload1.filename+".mp3"; ffmpeg = new process(); try { ffmpeg.startinfo.arguments = "-y -i \"" + audio + "\" -ab 128k \"" + mp3; //-command line argument, overwrites automatically ffmpeg.startinfo.filename = page.mappath("ffmpeg.exe"); //ffmpeg file location ffmpeg.start(); ffmpeg.waitforexit(); ffmpeg.close(); } catch { } } } }
Comments
Post a Comment