However good a Mografy film looks, in the end it has to become a video file.
For a while, export was the slowest and least predictable step of the whole workflow. A 1080p60 film over a minute long could run out of memory halfway through, and even when it finished, you waited a long time.
So this time I rebuilt video export in the open-source edition from end to end.
This post has two halves. First, where the problems were and how I fixed them. Then what the update brings: export presets, hardware encoding, cleaner pictures, and Windows support that still needs your help to verify.
How Mografy exports a video
Every Mografy scene is a function of time. To export, Mografy opens an invisible Chromium in the background, draws the film one frame at a time and hands the frames to FFmpeg to encode.
To make motion look smooth, each frame is actually drawn several times (four by default) at slightly different moments, then mixed into one. That is motion blur. So a 10-second film at 60 fps means 2,400 drawings behind the scenes.
Anything slightly slow, multiplied by thousands, becomes a wait you can feel.
Problem one: slower and slower, until memory ran out
I first noticed it while exporting a longer 1080p60 film. Memory kept climbing, and long films could crash outright.
The cause was hiding somewhere tiny. After each frame is drawn, it travels from the browser back to Node.js. Back then the raw pixels were sent as the request body, and Playwright, which drives the browser, kept a copy of every such request until the export ended.
Every frame exported added one more frame’s worth of memory.
The fix was one line: wrap the data in a Blob before sending it, so Playwright no longer keeps a copy.
- Moving one 1080p frame out of the browser: about 0.67 s → 0.04 s.
- Memory: steady at about 250 MB after 400 frames, instead of climbing.
- The code that mixes motion blur samples was rewritten too, with byte-identical output.
With both fixes, a test film went from about 1.4 s to 0.37 s per frame. Then I moved sample mixing into two Web Workers inside the page, so the next frame draws while the current one is still being mixed. With glow and grain turned on, that took another test from about 0.7 s to 0.34 s per frame.
This part has been on GitHub since late October.
Problem two: every film went through a lossless master first
With memory fixed, I laid the whole export pipeline out and found the biggest waste was the pipeline itself.
The old pipeline first wrote every frame into a lossless FFV1 master, encoded that master twice (two-pass), and only then produced the MP4. The master is huge, writing and reading it takes time, and most people only ever wanted one good-looking MP4.
The new pipeline works like this:
- Constant quality (CRF) is the default, and frames are encoded while they are drawn. No master is written.
- A frame where nothing moves is drawn once, not four times for motion blur.
- Only the parts of a frame that changed leave the browser.
- The number of parallel segments now adapts to your computer.
Two-pass encoding is still there, now under advanced settings, for anyone who needs a specific bitrate.
Measured: how much faster?
I wrote a benchmark script, scripts/bench-export.ts, that times each export and compares its quality with a lossless reference using VMAF. These are the results for the 12-second Mografy intro at 1080p60 on an Apple Silicon Mac with 10 cores:
- H.265: 26.2 s → 21.5 s.
- H.264: 21.9 s → 17.7 s.
- The new Fast high quality preset, with hardware encoding: 14.9 s.
- Quality stays the same: VMAF for H.265 went from 94.50 to 94.62.
If you always exported with the defaults, the change is bigger. A project that never set an encoding used to export with two-pass H.265, which took 40.0 s for this film. The new default takes 21.5 s.
To be honest, not every film gains this much. In glow-heavy scenes, the output effects and the H.265 encoder compete for the same CPU, so software H.265 barely changed (25.6 s → 26.2 s on our glow-heavy test). For films like that, use Fast high quality instead: 20.2 s on the same film.
Two-pass is now slower than before, because H.265 is now 10-bit. That is one more reason it moved to advanced settings.
Four presets: choose by where the video is going
Exporting a good video used to mean picking an encoder, a CRF and a speed yourself. Now there are four presets, chosen by what the file is for:
- Share (
share): MP4, H.264. Plays in every browser, on Windows PCs and in chat apps. Good for social uploads. - High quality (
high, the default): MP4, H.265 10-bit. The smallest file for the same quality, for Apple devices, Chrome and Edge. - Fast high quality (
fast): MP4, frames drawn by the graphics card and encoded as hardware H.265 10-bit. The fastest export. - Master (
master): MOV, ProRes 422 HQ, for editing in Final Cut, Premiere or DaVinci Resolve. The files are large.
Pick one in the Encoder field of the Export dialog, or from the terminal with npx mografy export my-film --preset fast.
Quality: hard to spot, but cleaner
- H.265 is now 10-bit (Main 10): smoother soft gradients and less banding at the same file size.
- Colour conversion uses exact rounding and full chroma, so thin coloured text has cleaner edges.
- Audio is now 48 kHz, the rate video platforms and editors expect.
There are also new advanced settings. They are all off or at their old values by default, so turn them on when you need them:
- Shutter angle: 360° by default; 180° gives shorter, more cinematic motion blur.
- Dither: removes banding in soft gradients and glows.
- Adaptive samples: frames that barely change mix only two samples. It now looks at how far the change spreads, so small, fast objects keep their full motion blur instead of turning into two ghosts.
sampleWindow: "centred"places each frame’s samples around its own moment, in step with the audio.
Windows: paths fixed, hardware encoding needs your help
Plenty of people use Mografy on Windows, so this update fixes several common export failures there:
- FFmpeg now only receives file names relative to its work folder, so a drive letter (
C:), spaces, apostrophes or backslashes in the project path no longer break exports. - If antivirus software briefly locks the finished file, Mografy retries instead of failing.
- Temporary files now live in the project’s
.mografy/tmp/instead of the system temp folder.
For hardware encoding, Mografy first runs a tiny trial encode to find which encoder works on your machine: VideoToolbox on macOS; NVIDIA NVENC, Intel Quick Sync and AMD AMF on Windows; NVENC, VA-API and Quick Sync on Linux. If none works, it falls back to software encoding and tells you which encoder it actually used. Windows can also draw frames on the graphics card (Direct3D 11), like macOS does with Metal.
One honest caveat: so far only VideoToolbox on macOS has been tested for real.
The Windows and Linux encoder settings and quality mapping are a first calibration, and I haven’t run them on a real Windows graphics card yet. If you’re on Windows, please try Fast high quality and tell us on Discord how it looks, how long it took and which encoder it used.
Your existing films stay the same
A lot changed underneath, but I held on to one rule: existing films must draw exactly the same frames as before.
That’s why every new setting that changes the picture, such as shutter angle, sample timing, dither and adaptive samples, keeps its old behaviour by default. Settings already saved in a project’s mografy.json, such as "encoding": "two-pass" or "workers": 2, are kept too. Only projects that never set them get the new defaults.
How to update
Run this in your Mografy folder. It updates, rebuilds and restarts the player. If you started npx mografy dev yourself, stop it and start it again. Then pick a preset in the Export dialog, or try the fast preset from the terminal:
npx mografy update
npx mografy export my-film --preset fastEvery setting is explained on the Export page of the docs.
Export shouldn’t be the part where you can only sit and wait.
Make motion with us
Join the Mografy Discord to share what you make, ask questions and help shape what we build next.