Skip to content

Wasm mp4 export#191

Open
lucasdinonolte wants to merge 10 commits into
mainfrom
wasm-mp4-export
Open

Wasm mp4 export#191
lucasdinonolte wants to merge 10 commits into
mainfrom
wasm-mp4-export

Conversation

@lucasdinonolte

@lucasdinonolte lucasdinonolte commented May 22, 2025

Copy link
Copy Markdown
Contributor

Follow up PR of #178, but using a WASM version of h264 over Web Codecs to handle the mp4 export.

What this does

  • Adds h264Writer class to mechanic core, following the interface of WebmWriter
    • this uses a WASM build of minih264 and libmp4v2 to handle h264 encoding and mp4 multiplexing
  • Adds ZipWriter class to mechanic core, following the interface of WebmWriter
    • this uses jszip to export raw frames of an animation and download them as a zip file
    • this is aimed at power users who have very specific video needs that can't be done in the browser (like ProRes)
  • Allows animated design function to specify their videoFormat to set the desired export
    • allowed values mp4, webm, and frames (defaults to mp4, as this probably the most wanted format)

What could be done

  • Add video export presets
    • right now it just exposes the options that can be passed to the encoder as part of a design functions settings
    • ... but this could be extended to provide presets like "High Quality MP4", "Small File Size Mp4", etc.
  • Discuss if we want the export format as an option on the design function or if we should let the end user choose the export format
    • if we decide on the latter there's probably a worthwhile exercise to see how this could fit in with the showMultipleExports option

Caveats

  • This seems to increase the build time of a mechanic project, as the WASM for h264 encoding is included inline in the final build
    • It's lazily loaded, so bundle size is not affected by this
    • But it still needs to flow through webpack, making the build slower
  • I'm still not 100% sure this is legal – as h264 is not an open codec, so I'm not sure the WASM implementations used by this are legally implementing h264. I think we should get legal advice from a more qualified person before proceeding with this.

Alternatives

Rely on browser standards as outlined in #178 (but with limited browser support for now)

@netlify

netlify Bot commented May 22, 2025

Copy link
Copy Markdown

Deploy Preview for dsi-logo-maker failed. Why did it fail? →

Name Link
🔨 Latest commit 1ea1139
🔍 Latest deploy log https://app.netlify.com/projects/dsi-logo-maker/deploys/682f03a50fc2240008db106d

@lucasdinonolte
lucasdinonolte changed the base branch from main to new-animation-api May 22, 2025 11:00
Base automatically changed from new-animation-api to main November 17, 2025 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant