Skip to content

Repository files navigation

m4k - media toolkit

A Bun media optimizer based on ffmpeg and sharp/libvips.

The docker image is available at ghcr.io/sv2dev/media-optimizer. It uses Bun as runtime.

Usage

Running the server

The @m4k/server can be deployed as a docker container.

docker run -p 3000:3000 -v $(pwd)/output:/output ghcr.io/sv2dev/m4k:0.2.1

Alternatively, you can install the server as a local package and run it:

bun add @m4k/server

Note: This server implementation is using Bun as runtime, so it can only be run on a system that has Bun installed.

Then, run the server:

bun run @m4k/server

Or import the server as a module and embed it in your project:

import { serveOpts } from "@m4k/server";

Bun.serve(serveOpts);

Using the client

The client is available as a standalone package @m4k/client. You can use it to connect to the m4k server.

Example, using the client on Bun:

import { ProcessedFile, processVideo } from "@m4k/client";

for await (const value of processVideo(
  "http://localhost:3000",
  Bun.file("fixtures/video.mp4"),
  { format: "mp4", videoCodec: "libx265", output: "output/video.mp4" }
)) {
  if (value instanceof ProcessedFile) {
    // handle the processed file
  } else {
    // handle the status update
  }
}

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages