From d2a453e381cb7ba3c3b8af51af6e458b9d182869 Mon Sep 17 00:00:00 2001 From: talksik Date: Wed, 29 Apr 2026 16:07:40 -0700 Subject: [PATCH] cap video resolution to save on memory --- go/cmd/particleprocessorworker/main.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/go/cmd/particleprocessorworker/main.go b/go/cmd/particleprocessorworker/main.go index 3747022..fe58a22 100644 --- a/go/cmd/particleprocessorworker/main.go +++ b/go/cmd/particleprocessorworker/main.go @@ -240,10 +240,18 @@ func transcodeMediaParticle(ctx context.Context, depotSvc depot.Service, doc *fi tmpPath, } } else { + // Cap encoder parallelism and lookahead to keep memory bounded — screen + // recordings come in at native display resolution (often 1440p–4K) and + // libx264's per-thread lookahead/reference buffers blow past the worker's + // memory limit otherwise. Output is also downscaled to 1080p max, which + // mobile playback won't notice; the original WebM stays in GCS untouched. args = []string{ "-y", "-i", sourceURL, + "-vf", "scale='min(1920,iw)':-2:flags=lanczos", "-c:v", "libx264", "-preset", "veryfast", "-crf", "23", "-pix_fmt", "yuv420p", "-profile:v", "baseline", "-level", "3.1", + "-x264-params", "rc-lookahead=20:ref=2", + "-threads", "2", "-filter_threads", "2", "-c:a", "aac", "-b:a", "128k", "-movflags", "+faststart", tmpPath,