Skip to content
Shivendra Pratap Singh edited this page Jun 12, 2021 · 3 revisions

FFmpeg object's are obtained from FFmpegFactory.CreateFFmpeg()

Example:

        var ff = FFmpegFactory.CreateFFmpeg();

IsLoaded : Property (bool)

Indicates Whether FFMpeg core wasm loaded or not

Examples:(razor)

    var isLoaded=ff.IsLoaded;

Load(bool triggerEvent): async Task

Download pure Wasm On Client side around ~25 MB , for 1st time

Arguments:

  • triggerEvent whether to trigger events like progress at object level or not, if false FFmpegFactory.Progress can give progress ratio

Examples:

   await ff.Load();
   //or 
    ff.Progress+=(p)=>Console.WriteLine(p.Ratio);
   await ff.Load(true); //true triggers event at instance level

Events associated per instance

  • Logger an event to get log messages, a quick example is ff.Logger+=(e) => console.WriteLine(e.message);
  • Progress a event to trace the progress, a quick example is ff.Progress+=(p) => Console.Writeline(p);

Run(params string[] Parameters): async Task

This is the major function in ffmpeg.wasm, you can just imagine it as ffmpeg native cli and what you need to pass argument in the same way. Arguments:

  • Parameters variables number of params you can pass around

Examples:

        await ff.Run("-i", "myFile.mp4", "output.mp3");

ReadFile(string name): Task<byte[]>

Read In-Memory Wasm File (Ideal Method)

Arguments:

  • fileName in-memory file name

Examples:

      var res = await ff.ReadFile("output.mp3");

UnlinkFile(string path):void

Delete In Memory Wasm file Arguments:

  • path path to in-memory file to delete

Examples:

        ff.UnlinkFile("myFile.mp4");

WriteFile(string path, byte[] buffer):void

Write buffer of C# to WASM in-memory File so that FFmpeg can interact Arguments:

  • path path to in-memory file to write
  • buffer >array bytes to write

Examples:

      ff.WriteFile("myFile.mp4", buffer);

FS(string method, params object[] args):Task

slow method to do Custom Emscripten File System Operation (Use faster ReadFile, WriteFile Instead) Arguments:

  • method: method Name to call eg : readFile,unlinkFile
  • args >variable no of argument can be passed

Examples:

      ff.FS("unlinkFile", "vid.mp4");

Exit():void

Exit out or terminate any ffmpeg running task Arguments:

Examples:

      ff.Exit();