{"_id":"@abdu-selam/multi-media","name":"@abdu-selam/multi-media","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@abdu-selam/multi-media","version":"1.0.0","description":"Powerfull video processing package that allow you to handle videos easily with ffmpeg.","license":"MIT","main":"./dist/index.cjs","module":"./dist/index.mjs","types":"./dist/index.d.mts","exports":{".":{"types":{"import":"./dist/index.d.mts","require":"./dist/index.d.cts"},"import":"./dist/index.mjs","require":"./dist/index.cjs"}},"type":"module","scripts":{"dev":"tsx watch ./src/index.ts","build":"tsdown","prepublishOnly":"npm run build"},"keywords":["video","video-processing","multi-media","video processing","processor","typescript","nodejs","ffmpeg","ffprobe","video-converter","video-metadata","video-trimmer","video-splitter","audio","audio-extraction","media-processing","multimedia"],"author":{"name":"Abduselam Awel"},"repository":{"type":"git","url":"git+https://github.com/abdu-selam/multi-media.git"},"bugs":{"url":"https://github.com/abdu-selam/multi-media/issues"},"homepage":"https://github.com/abdu-selam/multi-media#readme","engines":{"node":">=18"},"devDependencies":{"@types/node":"^26.4.0","tsdown":"^0.22.14","tsx":"^4.23.13","typescript":"^7.0.2"},"gitHead":"3446fde707f38ee6af3b5ad9d208f59d72fbf464","_id":"@abdu-selam/multi-media@1.0.0","_nodeVersion":"24.18.0","_npmVersion":"12.0.2","dist":{"integrity":"sha512-5qEx3dSwYHeWmICefBtL2qvCs3gTgwJJP6DoYZ20iOXEOtrQpp9Loudnqny2Kht4TCEW5H7IxnD2Po1cIK2/kQ==","shasum":"9ca6b2de4c6b9eebd10ad23bcff09a4ab33d12d7","tarball":"https://registry.npmjs.org/@abdu-selam/multi-media/-/multi-media-1.0.0.tgz","fileCount":80,"unpackedSize":154843,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEcc+7hUoCouIATLyLCc+uJNfq3LZDhT9Sqqoj6uhghmAiEAhhq0NmugQrIF41myzb4gRU3d+z1wN77KRsZp5btPiDc="}]},"_npmUser":{"name":"abdu-selam","email":"abdselam676@gmail.com"},"directories":{},"maintainers":[{"name":"abdu-selam","email":"abdselam676@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/multi-media_1.0.0_1788809127472_0.52796986620092"},"_hasShrinkwrap":false}},"time":{"created":"2026-09-07T19:25:27.299Z","1.0.0":"2026-09-07T19:25:27.581Z","modified":"2026-09-07T19:25:27.778Z"},"maintainers":[{"name":"abdu-selam","email":"abdselam676@gmail.com"}],"description":"Powerfull video processing package that allow you to handle videos easily with ffmpeg.","homepage":"https://github.com/abdu-selam/multi-media#readme","keywords":["video","video-processing","multi-media","video processing","processor","typescript","nodejs","ffmpeg","ffprobe","video-converter","video-metadata","video-trimmer","video-splitter","audio","audio-extraction","media-processing","multimedia"],"repository":{"type":"git","url":"git+https://github.com/abdu-selam/multi-media.git"},"author":{"name":"Abduselam Awel"},"bugs":{"url":"https://github.com/abdu-selam/multi-media/issues"},"license":"MIT","readme":"# Multi-Media\n\nA TypeScript/Node.js library for working with video files through **FFmpeg** and **FFprobe**.\n\n`@abdu-selam/multi-media` provides a simple, strongly typed API for video metadata extraction, format conversion, audio extraction, trimming, splitting, and common file operations without requiring you to work directly with FFmpeg commands.\n\n## Features\n\n- Video metadata extraction\n- Audio metadata extraction\n- Format metadata extraction\n- Complete media metadata\n- Video format conversion\n- Video to audio conversion\n- Video trimming\n- Video splitting\n- Rename, move, copy, and delete video files\n- Conversion progress callbacks\n- Custom error classes\n- Full TypeScript type definitions\n- ESM and CommonJS support\n\n## Requirements\n\n- **_FFmpeg_** (if your system doesn't have FFmpeg this package can't do anything for you)\n- **_FFprobe_**\n- Node.js `>=18`\n\nFFmpeg and FFprobe must be installed and available in your system's `PATH`.\n\nYou can verify the installation with:\n\n```bash\nffmpeg -version\nffprobe -version\n```\n\n## Installation\n\n```bash\nnpm install @abdu-selam/multi-media\n```\n\n## Basic Usage\n\n```ts\nimport { Video } from \"@abdu-selam/multi-media\";\n\nconst video = new Video(\"./input.mp4\");\n```\n\n## Metadata\n\n### Video Metadata\n\n```ts\nconst metadata = await video.videoMeta();\n\nconsole.log(metadata);\n```\n\nReturns information such as:\n\n- Codec\n- Resolution\n- Frame rate\n- Bitrate\n- Aspect ratio\n- Duration\n\n### Audio Metadata\n\n```ts\nconst audio = await video.audioMeta();\n\nconsole.log(audio);\n```\n\nReturns audio information such as codec, sample rate, channels, bitrate, and duration.\n\n### Format Metadata\n\n```ts\nconst format = await video.formatMeta();\n\nconsole.log(format);\n```\n\n### Complete Metadata\n\n```ts\nconst metadata = await video.meta();\n\nconsole.log(metadata);\n```\n\nYou can also retrieve metadata without creating a `Video` instance:\n\n```ts\nconst metadata = await Video.meta(\"./input.mp4\");\n```\n\n## Video Conversion\n\nConvert a video into another supported video format:\n\n```ts\nawait video.toMime(\"webm\", \"./output\");\n```\n\nSupported video formats:\n\n```text\nmp4, mkv, webm, avi, mov, mpeg, ogv, flv, m4v, 3gp\n```\n\nThe library automatically configures the appropriate FFmpeg container and codecs for the selected format.\n\n## Video to Audio\n\nExtract the audio track from a video:\n\n```ts\nawait video.toAudio(\"mp3\", \"./output\");\n```\n\nSupported audio formats:\n\n```text\nmp3\nm4a\nwav\nflac\nogg\naiff\n```\n\n## Trimming\n\nTrim a video between two points:\n\n```ts\nawait video.trim(10, 30, \"./output\");\n```\n\nThis creates a new video containing the section between **10 and 30 seconds**.\n\n### Trim From a Specific Point\n\n```ts\nawait video.trimStart(10, \"./output\");\n```\n\nThis keeps the video from 10 seconds until the end.\n\n### Trim Until a Specific Point\n\n```ts\nawait video.trimEnd(30, \"./output\");\n```\n\nThis keeps the video from the beginning until 30 seconds.\n\n## Splitting\n\nSplit a video at a specific point:\n\n```ts\nawait video.split(30, \"./output\");\n```\n\nFor example, a 60-second video split at 30 seconds produces two video files:\n\n```text\n0s  ─────────  30s  ─────────  60s\n      part 1          part 2\n```\n\nThe generated paths are reported when the operation completes.\n\n## Progress Tracking\n\nConversion and processing methods support a progress callback.\n\n```ts\nawait video.toMime(\"webm\", \"./output\", false, (progress) => {\n  console.log(progress);\n});\n```\n\nThe callback receives information such as:\n\n```ts\n{\n  time: number;\n  speed: string | undefined;\n  size: number;\n  status: string | undefined;\n  duration: number;\n  progress: number;\n}\n```\n\n`progress` is represented as a value between `0` and `1`.\n\nFor example:\n\n```ts\nawait video.toAudio(\"mp3\", \"./output\", false, (progress) => {\n  console.log(`${(progress.progress * 100).toFixed(2)}%`);\n});\n```\n\n## Logging\n\nProcessing methods display terminal progress by default.\n\nYou can disable terminal logging by passing `false`:\n\n```ts\nawait video.toMime(\"mp4\", \"./output\", false);\n```\n\nThe progress callback can still be used when terminal logging is disabled.\n\n## File Operations\n\nThe `Video` class also provides common file operations.\n\n### Check Whether a File Exists and Is a Video\n\n```ts\nconst exists = await video.isExist();\n```\n\nOr:\n\n```ts\nconst exists = await Video.isExist(\"./input.mp4\");\n```\n\n### Rename\n\n```ts\nawait video.rename(\"new-video\");\n```\n\n### Move\n\n```ts\nawait video.move(\"./videos\");\n```\n\n### Copy\n\n```ts\nawait video.copy(\"./backup\");\n```\n\n### Delete\n\n```ts\nawait video.delete();\n```\n\nStatic versions of these operations are also available:\n\n```ts\nawait Video.rename(\"./input.mp4\", \"new-video\");\n\nawait Video.move(\"./input.mp4\", \"./videos\");\n\nawait Video.copy(\"./input.mp4\", \"./backup\");\n\nawait Video.delete(\"./input.mp4\");\n```\n\n## Error Handling\n\nThe package provides custom errors for common failures, including:\n\n- `InvalidVideoError`\n- `FFprobeNotFound`\n- `FFmpegNotFound`\n- `InvalidPath`\n- `InvalidSecond`\n- `InvalidSecondLimit`\n- `InvalidSecondLimitStart`\n- `FFmpegError`\n- `InvalidMime`\n\nFor example:\n\n```ts\nimport { Video } from \"@abdu-selam/multi-media\";\n\ntry {\n  const video = new Video(\"./input.mp4\");\n\n  await video.toMime(\"webm\", \"./output\");\n} catch (error) {\n  console.error(error);\n}\n```\n\n## Supported Formats\n\n### Video\n\n| Format       | Extension |\n| ------------ | --------- |\n| MPEG-4       | `.mp4`    |\n| Matroska     | `.mkv`    |\n| WebM         | `.webm`   |\n| AVI          | `.avi`    |\n| QuickTime    | `.mov`    |\n| MPEG         | `.mpeg`   |\n| Ogg Video    | `.ogv`    |\n| Flash Video  | `.flv`    |\n| MPEG-4 Video | `.m4v`    |\n| 3GPP         | `.3gp`    |\n\n### Audio\n\n| Format       | Extension |\n| ------------ | --------- |\n| MP3          | `.mp3`    |\n| MPEG-4 Audio | `.m4a`    |\n| WAV          | `.wav`    |\n| FLAC         | `.flac`   |\n| Ogg Vorbis   | `.ogg`    |\n| AIFF         | `.aiff`   |\n\n## API Overview\n\n### `Video`\n\n| Method         | Description                              |\n| -------------- | ---------------------------------------- |\n| `videoMeta()`  | Get video stream metadata                |\n| `audioMeta()`  | Get audio stream metadata                |\n| `fileMeta()`   | Get file metadata                        |\n| `formatMeta()` | Get container/format metadata            |\n| `meta()`       | Get complete metadata                    |\n| `isExist()`    | Check whether the input is a valid video |\n| `rename()`     | Rename the video                         |\n| `move()`       | Move the video                           |\n| `copy()`       | Copy the video                           |\n| `delete()`     | Delete the video                         |\n| `toMime()`     | Convert to another video format          |\n| `toAudio()`    | Extract/convert audio                    |\n| `trim()`       | Trim between two timestamps              |\n| `trimStart()`  | Trim from a timestamp to the end         |\n| `trimEnd()`    | Trim from the beginning to a timestamp   |\n| `split()`      | Split a video at a timestamp             |\n\n## How It Works\n\nThe package uses:\n\n- **FFprobe** for inspecting media files and extracting metadata.\n- **FFmpeg** for video conversion, audio conversion, trimming, and splitting.\n- **Node.js filesystem APIs** for file management.\n\nThe library handles the FFmpeg command construction and exposes a higher-level API so applications can perform common video operations without manually constructing FFmpeg arguments.\n\n## Development\n\nClone the repository:\n\n```bash\ngit clone https://github.com/abdu-selam/multi-media.git\ncd multi-media\n```\n\nInstall dependencies:\n\n```bash\nnpm install\n```\n\nBuild the package:\n\n```bash\nnpm run build\n```\n\nThe compiled package is generated in the `dist` directory.\n\n## License\n\nThis project is licensed under the MIT License.\n\nSee the [LICENSE](./LICENSE) file for details.\n\n## Author\n\n**Abduselam Awel**\n\nGitHub: https://github.com/abdu-selam\n\n## Repository\n\nhttps://github.com/abdu-selam/multi-media\n\nIf you find the package useful, consider giving the repository a ⭐.\n","readmeFilename":"README.md","_rev":"1-beda7635be3629e44a2c4ac3669d06e4"}