{"id":19217586,"url":"https://github.com/qq15725/modern-mp4","last_synced_at":"2025-05-13T00:11:47.270Z","repository":{"id":200362359,"uuid":"705458656","full_name":"qq15725/modern-mp4","owner":"qq15725","description":"🚀 JavaScript MP4 Codec.","archived":false,"fork":false,"pushed_at":"2025-01-21T03:25:53.000Z","size":721,"stargazers_count":58,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-13T00:11:41.261Z","etag":null,"topics":["decoder","encoder","mp4","mp4box","webcodec"],"latest_commit_sha":null,"homepage":"https://modern-mp4.vercel.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qq15725.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-16T03:35:32.000Z","updated_at":"2025-04-05T12:49:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"60258f2c-cfae-42c6-8b14-7dd84a26c00a","html_url":"https://github.com/qq15725/modern-mp4","commit_stats":null,"previous_names":["qq15725/modern-mp4"],"tags_count":5,"template":false,"template_full_name":"qq15725/starter-ts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qq15725%2Fmodern-mp4","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qq15725%2Fmodern-mp4/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qq15725%2Fmodern-mp4/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qq15725%2Fmodern-mp4/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qq15725","download_url":"https://codeload.github.com/qq15725/modern-mp4/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253843219,"owners_count":21972874,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["decoder","encoder","mp4","mp4box","webcodec"],"created_at":"2024-11-09T14:22:54.741Z","updated_at":"2025-05-13T00:11:47.211Z","avatar_url":"https://github.com/qq15725.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003emodern-mp4\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://unpkg.com/modern-mp4\"\u003e\n    \u003cimg src=\"https://img.shields.io/bundlephobia/minzip/modern-mp4\" alt=\"Minzip\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/modern-mp4\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/modern-mp4.svg\" alt=\"Version\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/modern-mp4\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/dm/modern-mp4\" alt=\"Downloads\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/qq15725/modern-mp4/issues\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/issues/qq15725/modern-mp4\" alt=\"Issues\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/qq15725/modern-mp4/blob/main/LICENSE\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/l/modern-mp4.svg\" alt=\"License\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n## Install\n\n```shell\nnpm i modern-mp4\n\n# peerDependencies\nnpm i mp4box\n```\n\n## Usage\n\n### Encode\n\n```ts\nimport { encode } from 'modern-mp4'\n\nconst blob = await encode({\n  width: 1280,\n  height: 720,\n  audio: false,\n  frames: [\n    // data: string | CanvasImageSource | VideoFrame | AudioData\n    { data: '/example1.png', duration: 3000 },\n    { data: '/example2.png', duration: 3000 },\n  ],\n})\n\nwindow.open(URL.createObjectURL(blob))\n```\n\n### Encoder\n\n```ts\nimport { MP4Encoder } from 'modern-mp4'\n\nconst encoder = new MP4Encoder({\n  width: 1280,\n  height: 720,\n  audio: false,\n  framerate: 30,\n})\n\nawait encoder.encode({\n  data: '/example1.png',\n  timestamp: 0,\n  duration: 33,\n})\n\nawait encoder.encode({\n  data: '/example1.png',\n  timestamp: 33,\n  duration: 66,\n})\n\nconst blob = await encoder.flush()\n\nwindow.open(URL.createObjectURL(blob))\n```\n\n### Decode\n\n```ts\nimport { decode } from 'modern-mp4'\n\nconst infoWithFrames = await decode({\n  // string | Blob | BufferSource | Array\u003cBufferSource\u003e | readableStream\u003cBufferSource\u003e\n  data: './example.mp4',\n  audio: false,\n  // framerate: 10,\n  // onInfo: info =\u003e console.log(info),\n  // onFrame: frame =\u003e { console.log(frame) },\n  // onProgress: (current, total) =\u003e console.log(`decode frame ${current}/${total}`),\n})\n\nconsole.log(infoWithFrames)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqq15725%2Fmodern-mp4","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqq15725%2Fmodern-mp4","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqq15725%2Fmodern-mp4/lists"}