c# - Is it possible using `ffmpeg.exe` in a shared hosting server? -
i use ffmpeg.exe
convert video files flv
but not work in shared host. possible using ffmpeg
in shared host @ all? code:
private bool returnvideo(string filename) { string html = string.empty; //rename if file exists int j = 0; string apppath; string inputpath; string outputpath; string imgpath; apppath = request.physicalapplicationpath; //get application path inputpath = apppath + "originalvideo"; //path of original file outputpath = apppath + "convertvideo"; //path of converted file imgpath = apppath + "thumbs"; //path of 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); } this.fileuploadimagevideo.saveas(filepath); string outputfile; outputfile = "~/originalvideo/" + filename; int = this.fileuploadimagevideo.postedfile.contentlength; system.io.fileinfo = 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 application path exepath = apppath + "ffmpeg.exe"; system.diagnostics.process proc = new system.diagnostics.process(); proc.startinfo.filename = exepath; //path of exe executed, "filebuffer" "flvtool2.exe" proc.startinfo.arguments = cmd; //the command executed proc.startinfo.useshellexecute = false; proc.startinfo.createnowindow = true; proc.startinfo.redirectstandardoutput = false; proc.start(); while (proc.hasexited == false) { } }
you can't instantiate system.diagnostics.process object unless you're running @ fulltrust.
this class contains link demand , inheritance demand @ class level applies members. securityexception thrown when either immediate caller or derived class not have full-trust permission.
usually hosting providers not allow applications on shared hosts run under full trust. contact support more details or run code on server.
to change trust level, set in web.config
<trust level="full" originurl=""/>
Comments
Post a Comment