Skip to content

FFmpegFactory

Shivendra Pratap Singh edited this page Nov 21, 2020 · 1 revision

FFmpegFactory is an Static Class.

FFmpegFactory.Init(jsRuntime,newCDNPath): void

Init is a factory function that Assigns IJSRuntime and injects JS modules automatically

Arguments:

  • jsRuntime an IJSRuntime instance [not null]
  • newCDNPath download any latest js module [can be null]

Examples:(razor)

@inject IJSRuntime Runtime
using FFmpegBlazor;


FFmpegFactory.Init(Runtime);
//or
FFmpegFactory.Init(Runtime,"https://unpkg.com/@ffmpeg/ffmpeg@0.9.5/dist/ffmpeg.min.js");

FFmpegFactory.CreateFFmpeg(options): FFmpeg

CreateFFmpeg is a factory function that creates a FFmpeg instance.

Arguments:

  • options an object of customized options
    • corePath path for ffmpeg-core.js script
    • log a bool to turn on all logs, default is false

Examples:

   var ff = FFmpegFactory.CreateFFmpeg();
   //or
   var ff = FFmpegFactory.CreateFFmpeg(new FFmpegConfig() { Log=false});

Events

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

FFmpegFactory.DownloadBufferAsFile(byte[] buffer, string name, string mime): void

Download Buffer as File on client machine, instantly , without wait

Arguments:

  • buffer bytes of files to be downloaded as link
  • fileName rename file
  • mime type such as 'video/mp4'

Examples:

      FFmpegFactory.DownloadBufferAsFile(res, "output.mp3", "audio/mp3");

FFmpegFactory.CreateURLFromBuffer(byte[] buffer, string name, string mime): string

Creates a URL for a given Buffer so that it can be referenced by Html component as source

Arguments:

  • buffer bytes of files to be downloaded as link
  • fileName file blob name
  • mime type such as 'video/mp4'

Examples:

     var VideoURl= FFmpegFactory.CreateURLFromBuffer(res, "output.mp3", "audio/mp3");

FFmpegFactory.RevokeObjectURL(string urlSource)

Free URL object and buffer , caused by CreateURLFromBuffer()

Arguments:

  • urlSource url to revoke

Examples:

     FFmpegFactory.RevokeObjectURL(videoURL);