Skip to main content
This page provides a collection of short code snippets that showcase the most common operations you may use Mediabunny for.

Read file metadata

Extract information about a media file without decoding the actual media data:

Create new media files

Create a new media file from scratch using various sources:
  • You can create files of many different formats - see Output formats
  • Media data can be added from different sources - see Media sources

Convert files

Convert between different media formats with automatic transmuxing or transcoding:
This code will automatically transmux (copy media data) when possible, and transcode (re-encode media data) when necessary.

More examples

1

Read media data

Decode video frames and audio chunks from a media file:
See Media sinks for all the ways to extract media data from tracks.
2

Extract video thumbnails

Generate thumbnail images from video files:
3

Compress media files

Reduce file size by resizing, lowering quality, or trimming:
4

Record live media

Capture from webcam or microphone and save to a file:

Next steps

Now that you’ve seen the basics, dive deeper into specific topics:

Reading media files

Learn about input sources, demuxers, and extracting data

Writing media files

Understand output targets, muxers, and media sources

Converting media files

Master transmuxing, transcoding, and conversion options

Supported formats

See the full list of container formats and codecs