MAV - FFmpeg bindings for Mojo

MAV: Mojo Audio Video

Github: GitHub - josiahls/mav: Low level FFmpeg (8.*) bindings to Mojo for audio, image, and video processing · GitHub

Low level FFmpeg (8.*) bindings to Mojo for audio, image, and video processing. The bindings are avilable via the mojo community channel (Note the installation section below.

Emphasis should be placed on Low Level. This repo will never provide a high level API.

This project is originally part of ash_dynamics, but has been separated out to be used by other projects.

This package uses ffmpeg 8.0.1 from conda-forge. Please see the LICENSE section for more information.

High Level API Reference

Its strongly recommended to use the native FFmpeg C examples for now.

High Level API Current Projects Using MAV

Goals

My goals with mojo involves robot training and simulation, however we have not had a nice way to visualize renderings. This repo + momanim is where I’m playing with / learning high performance rendering using mojo, hopefully eventually rolling into robot simulation.

Demo / Examples in Mojo:

Video outputs from tests/test_ffmpeg/test_video_example.mojo

Gif:
test_video_save

Additionally outputs mp4 and webm video files.

Image outputs from tests/test_ffmpeg/test_image_example.mojo

Png:

Jpeg:

Installation

mav will install FFmpeg, however the Mojo compiler must be pointed to those libraries.

pixi.toml example. Reference the Current Projects above for practical usage.

[workspace]
channels = [
"https://repo.prefix.dev/modular-community",
"conda-forge"
]

[activation.env]
LIBRARY_PATH = "$CONDA_PREFIX/lib:$LIBRARY_PATH"
MAV_LINKERS = " -Xlinker -lavutil -Xlinker -lavcodec -Xlinker -lswresample -Xlinker -lswscale -Xlinker -lavformat"

[dependencies]
mav = "==0.0.4"

Usage:

mojo build $MAV_LINKERS some_file -o some_file && ./some_file

Note execution is a little awkward due to [BUG] `-Xlinker` ignored for `run` or `debug` · Issue #6155 · modular/modular · GitHub