locked
FFmpeg Command Line in Asp.Net Core RRS feed

  • Question

  • User338455301 posted

    Hi,

    i want add text to video with ffmpeg ,

    other command line is worked but for this code its not worked ? why ?

        ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.CreateNoWindow = false;
                startInfo.UseShellExecute = false;
                startInfo.FileName = Path.Combine(Directory.GetCurrentDirectory(), "ffmpeg.exe");
    
    //????????
    
                startInfo.Arguments = "-i H://input.mp4 -vf drawtext=" + "fontfile =H://arial.tft: \\" +
    "text = 'Stack Overflow': fontcolor = white: fontsize = 24: box = 1: boxcolor = black@0.5: \\" +
    "boxborderw = 5: x = (w - text_w) / 2: y = (h - text_h) / 2" + " -codec:a copy H://output.mp4";
    
    //????????
                
                    startInfo.RedirectStandardOutput = true;
    
                try
                {
                    using (Process process = Process.Start(startInfo))
                    {
                        process.WaitForExit();
                    }
    
                }
                catch (Exception ex)
                {
    
                    throw;
                }



    Sunday, September 15, 2019 7:54 AM

Answers

  • User338455301 posted

    i use \\ insted of // but its now worked.

     startInfo1.Arguments = "ffmpeg -i H:\\input.mp4 -vf "+'"'+ "drawtext =text='Super User':x=(w-text_w)/2:y=(h-text_h)/2:fontsize=24:fontcolor=white" + '"' + " -c:a copy H:\\out.mp4";



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 17, 2019 4:33 AM

All replies

  • User-474980206 posted
    If you are hosting in iis then the current directory is the iis hosting bin, not the project.
    Sunday, September 15, 2019 4:22 PM
  • User338455301 posted

    i test it in local 
    i put a file  (input.mp4) in H:// and test this code but its not work ?
    i have just problem with this code.

     "-i H://input.mp4 -vf "+'"'+ "drawtext =text='Super User':x=(w-text_w)/2:y=(h-text_h)/2:fontsize=24:fontcolor=white" + '"' + " -c:a copy H://out.mp4";



    Monday, September 16, 2019 10:31 AM
  • User753101303 posted

    Hi,

    It's often easier to start from an actual error message rather then trying to guess from the code.

    If windows try h:\\input.mp4 rather than // - it is \ in Windows and it needs to be escaped in C# unless using "verbatim" strings. You could also a permission error or some other problem for the generated options...

    Monday, September 16, 2019 2:21 PM
  • User338455301 posted

    i use \\ insted of // but its now worked.

     startInfo1.Arguments = "ffmpeg -i H:\\input.mp4 -vf "+'"'+ "drawtext =text='Super User':x=(w-text_w)/2:y=(h-text_h)/2:fontsize=24:fontcolor=white" + '"' + " -c:a copy H:\\out.mp4";



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 17, 2019 4:33 AM