The last post was about making one export faster. This one is about the next thing that got in the way: exporting many.
When I finish a series, like the nine paper-theatre films, exporting used to mean opening a project, pressing Export, waiting, opening the next project and doing it all again. Nine times.
Now you pick them all once, and Mografy exports them one after another.
While building it I also measured where the memory goes during an export. That turned into the second half of this update, and into an honest answer about speed.
From the terminal: list the films, or use --all
Put several project names after npx mografy export, or use --all to export every project in your projects folder:
npx mografy export intro story montage
npx mografy export --all --preset share- Films export one after another, all with the same options, such as
--preset,--formatand--resolution. --allskips folders that start with_, such as_to_delete.- If one film fails, Mografy reports it and moves on to the next one, so one broken project can’t stop the whole batch.
- Press Ctrl+C to cancel the current film and stop the batch. You still get a list of what finished and what didn’t.
- The whole batch shares one Chromium instead of opening a new one for every film.
In the player: the batch export dialog
In the player, click Batch in the top bar, next to Export, or choose Export several projects… in the Export dialog. On the left, tick films from every project on your computer. On the right, pick a format card (MP4, WebM, MOV, Lottie or SVGA), then the Encoder, Resolution and Frame rate. Each can stay at each project’s own setting. You’ll get shows exactly which files will come out before you start.
- Encoder: each project’s own, Share (H.264), High (H.265 10-bit) or Fast (hardware H.265, MP4 only).
- Resolution: each project’s own, 720p or 1080p by the shorter side. 16:9 and 9:16 films each keep their own shape, so one batch can mix landscape and portrait.
- Two switches: Use less memory and Include music.
- While it exports, the dialog shows the frame being captured, with a scan line and a strip of captured frames, plus progress and time left. The queue sits beside it.
- Close the dialog and a small card in the bottom-left corner keeps the progress, ending with how many films are done. Switching projects doesn’t stop it, and you can cancel one film or all of them.
- Finished films go into each project’s own
renders/folder, as before.
Why one at a time, and why it isn’t faster
My first idea was to export several films at the same time. Then I measured it.
Mografy already splits each film into segments that record in parallel. During an export, the CPU is already full: Chromium drawing frames takes about 55% and the encoder about 40%. On a 4-core test machine, going from 2 segments to 4 used 3 GB more memory and wasn’t any faster.
A full CPU can’t go faster by doing more at once. It only uses more memory.
So the batch runs one film at a time. To be honest, each film exports at about the same speed as before. What you gain is not having to sit there pressing Export, and a batch that finishes instead of running out of memory halfway.
Where the memory goes
I measured each process during a 1080p export. Each recording segment needs about 1.4 GB: about 700 MB for its Chromium page and 730 MB for its H.265 encoder. On top of that, the shared browser and Node.js take about 0.9 GB. I also checked long films for leaks and found none.
The problem was how many segments Mografy opened. It decided by core count alone, so a Mac usually got 4 segments: more than 6 GB just for the export, before the player and your other apps. On an 8 GB Mac, that is full.
This update changes three things:
- Automatic segments now look at memory too. An export plans for at most 40% of your computer’s memory: an 8 GB Mac opens 1 segment, a 16 GB Mac opens 4.
- Each segment’s H.265 encoder only uses its own share of the cores, instead of every encoder assuming the whole computer is its own.
- The encoder looks 10 frames ahead instead of 20. That saves about 150 MB per segment, the picture matches the previous output (SSIM 0.9999), and files came out about 9% smaller.
Less memory mode, for big batches
If memory is tight, turn on the Use less memory switch in the batch export dialog, or add --workers 1 in the terminal. Each film then records as one segment. Measured on the same film:
- Automatic: 59 s, with memory peaking at 4.0 GB.
- Less memory: 71 s, with memory peaking at 2.4 GB.
About 20% slower, with 40% less memory. If you are exporting a long list overnight, or you’re on an 8 GB laptop, turn it on.
These numbers come from an 8-second Mografy intro at 1080p60 on a 4-core cloud test machine, not on a Mac. The exact numbers on your computer will differ, but the proportions should hold.
Windows: fewer ways for a batch to go wrong
A batch runs for a long time, so small Windows problems add up. This update fixes four of them:
- Ctrl+C in a terminal batch now reports the film as cancelled and stops the batch, instead of marking it failed and moving on.
- Removing the temporary folder retries and tolerates files Windows still has locked.
- The hardware encoder check gives up after 20 seconds and falls back to software encoding, instead of hanging.
- FFmpeg runs without opening a console window for every film.
As with the last update, none of this has been tested on a real Windows PC yet.
If you export on Windows, please try a small batch and tell us on Discord how it went.
What stays the same
Every frame is still drawn exactly as before. Only the encoder setting changed, so a film exported now isn’t bit-for-bit identical to the same film exported last week, but the difference is far below what you can see. Settings saved in a project’s mografy.json, such as "workers": 2, are kept.
How to update
Run this in your Mografy folder. It updates, rebuilds and restarts the player. Then try a batch with less memory from the terminal:
npx mografy update
npx mografy export --all --workers 1Every option is explained on the Export page of the docs.
Finish the films. Let the exporting happen while you do something else.
Make motion with us
Join the Mografy Discord to share what you make, ask questions and help shape what we build next.