{"id":13801535,"url":"https://github.com/c4spar/deno-fast-forward","last_synced_at":"2025-04-30T12:34:49.329Z","repository":{"id":45642790,"uuid":"293928831","full_name":"c4spar/deno-fast-forward","owner":"c4spar","description":"An easy to use ffmpeg module for Deno. 🦕","archived":false,"fork":false,"pushed_at":"2021-12-03T00:45:25.000Z","size":364,"stargazers_count":47,"open_issues_count":2,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-03T12:19:46.950Z","etag":null,"topics":["deno","encoding","ffmpeg","ffprobe"],"latest_commit_sha":null,"homepage":"","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/c4spar.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-08T21:13:42.000Z","updated_at":"2024-02-05T23:51:42.000Z","dependencies_parsed_at":"2022-09-26T18:20:42.025Z","dependency_job_id":null,"html_url":"https://github.com/c4spar/deno-fast-forward","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c4spar%2Fdeno-fast-forward","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c4spar%2Fdeno-fast-forward/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c4spar%2Fdeno-fast-forward/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c4spar%2Fdeno-fast-forward/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/c4spar","download_url":"https://codeload.github.com/c4spar/deno-fast-forward/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242650900,"owners_count":20163610,"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":["deno","encoding","ffmpeg","ffprobe"],"created_at":"2024-08-04T00:01:23.995Z","updated_at":"2025-03-09T05:31:00.075Z","avatar_url":"https://github.com/c4spar.png","language":"TypeScript","funding_links":[],"categories":["Modules"],"sub_categories":["Video"],"readme":"\u003ch1 align=\"center\"\u003eFast Forward\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003eAn easy to use ffmpeg module for Deno.\u003c/p\u003e\n\n\u003cp align=\"center\" class=\"badges-container\"\u003e\n  \u003ca href=\"https://github.com/c4spar/deno-fast-forward/releases\"\u003e\n    \u003cimg alt=\"Version\" src=\"https://img.shields.io/github/v/release/c4spar/deno-fast-forward?logo=github\u0026color=blue\u0026label=latest\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/c4spar/deno-fast-forward/actions?query=workflow%3ATest\"\u003e\n    \u003cimg alt=\"Build status\" src=\"https://github.com/c4spar/deno-fast-forward/workflows/Test/badge.svg?branch=main\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/c4spar/deno-fast-forward\"\u003e\n    \u003cimg src=\"https://codecov.io/gh/c4spar/deno-fast-forward/branch/main/graph/badge.svg\"/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/c4spar/deno-fast-forward/issues\"\u003e\n    \u003cimg alt=\"issues\" src=\"https://img.shields.io/github/issues/c4spar/deno-fast-forward?label=issues\u0026logo=github\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://deno.land/\"\u003e\n    \u003cimg alt=\"Deno version\" src=\"https://img.shields.io/badge/deno-^1.6.2-blue?logo=deno\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://doc.deno.land/https/deno.land/x/fast_forward/mod.ts\"\u003e\n    \u003cimg alt=\"doc\" src=\"https://img.shields.io/badge/deno-doc-yellow?logo=deno\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"./LICENSE\"\u003e\n    \u003cimg alt=\"Licence\" src=\"https://img.shields.io/github/license/c4spar/deno-fast-forward?logo=github\" /\u003e\n  \u003c/a\u003e\n  \u003cbr\u003e\n  \u003ca href=\"https://deno.land/x/fast_forward\"\u003e\n    \u003cimg alt=\"deno.land\" src=\"https://img.shields.io/badge/Published on deno.land-blue?logo=deno\u0026logoColor=959DA6\u0026color=272727\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://nest.land/package/fast_forward\"\u003e\n    \u003cimg alt=\"nest.land\" src=\"https://nest.land/badge.svg\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003e ⚠️ Work In Progress! Expect breaking changes!\n\n## Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Getting Started](#getting-started)\n- [Examples](#Examples)\n  - [Events](#events)\n  - [Process Handling](#process-handling)\n  - [Event Stream](#event-stream)\n  - [Output Stream](#output-stream)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Installation\n\nThis is a Deno module and can be imported directly from the repo and from\nfollowing registries.\n\n[Deno Registry](https://deno.land/x/fast_forward)\n\n```typescript\nimport { ffmpeg } from \"https://deno.land/x/fast_forward@\u003cversion\u003e/mod.ts\";\n```\n\n[Nest Registry](https://nest.land/package/fast_forward)\n\n```typescript\nimport { ffmpeg } from \"https://x.nest.land/fast_forward@\u003cversion\u003e/mod.ts\";\n```\n\n[Github](https://github.com/c4spar/deno-fast-forward)\n\n```typescript\nimport { ffmpeg } from \"https://raw.githubusercontent.com/c4spar/deno-fast-forward/\u003cversion\u003e/mod.ts\";\n```\n\n## Usage\n\n```typescript\nawait ffmpeg(\"https://www.w3schools.com/html/mov_bbb.mp4\")\n  // Global encoding options (applied to all outputs).\n  .audioBitrate(\"192k\")\n  .videoBitrate(\"1M\")\n  .width(480)\n  .height(640)\n  // Ouput 1.\n  .output(\"output.mp4\")\n  .audioCodec(\"aac\")\n  .videoCodec(\"libx264\")\n  // Ouput 2.\n  .output(\"output.webm\")\n  .audioCodec(\"libvorbis\")\n  .videoCodec(\"libvpx-vp9\")\n  // Start encoding.\n  .encode();\n\nconsole.log(\"All encodings done!\");\n```\n\n```typescript\n$ deno run --allow-read --allow-run https://deno.land/x/fast_forward/examples/usage.ts\n```\n\n## Getting Started\n\nFirst create an instance of FFmpeg.\n\n```typescript\nconst encoder = ffmpeg(\"https://www.w3schools.com/html/mov_bbb.mp4\");\n// or using the constructor\nconst encoder = new FFmpeg(\"https://www.w3schools.com/html/mov_bbb.mp4\");\n```\n\nThen you can define global options and events which will be applied to all\ndefined outputs.\n\n```typescript\nencoder\n  .audioBitrate(\"192k\")\n  .videoBitrate(\"1M\")\n  .addEventListener(\n    \"progress\",\n    (event) =\u003e console.log(\"Progress: %s\", event.progress),\n  )\n  .addEventListener(\"error\", (event) =\u003e console.log(event.error));\n```\n\nThe `.output()` method add's a new encoding object which inherits all global\noptions and events. Multiple outputs can be added with additional options for\neach output.\n\n```typescript\nencoder\n  .output(\"output-x264.mp4\")\n  .videoCodec(\"libx264\")\n  .output(\"output-x265.mp4\")\n  .videoCodec(\"libx265\");\n```\n\nTo start the encoding just call the `.encode()` method and await the returned\npromise.\n\n```typescript\nawait encoder.encode();\n```\n\nTo get more control over the encoding precesses you can use the encoder instance\nas async iterator to iterate over all encoding processes with a `for await`\nloop. The process instance is an wrapper around the deno process and has almost\nthe same methods and properties. The encoding process can be started with the\n`.run()` method and must be closed with the `.close()` method after the process\nis finished or has failed.\n\nThere are to different ways to await the status. The first one is using the\n`.status()` method, same like with the deno process.\n\n```typescript\nfor await (const process: EncodingProcess of encoder) {\n  process.run();\n  const status: EncodingStatus = await process.status();\n  if (!status.success) {\n    process.close();\n    throw new Error(\"Encoding failed.\");\n  }\n  process.close();\n}\nconsole.log(\"All encodings done!\");\n```\n\nThe second one is using an async iterator. You can use the encoding process as\nasync iterator to iterate over all encoding events. If no error occurs then the\nstatus is success, if the status is not success or any encoding error occurs an\nerror event is emitted.\n\n```typescript\nfor await (const process: EncodingProcess of encoder) {\n  process.run();\n  for await (const event: EncodingEvent of process) {\n    switch (event.type) {\n      case \"start\":\n        console.log(\"start encoding of: %s\", event.encoding.output);\n        return;\n      case \"info\":\n        console.log(\"Media info loaded: %o\", event.info);\n        return;\n      case \"progress\":\n        console.log(\n          \"Encoding progress of: %s - %n%\",\n          event.encoding.output,\n          event.progress,\n        );\n        return;\n      case \"end\":\n        console.log(\"Encoding of %s done!\", event.encoding.output);\n        return;\n      case \"error\":\n        process.close();\n        throw event.error;\n    }\n  }\n  process.close();\n}\nconsole.log(\"All encodings done!\");\n```\n\n## Examples\n\n### Events\n\n```typescript\nawait ffmpeg(\"https://www.w3schools.com/html/mov_bbb.mp4\")\n  .audioBitrate(\"192k\")\n  .videoBitrate(\"1M\")\n  .width(480)\n  .height(640)\n  .addEventListener(\"start\", (event) =\u003e console.log(\"Event: %s\", event.type))\n  .addEventListener(\"info\", (event) =\u003e console.log(\"Event: %s\", event.type))\n  .addEventListener(\"progress\", (event) =\u003e console.log(\"Event: %s\", event.type))\n  .addEventListener(\"end\", (event) =\u003e console.log(\"Event: %s\", event.type))\n  .addEventListener(\"error\", (error) =\u003e console.log(\"Event: %s\", error.type))\n  .output(\"output.mp4\")\n  .output(\"output.webm\")\n  .encode();\n\nconsole.log(\"All encodings done!\");\n```\n\n```\n$ deno run --allow-read --allow-run https://deno.land/x/fast_forward/examples/events.ts\n```\n\n### Process handling\n\n```typescript\nconst encoder = ffmpeg(\"https://www.w3schools.com/html/mov_bbb.mp4\")\n  .audioBitrate(\"192k\")\n  .videoBitrate(\"1M\")\n  .width(480)\n  .height(640)\n  .output(\"output.mp4\")\n  .output(\"output.mkv\");\n\nfor await (const process: EncodingProcess of encoder) {\n  process.run();\n  const status: EncodingStatus = await process.status();\n  process.close();\n  if (!status.success) {\n    throw new Error(\n      `Encoding failed: ${process.encoding.output}\\n${\n        new TextDecoder().decode(await process.stderrOutput())\n      }`,\n    );\n  }\n  console.log(\"Encoding of %s done!\", process.encoding.output);\n}\n\nconsole.log(\"All encodings done!\");\n```\n\n```\n$ deno run --allow-read --allow-run https://deno.land/x/fast_forward/examples/process-handling.ts\n```\n\n### Event Stream\n\n```typescript\nconst spinner = wait({ text: \"\" });\n\nconst encoder = ffmpeg(\"https://www.w3schools.com/html/mov_bbb.mp4\")\n  .audioBitrate(\"192k\")\n  .videoBitrate(\"1M\")\n  .width(480)\n  .height(640)\n  .output(\"output.mp4\")\n  .output(\"output.webm\");\n\nfor await (const process: EncodingProcess of encoder) {\n  process.run();\n  spinner.start();\n  for await (const event: EncodingEvent of process) {\n    switch (event.type) {\n      case \"start\":\n        spinner.text = `Loading meta data: ${event.encoding.output} ...`;\n        break;\n      case \"info\":\n        spinner.text = `Start encoding: ${event.encoding.output} ...`;\n        break;\n      case \"progress\":\n        spinner.text = `Encode: ${event.encoding.output} - ${event.progress}%`;\n        break;\n      case \"end\":\n        spinner.stop();\n        process.close();\n        console.log(`✔ Encode: ${process.encoding.output} - 100%`);\n        break;\n      case \"error\":\n        spinner.stop();\n        process.close();\n        console.log(`✘ Encode: ${process.encoding.output} - failed!`);\n        throw event.error;\n    }\n  }\n}\n\nconsole.log(\"All encodings done!\");\n```\n\n```\n$ deno run --allow-read --allow-run --unstable https://deno.land/x/fast_forward/examples/event-stream.ts\n```\n\n### Output Stream\n\n```typescript\nexport { copy } from \"https://deno.land/std/io/util.ts\";\n\nconst encoder = ffmpeg(\"https://www.w3schools.com/html/mov_bbb.mp4\")\n  .output(\"pipe:1\")\n  .format(\"mp4\")\n  .videoBitrate(\"933k\")\n  .audioBitrate(\"128k\")\n  .args([\"-movflags\", \"frag_keyframe+empty_moov\"]);\n\nfor await (const process: EncodingProcess of encoder) {\n  process.run();\n  if (process.stdout) {\n    const outputFile: Deno.File = await Deno.open(\"output.mp4\", {\n      create: true,\n      write: true,\n    });\n    const [status] = await Promise.all([\n      process.status(),\n      copy(process.stdout, outputFile),\n    ]);\n    console.log({ status });\n  }\n  process.close();\n}\n\nconsole.log(\"Encoding done!\");\n```\n\n```\n$ deno run --allow-read --allow-write --allow-run https://deno.land/x/fast_forward/examples/output-stream.ts\n```\n\n## Todos\n\n### Options\n\n- [x] output\n  - [x] support multiple outputs\n- [x] input\n  - [ ] support multiple inputs\n- [x] cwd\n- [x] binary\n- [x] override\n- [x] format\n- [x] codec\n- [x] audioCodec\n- [x] videoCodec\n- [x] audioBitrate\n- [x] videoBitrate\n- [x] minVideoBitrate\n- [x] maxVideoBitrate\n- [x] videoBufSize\n- [x] width\n- [x] height\n- [ ] rotate\n- [x] noAudio\n- [x] noVideo\n- [ ] noSubtitle\n- [x] logLevel\n- [x] args\n- [ ] seek\n- [x] duration\n- [x] loop\n- [ ] preset (name,path)\n- [ ] watermark\n- [x] sampleRate\n- [x] audioQuality\n- [x] audioChannels\n- [ ] audioFilters\n- [ ] videoFilters\n- [ ] metadata\n- [ ] volume\n- [x] frames\n- [ ] frameSize/size\n- [x] fps/frameRate/rate\n- [ ] aspectRatio/aspect\n- [ ] loudnorm/normalize\n- [ ] autopad\n- [ ] keepDAR\n- [ ] map (map streams in container)\n- [ ] add input options\n- [ ] thumbnails\n- [ ] concat/merge (merge input files)\n- [ ] split (split output file by size/time)\n\n### Methods\n\n- [ ] getAvailableFilters()\n- [ ] getAvailableCodecs()\n- [ ] getAvailableEncoders()\n- [ ] getAvailableFormats()\n- [ ] validate()/checkCapabilities()\n- [ ] thumbnail()/thumbnails()\n- [ ] flipVertical/flipHorizontal\n- [ ] rotate()\n\n### Events\n\n- [x] start\n- [x] info/meta/metadata\n- [x] progress\n- [x] end\n- [x] error\n- [ ] stderr (ffmpeg output)\n\n## Contributing\n\nAny kind of contribution is welcome! Please take a look at the\n[contributing guidelines](../CONTRIBUTING.md).\n\n## License\n\n[MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc4spar%2Fdeno-fast-forward","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fc4spar%2Fdeno-fast-forward","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc4spar%2Fdeno-fast-forward/lists"}