# Video Encoding Standards
## Rule
All FFmpeg video encoding commands MUST specify codec, quality method (CRF/bitrate), pixel format, and include `-movflags +faststart` for web-targeted output.
## Required Parameters for Web Video
```bash
ffmpeg -i input.mp4 \
-c:v libx264 \ # REQUIRED: explicit codec
-crf 23 \ # REQUIRED: quality level
-preset medium \ # REQUIRED: speed/compression tradeoff
-profile:v high \ # REQUIRED: compatibility profile
-level 4.1 \ # REQUIRED: device compatibility level
-pix_fmt yuv420p \ # REQUIRED: browser-compatible pixel format
-c:a aac -b:a 128k \ # REQUIRED: audio codec and bitrate
-movflags +faststart \ # REQUIRED: progressive download
output.mp4
```
## CRF Ranges
| Codec | Excellent | Good | Acceptable | Max |
|-------|-----------|------|------------|-----|
| libx264 | 18 | 23 | 28 | 51 |
| libx265 | 20 | 28 | 32 | 51 |
| libsvtav1 | 20 | 30 | 38 | 63 |
## Good Example
```bash
ffmpeg -i raw.mov \
-c:v libx264 -crf 22 -preset medium \
-profile:v high -level 4.1 \
-pix_fmt yuv420p \
-c:a aac -b:a 128k \
-movflags +faststart \
web_ready.mp4
```
## Bad Example
```bash
# Missing codec, CRF, pixel format, faststart
ffmpeg -i raw.mov output.mp4
# FFmpeg uses defaults which may not be web-compatible
```
## Anti-Patterns
- Encoding without explicit codec (unpredictable output)
- Missing `-pix_fmt yuv420p` (Safari won't play yuv444p)
- Missing `-movflags +faststart` for web delivery
- CRF > 28 for H.264 (visible quality loss)
- Using `-preset veryslow` for non-archival content (wastes hours)
- Re-encoding with stream copy available (`-c copy`)