Overview
EaseLMS uses AWS MediaConvert to transcode uploaded videos into HLS (HTTP Live Streaming) format with multiple bitrates for adaptive streaming. This provides optimal playback quality across different network conditions and devices.Video Processing Architecture
HLS Output Structure
MediaConvert generates HLS files in a structured format:MediaConvert Client Setup
lib/aws/mediaconvert.ts
Environment Variables
.env.local
The MediaConvert role must have permissions to read from and write to your S3 bucket.
Creating MediaConvert Jobs
Job Configuration
ThecreateMediaConvertJob function creates HLS transcoding jobs:
lib/aws/mediaconvert.ts
Output Configurations
- 1080p @ 5 Mbps
- 720p @ 3 Mbps
- 480p @ 1.5 Mbps
HLS Path Generation
The system generates HLS paths based on the original video key:lib/aws/mediaconvert.ts
Example Path Transformation
Job Status Monitoring
Check Job Status
lib/aws/mediaconvert.ts
Job Status Values
- SUBMITTED
- PROGRESSING
- COMPLETE
- ERROR
Job has been submitted to MediaConvert queue.
Video Player Integration
The frontend uses Media Chrome for HLS playback:lib/hooks/useHLS.ts
Adaptive Bitrate Selection
HLS.js automatically selects the optimal bitrate based on:- Network bandwidth: Measured during playback
- Screen size: Higher quality for larger screens
- Buffer health: Switches to lower quality if buffering occurs
URL Generation for Playback
Get HLS Manifest URL
lib/aws/s3.ts
Prefer HLS with MP4 Fallback
lib/aws/s3.ts
Deleting Videos with HLS
When deleting videos, clean up both original and HLS files:lib/aws/s3.ts
Complete Upload & Transcode Flow
1
Upload Original Video
Upload MP4 to S3 using presigned URL:
2
Trigger MediaConvert Job
Create transcoding job:
3
Monitor Job Progress
Poll job status until complete:
4
Get HLS URL
Generate HLS manifest URL:
5
Play Video
Use HLS.js or native player:
IAM Role Configuration
The MediaConvert role requires these permissions:MediaConvert IAM Role Policy
Best Practices
Use Quality-Variable Bitrate (QVBR)
Use Quality-Variable Bitrate (QVBR)
QVBR provides better quality-to-file-size ratio than constant bitrate:
Set Appropriate Segment Length
Set Appropriate Segment Length
10-second segments balance startup time and seek performance:
Enable Acceleration for Faster Processing
Enable Acceleration for Faster Processing
Use accelerated transcoding for time-sensitive content (higher cost):
Store Job IDs for Monitoring
Store Job IDs for Monitoring
Save MediaConvert job IDs in your database to track processing status and handle failures.
Troubleshooting
Job Fails Immediately
Check that the MediaConvert role has S3 read/write permissions and the input file exists.
HLS Playback Fails
Verify CORS is configured on S3 and the master playlist exists at the expected path.
Low Quality Output
Increase QVBR quality level (7-9) and max bitrate for higher quality output.
Slow Processing
Enable acceleration mode or reduce output resolutions for faster transcoding.
Next Steps
File Storage
Learn about S3 storage patterns and CDN integration
Architecture
Understand the complete system architecture