m4k 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
1
  import { type AudioOptions } from "@m4k/common";
2
2
  /**
3
- * Process a video.
4
- * @param input - The input video. Can be a file path, a stream or a blob.
5
- * @param opts - The options for the video processing.
3
+ * Process an audio file.
4
+ * @param input - The input audio file. Can be a file path, a stream or a blob.
5
+ * @param opts - The options for the audio processing.
6
6
  * @param signal - An optional abort signal.
7
- * @returns An iterable of the processed videos.
7
+ * @returns An iterable of the processed audio files.
8
8
  */
9
9
  export declare function processAudio(input: string | AsyncIterable<Uint8Array> | Blob, opts: AudioOptions | AudioOptions[], { signal }?: {
10
10
  signal?: AbortSignal;
@@ -14,7 +14,7 @@ export declare function processAudio(input: string | AsyncIterable<Uint8Array> |
14
14
  position: number;
15
15
  }, void, unknown> | null;
16
16
  /**
17
- * The queue for video processing.
17
+ * The queue for audio processing.
18
18
  */
19
19
  export declare const audioQueue: import("tasque").Tasque;
20
20
  //# sourceMappingURL=audio-processor.d.ts.map
@@ -3,11 +3,11 @@ import { mkdir } from "node:fs/promises";
3
3
  import { createQueue } from "tasque";
4
4
  import { getExtension, processFfmpeg } from "../util/ffmpeg-processor";
5
5
  /**
6
- * Process a video.
7
- * @param input - The input video. Can be a file path, a stream or a blob.
8
- * @param opts - The options for the video processing.
6
+ * Process an audio file.
7
+ * @param input - The input audio file. Can be a file path, a stream or a blob.
8
+ * @param opts - The options for the audio processing.
9
9
  * @param signal - An optional abort signal.
10
- * @returns An iterable of the processed videos.
10
+ * @returns An iterable of the processed audio files.
11
11
  */
12
12
  export function processAudio(input, opts, { signal } = {}) {
13
13
  return processFfmpeg(input, () => {
@@ -28,6 +28,8 @@ export function processAudio(input, opts, { signal } = {}) {
28
28
  a.push("-filter_complex", o.complexFilters);
29
29
  if (o.codec)
30
30
  a.push("-c:a", o.codec);
31
+ if (o.args)
32
+ a.push(...o.args);
31
33
  args.push({
32
34
  args: a,
33
35
  ext: o.ext ?? getExtension(o.format ?? "mp3"),
@@ -37,7 +39,7 @@ export function processAudio(input, opts, { signal } = {}) {
37
39
  }, { signal, queue: audioQueue, tmpDir });
38
40
  }
39
41
  /**
40
- * The queue for video processing.
42
+ * The queue for audio processing.
41
43
  */
42
44
  export const audioQueue = createQueue({
43
45
  parallelize: Number(process.env.AUDIO_PARALLELIZE ?? 1),
@@ -19,7 +19,7 @@ export function processImage(input, opts, { signal } = {}) {
19
19
  : "stream" in input
20
20
  ? input.stream()
21
21
  : input, sharpInstance);
22
- const files = opts.map(async ({ colorspace, crop, format = "avif", keepExif, keepIcc, keepMetadata, quality, resize, rotate, }, idx) => {
22
+ const files = opts.map(async ({ colorspace, crop, format = "avif", ext = format, keepExif, keepIcc, keepMetadata, quality, resize, rotate, }, idx) => {
23
23
  let s = sharpInstance.clone();
24
24
  s = s.rotate(rotate);
25
25
  if (resize)
@@ -42,8 +42,8 @@ export function processImage(input, opts, { signal } = {}) {
42
42
  top: crop.top ?? 0,
43
43
  });
44
44
  }
45
- s = s.toFormat(format, { quality });
46
- return new ProcessedFile(`file${idx + 1}.${format}`, `image/${format}`, s);
45
+ s = s.toFormat(ext, { quality });
46
+ return new ProcessedFile(`file${idx + 1}.${ext}`, `image/${ext}`, s);
47
47
  });
48
48
  let done = 0;
49
49
  yield { progress: 0 };
package/lib/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- export * from "@m4k/common";
1
+ export { ProcessedFile, type AudioOptions, type ImageOptions, type ProcessingError, type Progress, type QueuePosition, type VideoOptions } from "@m4k/common";
2
2
  export { audioQueue, processAudio } from "./audio/audio-processor";
3
3
  export { imageQueue, processImage } from "./images/image-processor";
4
4
  export { getExtension } from "./util/ffmpeg-processor";
5
+ export { mimeTypes } from "./util/mime";
5
6
  export { processVideo, videoQueue } from "./videos/video-processor";
6
7
  //# sourceMappingURL=index.d.ts.map
package/lib/index.js CHANGED
@@ -1,6 +1,7 @@
1
- export * from "@m4k/common";
1
+ export { ProcessedFile } from "@m4k/common";
2
2
  export { audioQueue, processAudio } from "./audio/audio-processor";
3
3
  export { imageQueue, processImage } from "./images/image-processor";
4
4
  export { getExtension } from "./util/ffmpeg-processor";
5
+ export { mimeTypes } from "./util/mime";
5
6
  export { processVideo, videoQueue } from "./videos/video-processor";
6
7
  //# sourceMappingURL=index.js.map
@@ -44,6 +44,8 @@ export function processVideo(input, opts, { signal } = {}) {
44
44
  a.push("-c:v", o.videoCodec);
45
45
  if (o.audioCodec)
46
46
  a.push("-c:a", o.audioCodec);
47
+ if (o.args)
48
+ a.push(...o.args);
47
49
  args.push({
48
50
  args: a,
49
51
  ext: o.ext ?? getExtension(o.format ?? "mp4"),
package/package.json CHANGED
@@ -1,11 +1,21 @@
1
1
  {
2
2
  "name": "m4k",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "type": "module",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
7
7
  "module": "./lib/index.js",
8
8
  "license": "MIT",
9
+ "description": "Media toolkit for node, bun, and deno",
10
+ "keywords": [
11
+ "media",
12
+ "ffmpeg",
13
+ "video",
14
+ "audio",
15
+ "image",
16
+ "sharp"
17
+ ],
18
+ "author": "sv2dev",
9
19
  "scripts": {
10
20
  "prepublishOnly": "bun run build",
11
21
  "build": "tsc -b",
@@ -15,13 +25,13 @@
15
25
  "devDependencies": {
16
26
  "@ffmpeg-installer/ffmpeg": "^1.1.0",
17
27
  "tasque": "^0.1.2",
18
- "typescript": "^5.0.0"
28
+ "typescript": "^5.8.3"
19
29
  },
20
30
  "dependencies": {
21
- "@m4k/common": "^0.2.2"
31
+ "@m4k/common": "^0.2.3"
22
32
  },
23
33
  "peerDependencies": {
24
- "sharp": "^0.33.5"
34
+ "sharp": "^0.34.1"
25
35
  },
26
36
  "repository": "github:sv2dev/m4k"
27
37
  }