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.
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.1Alternatively, you can install the server as a local package and run it:
bun add @m4k/serverNote: 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/serverOr import the server as a module and embed it in your project:
import { serveOpts } from "@m4k/server";
Bun.serve(serveOpts);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
}
}