Media Normalization
This guide explains the media normalization system that preprocesses videos during the publishing workflow to ensure platform compatibility.
Overviewβ
The publish orchestrator includes a media normalization phase that:
- Detects video content in post submissions
- Rehosts videos to ensure reliable access across platforms
- Normalizes video formats for maximum platform compatibility
- Preserves original video URLs for reference
Implementationβ
Entry: apps/functions/shared/media.js
Key functions:
selectPrimaryMedia(content)- Identifies primary media from post contentnormalizeVideoForPublishing(videoUrl)- Processes and rehosts video
Workflow Integrationβ
The normalization happens in the publish orchestrator before platform fan-out:
- Content Analysis: Extract primary media from post content
- Video Detection: Check if primary media type is "video"
- Normalization: Process video through normalization pipeline
- Request Update: Replace video URL in request with normalized URL
- Fan-out: Send updated request to platform-specific publishers
Data Storageβ
Normalization results are stored in the post submission document:
{
"normalization": {
"videoUrl": "https://normalized-video-url.com/video.mp4",
"contentType": "video/mp4"
}
}
Original video URLs are preserved:
{
"post": {
"content": {
"videoUrl": "https://normalized-video-url.com/video.mp4",
"originalVideoUrl": "https://original-video-url.com/video.mov"
}
}
}
Error Handlingβ
- Normalization failures are logged but don't block publishing
- If normalization fails, original video URL is preserved
- Platforms receive the best available video URL
Benefitsβ
- Platform Compatibility: Videos are processed to work across all platforms
- Reliability: Rehosted videos reduce external dependency failures
- Performance: Optimized videos load faster for end users
- Consistency: Uniform video handling across all publishing targets
Future Enhancementsβ
The normalization system is designed to support:
- Format conversion (MP4, WebM, etc.)
- Resolution optimization per platform
- Thumbnail generation
- Duration and size optimization