video-upscale-cpu — Video Upscaler (Pure CPU Universal Chain)
A battle-tested ffmpeg repair chain: deband → hqdn3d → lanczos scale to 2560×1440 → CAS 0.6 sharpening, x264 crf15, audio stream copy. Pure CPU, zero VRAM, speed about RTF 1~3 (161 seconds of footage runs in minutes). Universal for any video — motion graphics, animation, live action, screencasts, movie clips, all work.
Three Typical Artifacts Fixed
- Banding on dark backgrounds/gradients — deband treats it, common in animation and dark live action
- Blurry small text and edges from compression — lanczos+CAS treats it, benefits infographics, screencasts, subtitles
- Compression noise and general fuzziness — hqdn3d treats it
One-Click Script (wraps all gotchas)
python scripts/upscale2k.py <source video> [output path]
Dependencies: ffmpeg/ffprobe in PATH (download or winget install Gyan.FFmpeg); Pillow + numpy optional (only affects auto-validation comparison images).
The script automatically does: ffprobe source probe → target dimension calculation (if source height ≥1440, only repair, no upscale) → run chain → integrity check (moov readable / duration aligned / audio start_time=0) → output same-frame 1:1 comparison image (old version nearest neighbor resize to same size vs new version) + edge energy ratio report.
Manual Command (equivalent)
ffmpeg -y -i <source> -vf "deband,hqdn3d=1.5:1.5:6:6,scale=2560:1440:flags=lanczos,cas=0.6" -c:v libx264 -crf 15 -preset medium -c:a copy <output>
Per-Content-Type Tweaks (optional, works without)
| Content | Suggested Tweak |
|---|---|
| Motion graphics / infographics (dark bg, small text) | Default works; if text too sharp, lower cas=0.6 to 0.4 |
| 2D animation | Default works; if banding heavy, stack one more deband |
| Live action | Lower first two params of hqdn3d to 1 (preserve film grain); for pore-level texture reconstruction, optionally layer AI super-resolution |
| Screencast / tutorial | Default; if text blurry, focus on CAS |
🔴 Three Hard Gotchas (all hit in practice)
lanczosis not a standalone filter — must writescale=2560:1440:flags=lanczos; writinglanczos=2560:1440gives Invalid argument.- mp4 moov index written only at end of transcoding — opening output mid-run gives "Invalid data / cannot open"; it's not broken, wait for completion.
- Re-encoded copies cannot be used as source — WeChat/QQ etc. re-encodes and drops frames (measured 4842→4830 frames) + timestamp damage; pairing its video track with original audio causes audio/video desync (silent first few seconds). Desync check:
ffprobe -select_streams a:0 -show_entries stream=start_time+silencedetectto check audio start.
Validation Criteria
- Same-frame 1:1 pixel comparison: old version uses
flags=neighborresize to same size, edge energy ratio (new/old) in 1.05~1.15 is normal gain; significantly below 1.0 = chain working backward, check params. - Visually confirm small text edges and dark background banding in the comparison image; quantitative metrics are only supporting evidence.
- Audio: output
start_time=0+ volumedetect shows loudness in the first 3 seconds.