Creating an output
Media file creation in Mediabunny revolves around theOutput class. One instance of Output represents one media file you want to create.
1
Import the required classes
2
Create a new output
format determines the container format of the output file (MP4, WebM, etc.).The target determines where the data will be written (memory, disk, stream, etc.). See the Streaming guide for available targets.Adding tracks
Before starting an output, you need to add tracks to it. Each track requires a media source that provides the media data.Adding a video track
Adding an audio track
Track metadata options
The
frameRate option snaps all timestamps and durations to the specified frame rate. To achieve fractional frame rates precisely, use their exact fractional forms:- 23.976 →
24000/1001 - 29.97 →
30000/1001 - 59.94 →
60000/1001
Setting metadata tags
You can write descriptive metadata tags to the output file:Starting an output
After adding all tracks, you need to start the output:Adding media data
After starting an output, use the media sources to pipe data to the output file:Finalizing an output
Once all media data has been added, finalize the output:Output state
You can check the current state of an output:'pending'- Not started yet; tracks can be added'started'- Ready to receive media data; no more tracks can be added'finalizing'-finalize()has been called but hasn’t completed'finalized'- Output is complete'canceled'- Output was canceled