{"id":24711170,"url":"https://github.com/stacksjs/audiox","last_synced_at":"2025-03-22T06:43:57.178Z","repository":{"id":274356035,"uuid":"922652434","full_name":"stacksjs/audiox","owner":"stacksjs","description":"🎵 Powerful audio processing for your media workflows. ","archived":false,"fork":false,"pushed_at":"2025-03-21T17:54:52.000Z","size":702,"stargazers_count":2,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-21T18:35:30.019Z","etag":null,"topics":["audio","bun","cli","ffmpeg","library","optimization","processing","typescript"],"latest_commit_sha":null,"homepage":"https://stacks-audiox.netlify.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/stacksjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["stacksjs","chrisbbreuer"],"open_collective":"stacksjs"}},"created_at":"2025-01-26T19:03:00.000Z","updated_at":"2025-03-18T12:06:35.000Z","dependencies_parsed_at":"2025-01-26T20:23:42.303Z","dependency_job_id":"5d9e4b2b-e361-4b99-9a4f-0566de6c0590","html_url":"https://github.com/stacksjs/audiox","commit_stats":null,"previous_names":["stacksjs/audiox"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacksjs%2Faudiox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacksjs%2Faudiox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacksjs%2Faudiox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacksjs%2Faudiox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stacksjs","download_url":"https://codeload.github.com/stacksjs/audiox/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244852465,"owners_count":20521152,"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":["audio","bun","cli","ffmpeg","library","optimization","processing","typescript"],"created_at":"2025-01-27T07:14:03.172Z","updated_at":"2025-03-22T06:43:57.170Z","avatar_url":"https://github.com/stacksjs.png","language":"TypeScript","funding_links":["https://github.com/sponsors/stacksjs","https://github.com/sponsors/chrisbbreuer","https://opencollective.com/stacksjs"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"https://github.com/stacksjs/audiox/blob/main/.github/art/cover.jpg?raw=true\" alt=\"Social Card of this repo\"\u003e\u003c/p\u003e\n\n[![npm version][npm-version-src]][npm-version-href]\n[![GitHub Actions][github-actions-src]][github-actions-href]\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n\u003c!-- [![npm downloads][npm-downloads-src]][npm-downloads-href] --\u003e\n\u003c!-- [![Codecov][codecov-src]][codecov-href] --\u003e\n\n# audiox\n\n\u003e A TypeScript-based audio processing library \u0026 CLI that wraps ffmpeg, helping you optimize audio files in Node.js/Bun environments.\n\n## Features\n\n- Audio optimizations and conversions\n- Stream-based processing support\n- Metadata handling\n- Multiple output formats _(WAV, MP3, AAC)_\n- Configurable audio properties _(bitrate, channels, sample rate)_\n- Error handling and detailed logging\n- Fully typed with TypeScript\n\n## Install\n\n```bash\nbun install @stacksjs/audiox\n```\n\n## Get Started\n\nThere are two ways of using this tool: as a library or as a CLI.\n\n### Library Usage\n\nGiven the npm package is installed:\n\n```ts\nimport { audio, audioInfo } from '@stacksjs/audiox'\n\n// Basic audio conversion\nawait audio('input.mp3', 'output.wav', {\n  codec: 'pcm_s16le',\n  channels: 1,\n  sampleRate: 16000,\n  bitrate: '160k',\n})\n\n// Get audio file information\nconst info = await audioInfo('audio.mp3')\nconsole.log(info)\n// [\n//   {\n//     codec: 'mp3',\n//     channels: 2,\n//     sampleRate: '44100',\n//     bitrate: '192000',\n//     duration: '180.5',\n//   }\n// ]\n\n// Convert with metadata\nawait audio('input.mp3', 'output.mp3', {\n  codec: 'mp3',\n  bitrate: '192k',\n  channels: 2,\n  sampleRate: 44100,\n  metadata: {\n    title: 'My Track',\n    artist: 'Artist Name',\n    album: 'Album Name',\n    year: '2024',\n  },\n})\n\n// Stream processing\nconst file = Bun.file('input.mp3')\nconst stream = file.stream()\n\nawait audioWithStreamInput(stream, 'output.wav', {\n  codec: 'pcm_s16le',\n  bitrate: '128k',\n  channels: 1,\n  sampleRate: 16000,\n})\n\n// Buffer processing\nconst arrayBuffer = await Bun.file('input.mp3').arrayBuffer()\nconst wavData = await audioWav(new Uint8Array(arrayBuffer))\nawait Bun.write('output.wav', wavData)\n```\n\n### CLI Usage\n\nOnce installed globally or locally in your project, you can use audiox from the command line:\n\n```bash\n# Global installation\nnpm install -g @stacksjs/audiox\n\n# Using npx with local installation\nnpx audiox [command] [options]\n\n# Using bun\nbunx audiox [command] [options]\n```\n\n#### Basic Commands\n\nConvert audio files with default settings:\n\n```bash\naudiox convert input.mp3 output.wav\n```\n\nGet audio file information:\n\n```bash\naudiox info input.mp3\n```\n\n#### Convert Command Options\n\n```bash\naudiox convert \u003cinput\u003e \u003coutput\u003e [options]\n\nOptions:\n  --codec \u003ccodec\u003e           Audio codec (aac, mp3, pcm_s16le)\n  --bitrate \u003cbitrate\u003e       Audio bitrate (e.g., \"192k\")\n  --channels \u003cnumber\u003e       Number of channels (1, 2, 5.1, 7.1)\n  --sample-rate \u003crate\u003e      Sample rate (8000, 16000, 44100, 48000)\n  --quality \u003cnumber\u003e        Audio quality setting\n  -m, --metadata \u003cdata\u003e     Set metadata (format: key=value)\n  -v, --verbose            Enable verbose output\n```\n\n#### Examples\n\nConvert to WAV with specific settings:\n\n```bash\naudiox convert input.mp3 output.wav --codec pcm_s16le --channels 1 --sample-rate 16000 --bitrate 128k\n```\n\nConvert to MP3 with metadata:\n\n```bash\naudiox convert input.wav output.mp3 --codec mp3 --bitrate 192k \\\n  --metadata title=\"My Song\" \\\n  --metadata artist=\"Artist Name\" \\\n  --metadata year=2024\n```\n\nGet detailed audio information including metadata:\n\n```bash\naudiox info input.mp3 --metadata title,artist,album,year\n```\n\n#### Configuration\n\nYou can create a `audiox.config.js` or `audiox.config.ts` file in your project root to set default options:\n\n```ts\nimport type { AudioxOptions } from './src/types'\n\nconst config: AudioxOptions = {\n  codec: 'mp3',\n  bitrate: '192k',\n  channels: 2,\n  sampleRate: 44100,\n  verbose: true\n}\n\nexport default config\n```\n\nThe CLI will automatically use these defaults unless overridden by command-line options.\n\n### Advanced Usage\n\n#### Stream Processing with Custom Handlers\n\n```ts\n// Process audio with stream output handling\nawait audioWithStreamOut(\n  'input.mp3',\n  {\n    onProcessDataFlushed: (chunk) =\u003e {\n      // Handle each chunk of processed audio\n      console.log('Processing chunk:', chunk?.length)\n    },\n    onProcessDataEnd: async (data) =\u003e {\n      // Handle completed audio data\n      await Bun.write('output.wav', data!)\n    },\n  },\n  {\n    codec: 'pcm_s16le',\n    bitrate: '128k',\n    channels: 1,\n    sampleRate: 16000,\n  },\n)\n```\n\n#### Detailed Audio Information\n\n```ts\n// Get audio information including metadata\nconst audioInfo = await audioInfo('music.mp3', {\n  metadataTags: ['title', 'artist', 'album', 'track', 'genre', 'year'],\n})\n\n// Example response:\n// [\n//   {\n//     codec: 'mp3',\n//     channels: 2,\n//     sampleRate: '44100',\n//     bitrate: '192000',\n//     duration: '180.5',\n//     metadata: {\n//       title: 'Song Title',\n//       artist: 'Artist Name',\n//       album: 'Album Name',\n//       track: '1',\n//       genre: 'Pop',\n//       year: '2024'\n//     }\n//   }\n// ]\n```\n\n## Configuration\n\nAudiox can be configured using a `audiox.config.ts` (or `audiox.config.js`) file:\n\n```ts\nimport type { AudioxConfig } from '@stacksjs/audiox'\n\nconst config: AudioxConfig = {\n  verbose: true, // Enable detailed logging\n  // Default audio settings\n  codec: 'mp3',\n  bitrate: '192k',\n  channels: 2,\n  sampleRate: 44100,\n}\n\nexport default config\n```\n\n### Available Options\n\n```ts\ninterface AudioxOptions {\n  codec?: 'aac' | 'mp3' | 'pcm_s16le' | string\n  bitrate?: string // e.g., \"192k\"\n  channels?: 1 | 2 | 5.1 | 7.1 | number\n  sampleRate?: 8000 | 16000 | 44100 | 48000 | number\n  quality?: number\n  metadata?: {\n    [key: string]: string\n  }\n  onError?: (error: unknown) =\u003e void\n  verbose: boolean\n}\n```\n\n## Testing\n\n```bash\nbun test\n```\n\n## Changelog\n\nPlease see our [releases](https://github.com/stacksjs/stacks/releases) page for more information on what has changed recently.\n\n## Contributing\n\nPlease review the [Contributing Guide](https://github.com/stacksjs/contributing) for details.\n\n## Community\n\nFor help, discussion about best practices, or any other conversation that would benefit from being searchable:\n\n[Discussions on GitHub](https://github.com/stacksjs/stacks/discussions)\n\nFor casual chit-chat with others using this package:\n\n[Join the Stacks Discord Server](https://discord.gg/stacksjs)\n\n## Postcardware\n\n“Software that is free, but hopes for a postcard.” We love receiving postcards from around the world showing where `audiox` is being used! We showcase them on our website too.\n\nOur address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094 🌎\n\n## Sponsors\n\nWe would like to extend our thanks to the following sponsors for funding Stacks development. If you are interested in becoming a sponsor, please reach out to us.\n\n- [JetBrains](https://www.jetbrains.com/)\n- [The Solana Foundation](https://solana.com/)\n\n## Credits\n\n- [`bun-ffmpeg`](https://github.com/KenjiGinjo/bun-ffmpeg)\n- [Chris Breuer](https://github.com/chrisbbreuer)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [LICENSE](https://github.com/stacksjs/stacks/tree/main/LICENSE.md) for more information.\n\nMade with 💙\n\n\u003c!-- Badges --\u003e\n[npm-version-src]: https://img.shields.io/npm/v/@stacksjs/audiox?style=flat-square\n[npm-version-href]: https://npmjs.com/package/@stacksjs/audiox\n[github-actions-src]: https://img.shields.io/github/actions/workflow/status/stacksjs/audiox/ci.yml?style=flat-square\u0026branch=main\n[github-actions-href]: https://github.com/stacksjs/audiox/actions?query=workflow%3Aci\n\n\u003c!-- [codecov-src]: https://img.shields.io/codecov/c/gh/stacksjs/audiox/main?style=flat-square\n[codecov-href]: https://codecov.io/gh/stacksjs/audiox --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstacksjs%2Faudiox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstacksjs%2Faudiox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstacksjs%2Faudiox/lists"}