MediaX Class
The MediaX class is the primary entry point of the MediaX SDK. It provides high-level methods to perform media transformations, manage pipelines, and retrieve metadata.
Class Overview
123
Auto-Configuration
Handles initialization of FFmpeg and FFprobe binaries
Rich Methods
Exposes methods for conversion, compression, audio extraction, and more
Event-Driven
Provides event-driven job objects for progress tracking
Pipeline Integration
Integrates with pipelines and queues for batch management
Constructor
1
On Instantiation:
- Auto-configures ffmpeg and ffprobe paths using installers
- Prepares internal registries for jobs and pipelines
- No arguments required - zero configuration setup
Events
Every job returned by a MediaX method is an EventEmitter. Available events:
123456
Methods
1. convert
conversionconvert(input, output, format, options?)
Convert a file from one format to another
mediaX.convert("input.mp4", "output.mkv", "mkv");
2. compress
optimizationcompress(input, output, bitrate)
Reduce file size by re-encoding at a specified bitrate
mediaX.compress("input.mp4", "compressed.mp4", "800k");
3. extractAudio
audioextractAudio(input, output, format)
Extract audio track in given format
mediaX.extractAudio("input.mp4", "output.mp3", "mp3");
4. replaceAudio
audioreplaceAudio(videoFile, audioFile, output)
Replace video's existing audio track with a new one
mediaX.replaceAudio("video.mp4", "voiceover.mp3", "final.mp4");
5. thumbnail
imagethumbnail(input, output, timestamp)
Capture a single frame as an image
mediaX.thumbnail("video.mp4", "thumb.png", "00:00:10");
6. clip
editingclip(input, output, { start, duration })
Extract a short segment
mediaX.clip("movie.mp4", "scene.mp4", { start: 30, duration: 10 });
Additional Methods
Pipeline Method
Chain multiple transformations using the pipeline method:
123456
Error Handling
Custom Error Types
1234567
Properties
list of active jobs
list of active pipelines
resolved path to FFmpeg binary
resolved path to FFprobe binary
Status Monitoring
123456789
Next: Learn Pipelines
Now that you understand the MediaX class, learn how to create powerful pipeline workflows for complex media processing operations.