index.d.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { ProgressCallback } from "./types.js";
  2. /**
  3. * An util function to fetch data from url string, base64, URL, File or Blob format.
  4. *
  5. * Examples:
  6. * ```ts
  7. * // URL
  8. * await fetchFile("http://localhost:3000/video.mp4");
  9. * // base64
  10. * await fetchFile("data:<type>;base64,wL2dvYWwgbW9yZ...");
  11. * // URL
  12. * await fetchFile(new URL("video.mp4", import.meta.url));
  13. * // File
  14. * fileInput.addEventListener('change', (e) => {
  15. * await fetchFile(e.target.files[0]);
  16. * });
  17. * // Blob
  18. * const blob = new Blob(...);
  19. * await fetchFile(blob);
  20. * ```
  21. */
  22. export declare const fetchFile: (file?: string | File | Blob) => Promise<Uint8Array>;
  23. /**
  24. * importScript dynamically import a script, useful when you
  25. * want to use different versions of ffmpeg.wasm based on environment.
  26. *
  27. * Example:
  28. *
  29. * ```ts
  30. * await importScript("http://localhost:3000/ffmpeg.js");
  31. * ```
  32. */
  33. export declare const importScript: (url: string) => Promise<void>;
  34. /**
  35. * Download content of a URL with progress.
  36. *
  37. * Progress only works when Content-Length is provided by the server.
  38. *
  39. */
  40. export declare const downloadWithProgress: (url: string | URL, cb?: ProgressCallback) => Promise<ArrayBuffer>;
  41. /**
  42. * toBlobURL fetches data from an URL and return a blob URL.
  43. *
  44. * Example:
  45. *
  46. * ```ts
  47. * await toBlobURL("http://localhost:3000/ffmpeg.js", "text/javascript");
  48. * ```
  49. */
  50. export declare const toBlobURL: (url: string, mimeType: string, progress?: boolean, cb?: ProgressCallback) => Promise<string>;