This post was created with AI assistance and reviewed for accuracy before publishing.
For the last few weeks I have been building Manuhar, a maker for wedding and birthday video invites in Hindi, Gujarati and English. A family types names, dates and a venue, picks a design, and gets a vertical MP4 to send on WhatsApp.
On paper that is a form and a video template. In practice almost every hard problem came from three places: Indic text inside a video frame, a render that has to finish on an ordinary phone, and wording that has to read naturally in three languages. These are the notes I wish I had at the start.
One composition for the preview and the video
The designs are Remotion compositions at 1080x1920. Remotion lets you write a video as React components, which suits this work: a design is a layout with timing, and the text in it comes from props.
The same composition is used twice. While someone edits, a Remotion <Player> shows it live in the page. When they are done, renderMediaOnWeb from @remotion/web-renderer draws it frame by frame and encodes an MP4 with WebCodecs, in the browser. Nothing goes to a server, and the family's photos never leave the phone.
Using one composition for both is the point. If the preview and the final video came from different code, they would drift, and the person would approve one thing and receive another. Sharing the code is not enough to prove they match, though, so there is a test for it. A script pauses the Player at a frame, screenshots it, renders that same frame range to MP4, pulls the frame out and compares the two images with PSNR. It runs across three designs and fails below 30 dB.
One detail from writing it: rendering a single frame fails, because the encoder needs more than one frame to flush. The check renders a short range and takes the first frame of it.
The web renderer is not Chrome
The first surprise was that the web renderer does not paint a page the way the browser does. It walks the DOM and draws it into a canvas itself, and it covers most of CSS, not all of it.
When I compared its output with stills from Remotion's command-line renderer, the scores were 21.9, 20.4 and 25.1 dB on three designs. That is a visible difference, not noise. Two causes accounted for it:
- Box-shadow spread is not drawn. Designs that used a spread shadow as a thin outline lost the outline.
- A border on an
overflow: hiddenbox is clipped.
The fix was to stop leaning on those features: real borders where there had been shadows, and a negative margin equal to the border width where a border had to sit outside its box. After that the preview test above became the guard, so a new design that uses an unsupported feature fails before anyone sees it.
The general lesson: if a library re-implements rendering, treat its output as a different browser and test against it, not against what Chrome shows you.
Content Security Policy, for one page only
The site has a strict CSP. The render page needed three exceptions, and finding the first one took a while because it did not fail loudly. With inline styles blocked, the first frame rendered correctly and every frame after it came out wrong. The renderer sets inline styles while it draws SVG, so style-src needs 'unsafe-inline' on that page.
The other two were worker-src blob:, for a small timer the renderer runs in a worker, and a connect-src entry for Remotion's usage telemetry, which cannot be switched off. All three apply to the render page only. Every other page keeps the strict policy.
Fonts by script
Indic text in video has two separate problems: getting the right glyphs, and getting them early enough.
The first version loaded every font face on every card, about 1 MB, Gujarati and Sanskrit faces included on an English card. Now the faces are grouped (a small core set, a Sanskrit face, Devanagari, Gujarati and a few display families) and a card asks for the groups its text needs. The test is a Unicode range per script:
const DEVA = /[\u0900-\u097F\u1CD0-\u1CFF\uA8E0-\uA8FF]/; const GUJ = /[\u0A80-\u0AFF]/; Every card loads the core set. The Gujarati faces load only when a Gujarati letter appears anywhere on the card, and the extra Devanagari faces only when Hindi text outside the core-drawn lines needs them. Loading a face too many costs a few kilobytes, while loading one too few changes how the card looks, so the rules lean towards loading.
Getting them early enough matters more in video than on a web page. A page that shows a fallback font for 200 ms looks a little odd. A video renders a fallback font into the first frames and keeps it forever. The renderer waits for the fonts to finish loading before it draws frame one.
For the site's own wordmark the faces are subset. Yatra One went from 70 KB to a few KB for the six letters it shows. Subsetting Indic fonts has a trap: the conjuncts are built by OpenType layout features, and a subset that drops them renders broken words. The build keeps every feature:
python -m fontTools.subset Face.ttf --text="..." \ --layout-features='*' --flavor=woff2 It also checks the sha256 of each source face, so if a font file is swapped the build stops instead of quietly cutting a subset from the wrong file.
Line height was the last font problem. Devanagari and Gujarati stack marks above and below the letter, so a line height set by eye on Latin text clips them. The spacing is measured from the ink of the tallest clusters in each script, words like श्री and ક્ષ્મી, not from the font's nominal size.
Phones are slower than you think
Rendering video in the browser is affordable for a laptop and expensive for a phone. On my laptop the cost per frame was 560, 541 and 551 ms at 480p, 720p and 1080p. The resolution barely mattered. Walking the page and drawing it into a canvas is the cost, not the pixels.
That changed how I thought about quality. Dropping to a smaller size saves little time, so the size should be chosen per device rather than set low for everyone. For a slow device, the useful lever is the length of the wait, not the resolution.
Before a render, the site runs a short test render of the person's own video, measures frames per second, then aborts it. From that it estimates the full render time at each size and picks the biggest allowed size that finishes within five minutes. A reading that says "slow" is trusted only if the page was not throttled before and after it and a second timing agrees, because a phone that is busy for a moment should not be told it is slow.
The aborted test render taught me something about WebCodecs. Cancelling mid-render left a VideoFrame open, and the console reported that a VideoFrame was garbage collected without being closed. Frames hold decoder memory, and the browser only warns you. The frame callback now tracks the frame it holds and closes it on abort.
Some phones get no live preview at all. A device with deviceMemory or hardwareConcurrency of 2 or less sees a still card instead of the Player. An unknown value counts as capable, because Safari does not expose deviceMemory, and treating every iPhone as weak would be wrong.
There is also a server render path, built and tested, that stays switched off. A study for it timed a 720p wedding invite at 262 seconds in a laptop browser and 84 to 133 minutes under a 6x CPU throttle, a rough stand-in for a slow phone. A container on a server did 1080p in roughly 19 to 35 seconds, with the Devanagari shaped correctly. The path is built and passed its test runs, but it is hidden, and every video, HD included, is made on the person's own phone. That is also what lets the photos stay there.
Photos stay on the device
A photo is decoded with createImageBitmap and imageOrientation: "from-image", downscaled on a canvas to 1600 px on the long side and saved as a JPEG at quality 0.9. Redrawing through a canvas also drops the EXIF data, including any GPS location. The result lives as a blob URL in the tab's memory. Nothing is uploaded, so there is nothing to delete later.
Localisation is more than translation
The card language and the site language are separate settings. A Gujarati family may want an English site and a Gujarati invite. The page ships in English, and the Hindi and Gujarati interface strings load only when someone picks one.
Dates are built without Intl. Different phones carry different ICU data, and the same Intl.DateTimeFormat call can print a different line on two phones. On a wedding card that is not acceptable. The code has its own month names, its own words for morning and evening (सुबह and शाम, સવારે and સાંજે), and native digits unless the family chooses Latin ones.
Some numbers must be words. Gujarati ordinals are formed with મો, so a fifth birthday would be ૫મો. But the Gujarati digit ૫ looks very like the letter પ, and ૫મો reads as પમો, which is not a word. Ordinals one to ten are written as words. Digits start at eleven.
Grammar can save you a question. A Hindi birthday line reads का 5वाँ जन्मदिवस. The ordinal agrees with जन्मदिवस, a masculine noun, not with the child, so the line never needs to ask whether the child is a boy or a girl.
A careful language review finds what tests do not. A strict read of the Gujarati copy found a Devanagari vowel sign, ी, inside Gujarati text, where it looked almost right. The same pass rewrote phrasing that was correct but not how anyone would say it. Separately, a test now checks that no Gujarati letters appear in Hindi price text, and the reverse.
Testing all of it
The test suite has over a thousand checks. Some are ordinary unit tests. The ones that earned their keep compare pixels: the preview against the render, and a font check that holds the frames to 45 dB after a font change (after one swap, 31 of 35 frames came out byte-identical). When the output is a video, the most reliable test is to render it and look at the frames, with numbers rather than eyes.
The short version
- Use one composition for the preview and the final render, and prove they match with a frame comparison.
- Treat a re-implemented renderer as a separate browser. Test against its output.
- Load fonts by script, wait for them before the first frame, and keep layout features when subsetting Indic faces.
- On phones, the cost is drawing, not pixels. Measure the device and choose the size per device.
- Close every
VideoFrame, especially on abort. - Do not trust
Intlfor text that must read the same on every phone. - Have every language's copy reviewed on its own, not just tested.
If you want to see where all this ended up, Manuhar is live at manuhar.app. Pick a language and a design and watch the preview change as you type.
Manuhar is still being built, and it will keep changing. What is live today is yours to try at manuhar.app.
