سؤال

consider user1 uploads a swf file, user2 uploads a flv, user 3 uploads a mp4 file, user 4 uploads a 3gp file,

and for showing cross browser we need have above file in this formats (swf,3gp,mp4,flv,ogv) how can do it as soon as user uploads his/her file in asp.net


Thanks @Florestan06 I just test this code

    protected void Button1_Click(object sender, EventArgs e)
{
    string AppPath = Request.PhysicalApplicationPath;
    //This is the path of your application
    string inputPath = AppPath + "ffmpeg\\" + "tizer.mp4";
    //Source Video Path
    string outputPath = AppPath + "outputFolder\\" + "myVideoOutput.flv";
    //Destination Video Path
    string fileargs = " -i \"" + inputPath + "\" \"" + outputPath + "\"";
    //Command Line
    System.Diagnostics.Process proc = new System.Diagnostics.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 = false;
    proc.Start();
}

It convert tizer.mp4 to flv but it's size in 0 bytes now. do you have any Idea?

هل كانت مفيدة؟

المحلول

I would suggest you install ffmpeg on your server and then call ffmpeg commands through .NET. This way you can process the different transcoding of your input file to the desired outputs. This of course once the upload is complete.

Though I am not sure why you need to have both SWF and FLV - FLV should suffice for flash based environment? Have a look here for more information.

EDIT: It convert tizer.mp4 to flv but it's size in 0 bytes now. do you have any Idea?

First you need to learn the basics of ffmpeg for transcoding to the different outputs you are targeting. You can start here and go deeper with the ffmpeg documentation. First make sure your command works in a terminal/command Prompt.

Once this is ok I would suggest you go verbose on the output of your .Net/ffmpeg script trying to catch/log any major steps of the process. I was only pointing at an example of how to execute and external program from .Net. I guess you can find other examples on Stackoverflow or the MSDN community if this one is not working as expected for you.

Having a 0 bytes output file either suggests your ffmpeg command is not valid or there is an issue with your script executing ffmpeg.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top