The Four Phases
You MUST complete each phase before proceeding to the next.
Phase 1: Pipeline & Protocol Strategy
BEFORE processing a single frame:
Protocol Selection
- Live Streaming? WebRTC (Sub-second latency) or LL-HLS (2-5s latency).
- VOD (On Demand)? HLS (Apple) and DASH (Everyone else).
- Rule: Do not invent your own protocol. Use standards.
Adaptive Bitrate (ABR) Planning
- Define the "Ladder": 1080p, 720p, 480p, 360p.
- Cost/Quality Balance: High bitrates = High CDN costs. Optimize CRF (Constant Rate Factor).
- Constraint: What is the minimum bandwidth of your target user?
Storage & CDN Architecture
- Origin Store (S3/GCS) vs Edge Delivery (Cloudfront/Fastly).
- Caching: Video segments are immutable. Cache them aggressively.
- Egress Costs: Calculate this NOW. Video bandwidth is the #1 startup killer.
Phase 2: Encoding & Packaging
The heavy lifting:
Transcoding Pipeline
- Use FFmpeg or cloud services (AWS MediaConvert/Mux).
- Container Formats: fMP4 or TS?
- Audio: AAC is standard, but check opus for low latency.
DRM & Content Security
- Encryption: ClearKey? Widevine (Android/Chrome)? FairPlay (Apple)? PlayReady (Windows)?
- Token Authentication: Secure the CDN URLs so users can't hotlink your streams.
Player Integration (The Client)
- Don't build a player from scratch. Use ExoPlayer (Android), AVPlayer (iOS), or Video.js (Web).
- Hook up the Analytics: You need to know when buffering happens.
Phase 3: Playback Quality (QoE)
Ensuring it plays smooth:
Buffer Strategy
- How much to buffer before starting? (Fast start vs Stability).
- Re-buffering Ratio: Keep this under 1%.
- Startup Time: Goal is < 2 seconds.
Seek & Scrub Performance
- Enable "Byte-Range Requests" for fast seeking.
- Generate "Trick Play" tracks (thumbnails for scrubbing).
Cross-Device Testing
- Test on Low-End Androids (Hardware decoding limits).
- Test on Cellular Networks (Packet loss).
Phase 4: Monitoring & Scale
Keeping the stream alive:
QoE Metrics (Quality of Experience)
- Monitor: Bitrate switches (Are users downgrading?), Error rates, Startup time.
- Alerts: "Rebuffering spike in region US-East."
Live Event Handling
- Thundering Herd: 100k users joining at once.
- Pre-warm the Load Balancers/CDN.
Red Flags - STOP and Follow Process
If you catch yourself thinking:
- "I'll just serve the MP4 file directly." (Buffering nightmare).
- "We don't need DRM, nobody will steal this." (Copyright strike risk).
- "I'll run FFmpeg on the web server." (CPU explosion).
- "Latency of 30 seconds is fine." (Not for interactive apps).
- "I'll test it on my office Gigabit wifi." (Unrealistic).
ALL of these mean: STOP. Return to Phase 1.
Quick Reference
| Phase |
Key Activities |
Success Criteria |
| 1. Protocol |
HLS/WebRTC, CDN |
Architecture defined, costs estimated |
| 2. Encode |
FFmpeg, DRM, ABR |
Multi-bitrate streams working |
| 3. Playback |
ExoPlayer/AVPlayer, Buffer |
Fast startup, smooth seek |
| 4. Ops |
QoE Metrics, Scaling |
<1% Rebuffer rate |
🛠️ Modern Media Stack (2026)
Video Encoding
- FFmpeg 7: Universal encoder (H.264, H.265, AV1)
- Cloud: AWS MediaConvert, Mux, Cloudinary
- Hardware: NVENC (NVIDIA), QuickSync (Intel)
- Codec Choice: H.264 (compatibility), AV1 (efficiency, +30% savings)
Streaming Protocols
- LL-HLS: Low-latency HLS (Apple), 2-5s latency
- DASH: Dynamic Adaptive Streaming (MPEG)
- WebRTC: Sub-second latency, peer-to-peer
- RTMP: Legacy push to server (OBS, streaming software)
CDN & Storage
- CDN: Cloudflare Stream, AWS CloudFront, Fastly
- Origin: S3, GCS, Azure Blob
- Edge Caching: Aggressive (immutable segments)
Player SDKs
- Web: Video.js, HLS.js, Shaka Player
- iOS: AVPlayer (native), VLCKit
- Android: ExoPlayer (Google), VLCPlayer
🤖 AI-Powered Media Processing (2026)
AI Enhancement Tools
- Background Removal: Remove.bg API, Rembg (local)
- Upscaling: Topaz Video AI, Real-ESRGAN
- Auto-Captioning: OpenAI Whisper, AssemblyAI
- Content Moderation: OpenAI Moderation API, AWS Rekognition
- Scene Detection: PySceneDetect, FFmpeg scene filter
Use Cases
- Auto-generate subtitles: Whisper API (99% accuracy)
- Thumbnail selection: ML picks best frame
- Content safety: Auto-flag NSFW content
- Quality enhancement: AI upscale 480p → 1080p
🌐 WebCodecs API (Browser-Native)
When to Use
- Browser video editors: No FFmpeg download
- Real-time effects: Filters, overlays
- Custom encoding: Precise control
Example
const encoder = new VideoEncoder({
output: (chunk) => { /* save encoded data */ },
error: (e) => console.error(e)
});
encoder.configure({
codec: 'vp9',
width: 1920,
height: 1080,
bitrate: 2_000_000
});
// Encode frames
encoder.encode(videoFrame);
Benefits
- No server: Encode in browser (privacy, cost)
- Low latency: 10x faster than WASM FFmpeg
- Support: Chrome 94+, Edge 94+, Safari 17+
📊 Quality of Experience (QoE) Metrics
Critical Metrics
| Metric |
Target |
Why |
| Startup Time |
<2s |
User drops off after 3s |
| Rebuffer Rate |
<1% |
Each rebuffer = 5% abandonment |
| Bitrate Switches |
<3/min |
Too many = poor ABR logic |
| Error Rate |
<0.1% |
Playback failures |
Monitoring
- Mux Data: Video analytics platform
- Datadog RUM: Real user monitoring
- Custom: Send events to Amplitude/Mixpanel
Alerts
- Rebuffer spike: >2% in last hour
- Startup time: p95 >3s
- CDN errors: >1% failure rate
1---2name: media-engineer3description: Media Engineer Skill4---5## The Four Phases67You MUST complete each phase before proceeding to the next.89### Phase 1: Pipeline & Protocol Strategy1011**BEFORE processing a single frame:**12131. **Protocol Selection**14 - Live Streaming? WebRTC (Sub-second latency) or LL-HLS (2-5s latency).15 - VOD (On Demand)? HLS (Apple) and DASH (Everyone else).16 - **Rule:** Do not invent your own protocol. Use standards.17182. **Adaptive Bitrate (ABR) Planning**19 - Define the "Ladder": 1080p, 720p, 480p, 360p.20 - **Cost/Quality Balance:** High bitrates = High CDN costs. Optimize CRF (Constant Rate Factor).21 - **Constraint:** What is the minimum bandwidth of your target user?22233. **Storage & CDN Architecture**24 - Origin Store (S3/GCS) vs Edge Delivery (Cloudfront/Fastly).25 - **Caching:** Video segments are immutable. Cache them aggressively.26 - **Egress Costs:** Calculate this NOW. Video bandwidth is the #1 startup killer.2728### Phase 2: Encoding & Packaging2930**The heavy lifting:**31321. **Transcoding Pipeline**33 - Use FFmpeg or cloud services (AWS MediaConvert/Mux).34 - **Container Formats:** fMP4 or TS?35 - **Audio:** AAC is standard, but check opus for low latency.36372. **DRM & Content Security**38 - **Encryption:** ClearKey? Widevine (Android/Chrome)? FairPlay (Apple)? PlayReady (Windows)?39 - **Token Authentication:** Secure the CDN URLs so users can't hotlink your streams.40413. **Player Integration (The Client)**42 - Don't build a player from scratch. Use ExoPlayer (Android), AVPlayer (iOS), or Video.js (Web).43 - **Hook up the Analytics:** You need to know when buffering happens.4445### Phase 3: Playback Quality (QoE)4647**Ensuring it plays smooth:**48491. **Buffer Strategy**50 - How much to buffer before starting? (Fast start vs Stability).51 - **Re-buffering Ratio:** Keep this under 1%.52 - **Startup Time:** Goal is < 2 seconds.53542. **Seek & Scrub Performance**55 - Enable "Byte-Range Requests" for fast seeking.56 - Generate "Trick Play" tracks (thumbnails for scrubbing).57583. **Cross-Device Testing**59 - Test on Low-End Androids (Hardware decoding limits).60 - Test on Cellular Networks (Packet loss).6162### Phase 4: Monitoring & Scale6364**Keeping the stream alive:**65661. **QoE Metrics (Quality of Experience)**67 - Monitor: Bitrate switches (Are users downgrading?), Error rates, Startup time.68 - **Alerts:** "Rebuffering spike in region US-East."69702. **Live Event Handling**71 - **Thundering Herd:** 100k users joining at once.72 - Pre-warm the Load Balancers/CDN.7374## Red Flags - STOP and Follow Process7576If you catch yourself thinking:77- "I'll just serve the MP4 file directly." (Buffering nightmare).78- "We don't need DRM, nobody will steal this." (Copyright strike risk).79- "I'll run FFmpeg on the web server." (CPU explosion).80- "Latency of 30 seconds is fine." (Not for interactive apps).81- "I'll test it on my office Gigabit wifi." (Unrealistic).8283**ALL of these mean: STOP. Return to Phase 1.**8485## Quick Reference8687| Phase | Key Activities | Success Criteria |88|-------|---------------|------------------|89| **1. Protocol** | HLS/WebRTC, CDN | Architecture defined, costs estimated |90| **2. Encode** | FFmpeg, DRM, ABR | Multi-bitrate streams working |91| **3. Playback** | ExoPlayer/AVPlayer, Buffer | Fast startup, smooth seek |92| **4. Ops** | QoE Metrics, Scaling | <1% Rebuffer rate |9394## 🛠️ Modern Media Stack (2026)9596### Video Encoding97- **FFmpeg 7:** Universal encoder (H.264, H.265, AV1)98- **Cloud:** AWS MediaConvert, Mux, Cloudinary99- **Hardware:** NVENC (NVIDIA), QuickSync (Intel)100- **Codec Choice:** H.264 (compatibility), AV1 (efficiency, +30% savings)101102### Streaming Protocols103- **LL-HLS:** Low-latency HLS (Apple), 2-5s latency104- **DASH:** Dynamic Adaptive Streaming (MPEG)105- **WebRTC:** Sub-second latency, peer-to-peer106- **RTMP:** Legacy push to server (OBS, streaming software)107108### CDN & Storage109- **CDN:** Cloudflare Stream, AWS CloudFront, Fastly110- **Origin:** S3, GCS, Azure Blob111- **Edge Caching:** Aggressive (immutable segments)112113### Player SDKs114- **Web:** Video.js, HLS.js, Shaka Player115- **iOS:** AVPlayer (native), VLCKit116- **Android:** ExoPlayer (Google), VLCPlayer117118## 🤖 AI-Powered Media Processing (2026)119120### AI Enhancement Tools121- **Background Removal:** Remove.bg API, Rembg (local)122- **Upscaling:** Topaz Video AI, Real-ESRGAN123- **Auto-Captioning:** OpenAI Whisper, AssemblyAI124- **Content Moderation:** OpenAI Moderation API, AWS Rekognition125- **Scene Detection:** PySceneDetect, FFmpeg scene filter126127### Use Cases128- **Auto-generate subtitles:** Whisper API (99% accuracy)129- **Thumbnail selection:** ML picks best frame130- **Content safety:** Auto-flag NSFW content131- **Quality enhancement:** AI upscale 480p → 1080p132133## 🌐 WebCodecs API (Browser-Native)134135### When to Use136- **Browser video editors:** No FFmpeg download137- **Real-time effects:** Filters, overlays138- **Custom encoding:** Precise control139140### Example141```javascript142const encoder = new VideoEncoder({143 output: (chunk) => { /* save encoded data */ },144 error: (e) => console.error(e)145});146147encoder.configure({148 codec: 'vp9',149 width: 1920,150 height: 1080,151 bitrate: 2_000_000152});153154// Encode frames155encoder.encode(videoFrame);156```157158### Benefits159- **No server:** Encode in browser (privacy, cost)160- **Low latency:** 10x faster than WASM FFmpeg161- **Support:** Chrome 94+, Edge 94+, Safari 17+162163## 📊 Quality of Experience (QoE) Metrics164165### Critical Metrics166| Metric | Target | Why |167|--------|--------|-----|168| **Startup Time** | <2s | User drops off after 3s |169| **Rebuffer Rate** | <1% | Each rebuffer = 5% abandonment |170| **Bitrate Switches** | <3/min | Too many = poor ABR logic |171| **Error Rate** | <0.1% | Playback failures |172173### Monitoring174- **Mux Data:** Video analytics platform175- **Datadog RUM:** Real user monitoring176- **Custom:** Send events to Amplitude/Mixpanel177178### Alerts179- **Rebuffer spike:** >2% in last hour180- **Startup time:** p95 >3s181- **CDN errors:** >1% failure rate