Overview
Ant Media Server provides powerful recording capabilities that allow you to capture live streams in MP4 and WebM formats. The recording system is built on FFmpeg and supports automatic upload to cloud storage services like AWS S3, Azure Storage, and Google Cloud Storage.Recording Formats
Ant Media Server supports two recording formats:- MP4 - H.264/H.265 video with AAC audio
- WebM - VP8/VP9 video with Vorbis audio
Supported Codecs for MP4
The MP4 muxer supports a wide range of codecs:Configuration
Enable Recording
Recording can be enabled at different levels:Application Level
Enable recording for all streams in your application via the Web Panel:Settings → Advanced Settings → MP4 MuxingSet
mp4MuxingEnabled to trueRecording Settings
Key application settings for recording:| Setting | Type | Default | Description |
|---|---|---|---|
mp4MuxingEnabled | boolean | true | Enable/disable MP4 recording |
webMMuxingEnabled | boolean | false | Enable/disable WebM recording |
addDateTimeToMp4FileName | boolean | false | Add timestamp to recording filename |
recordingSubfolder | string | "" | Subfolder for storing recordings |
uploadExtensionsToS3 | int | 7 | Bitmask for file types to upload to S3 |
Cloud Storage Integration
Recordings can be automatically uploaded to cloud storage after the stream ends.AWS S3 Configuration
Configure S3 storage in Web Panel:Upload Behavior
TheRecordMuxer class handles the upload process:
The recording file is renamed from
.mp4.tmp to .mp4 only after the stream successfully ends. This prevents incomplete files from being processed.Recording Lifecycle
Stream Start
When a stream starts, the
RecordMuxer is initialized:- Temporary file created with
.tmpextension - Video and audio streams configured
- Recording starts after first keyframe received
Active Recording
During the stream:
- Video and audio packets written to file
- Codec parameters validated
- File integrity maintained
Advanced Features
Date/Time in Filenames
Add timestamp to recording filenames:streamId_2026-03-04_14-30-15.mp4
Recording Subfolders
Organize recordings in subfolders:VoD Integration
Recordings are automatically registered as Video-on-Demand (VoD) items:- VoD ID
- Stream ID
- File path
- Duration
- Creation date
- File size
Code Examples
Enable Recording via REST API
Check Recording Status
Troubleshooting
Recording file not created
Recording file not created
Possible causes:
- Recording not enabled in settings
- Stream ended before first keyframe
- Insufficient disk space
- Codec not supported
io.antmedia.muxer.RecordMuxerS3 upload fails
S3 upload fails
Possible causes:
- Invalid S3 credentials
- Incorrect bucket name or region
- Network connectivity issues
- IAM permissions insufficient
s3:PutObject permissionIncomplete recordings
Incomplete recordings
Issue: Recording ends with
.tmp extensionCause: Stream did not end gracefully (crash or network disconnect)Solution: You can manually remux the file using FFmpeg:Best Practices
Monitor Disk Space
Ensure sufficient disk space for recordings. Use the
recordingSubfolder setting to organize files.Use Cloud Storage
Enable S3 upload to prevent local disk from filling up. Configure automatic local file deletion.
Validate Codecs
Verify incoming streams use supported codecs (H.264/H.265 for video, AAC for audio).
Test Recovery
Test your recording system with unexpected stream disconnects to ensure proper file handling.
