@storyteller-platform/audiobook 0.3.0 → 0.3.3
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.
- package/dist/ffmpeg.cjs +10 -5
- package/dist/ffmpeg.d.cts +2 -2
- package/dist/ffmpeg.d.ts +2 -2
- package/dist/ffmpeg.js +10 -5
- package/package.json +1 -1
package/dist/ffmpeg.cjs
CHANGED
|
@@ -90,6 +90,7 @@ function lookup(codecName) {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
async function getTrackMetadata(path) {
|
|
93
|
+
var _a, _b;
|
|
93
94
|
const stdout = await execCmd(
|
|
94
95
|
`ffprobe -i ${quotePath(path)} -v quiet -show_format -show_chapters -show_streams -output_format json`
|
|
95
96
|
);
|
|
@@ -100,10 +101,10 @@ async function getTrackMetadata(path) {
|
|
|
100
101
|
(stream) => !!stream.disposition.attached_pic
|
|
101
102
|
);
|
|
102
103
|
const attachedPic = attachedPicStream && {
|
|
103
|
-
name: attachedPicStream.tags.title,
|
|
104
|
+
name: (_a = attachedPicStream.tags) == null ? void 0 : _a.title,
|
|
104
105
|
mimeType: lookup(attachedPicStream.codec_name),
|
|
105
|
-
kind:
|
|
106
|
-
description: attachedPicStream.tags.comment,
|
|
106
|
+
kind: "coverFront",
|
|
107
|
+
description: (_b = attachedPicStream.tags) == null ? void 0 : _b.comment,
|
|
107
108
|
data: await execCmdBuffer("ffmpeg", [
|
|
108
109
|
"-nostdin",
|
|
109
110
|
"-i",
|
|
@@ -149,6 +150,7 @@ async function getTrackMetadata(path) {
|
|
|
149
150
|
};
|
|
150
151
|
}
|
|
151
152
|
async function writeTrackMetadata(path, metadata, attachedPic) {
|
|
153
|
+
const args = [];
|
|
152
154
|
const metadataArgs = [];
|
|
153
155
|
if (metadata.title) {
|
|
154
156
|
metadataArgs.push(`-metadata title="${escapeQuotes(metadata.title)}"`);
|
|
@@ -205,7 +207,9 @@ async function writeTrackMetadata(path, metadata, attachedPic) {
|
|
|
205
207
|
`storyteller-platform-audiobook-${(0, import_node_crypto.randomUUID)()}.${imageExt}`
|
|
206
208
|
);
|
|
207
209
|
await (0, import_promises.writeFile)(picPath, attachedPic.data);
|
|
208
|
-
|
|
210
|
+
args.push(`-i ${quotePath(picPath)}`);
|
|
211
|
+
args.push(`-map 0:a -map 1:v`);
|
|
212
|
+
args.push(`-disposition:v:0 attached_pic`);
|
|
209
213
|
if (attachedPic.name) {
|
|
210
214
|
metadataArgs.push(
|
|
211
215
|
`-metadata:s:v title="${escapeQuotes(attachedPic.name)}"`
|
|
@@ -217,7 +221,8 @@ async function writeTrackMetadata(path, metadata, attachedPic) {
|
|
|
217
221
|
);
|
|
218
222
|
}
|
|
219
223
|
}
|
|
220
|
-
|
|
224
|
+
args.push(...metadataArgs);
|
|
225
|
+
const cmd = `ffmpeg -i ${quotePath(path)} ${args.join(" ")} -codec copy "${tmpPath}"`;
|
|
221
226
|
await execCmd(cmd);
|
|
222
227
|
await (0, import_promises.cp)(tmpPath, path, { force: true });
|
|
223
228
|
} finally {
|
package/dist/ffmpeg.d.cts
CHANGED
|
@@ -11,8 +11,8 @@ type AttachedPic = {
|
|
|
11
11
|
data: Uint8Array;
|
|
12
12
|
mimeType: string;
|
|
13
13
|
kind: "coverFront" | "coverBack" | "unknown";
|
|
14
|
-
name?: string;
|
|
15
|
-
description?: string;
|
|
14
|
+
name?: string | undefined;
|
|
15
|
+
description?: string | undefined;
|
|
16
16
|
};
|
|
17
17
|
declare function getTrackMetadata(path: string): Promise<{
|
|
18
18
|
duration: number;
|
package/dist/ffmpeg.d.ts
CHANGED
|
@@ -11,8 +11,8 @@ type AttachedPic = {
|
|
|
11
11
|
data: Uint8Array;
|
|
12
12
|
mimeType: string;
|
|
13
13
|
kind: "coverFront" | "coverBack" | "unknown";
|
|
14
|
-
name?: string;
|
|
15
|
-
description?: string;
|
|
14
|
+
name?: string | undefined;
|
|
15
|
+
description?: string | undefined;
|
|
16
16
|
};
|
|
17
17
|
declare function getTrackMetadata(path: string): Promise<{
|
|
18
18
|
duration: number;
|
package/dist/ffmpeg.js
CHANGED
|
@@ -63,6 +63,7 @@ function lookup(codecName) {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
async function getTrackMetadata(path) {
|
|
66
|
+
var _a, _b;
|
|
66
67
|
const stdout = await execCmd(
|
|
67
68
|
`ffprobe -i ${quotePath(path)} -v quiet -show_format -show_chapters -show_streams -output_format json`
|
|
68
69
|
);
|
|
@@ -73,10 +74,10 @@ async function getTrackMetadata(path) {
|
|
|
73
74
|
(stream) => !!stream.disposition.attached_pic
|
|
74
75
|
);
|
|
75
76
|
const attachedPic = attachedPicStream && {
|
|
76
|
-
name: attachedPicStream.tags.title,
|
|
77
|
+
name: (_a = attachedPicStream.tags) == null ? void 0 : _a.title,
|
|
77
78
|
mimeType: lookup(attachedPicStream.codec_name),
|
|
78
|
-
kind:
|
|
79
|
-
description: attachedPicStream.tags.comment,
|
|
79
|
+
kind: "coverFront",
|
|
80
|
+
description: (_b = attachedPicStream.tags) == null ? void 0 : _b.comment,
|
|
80
81
|
data: await execCmdBuffer("ffmpeg", [
|
|
81
82
|
"-nostdin",
|
|
82
83
|
"-i",
|
|
@@ -122,6 +123,7 @@ async function getTrackMetadata(path) {
|
|
|
122
123
|
};
|
|
123
124
|
}
|
|
124
125
|
async function writeTrackMetadata(path, metadata, attachedPic) {
|
|
126
|
+
const args = [];
|
|
125
127
|
const metadataArgs = [];
|
|
126
128
|
if (metadata.title) {
|
|
127
129
|
metadataArgs.push(`-metadata title="${escapeQuotes(metadata.title)}"`);
|
|
@@ -178,7 +180,9 @@ async function writeTrackMetadata(path, metadata, attachedPic) {
|
|
|
178
180
|
`storyteller-platform-audiobook-${randomUUID()}.${imageExt}`
|
|
179
181
|
);
|
|
180
182
|
await writeFile(picPath, attachedPic.data);
|
|
181
|
-
|
|
183
|
+
args.push(`-i ${quotePath(picPath)}`);
|
|
184
|
+
args.push(`-map 0:a -map 1:v`);
|
|
185
|
+
args.push(`-disposition:v:0 attached_pic`);
|
|
182
186
|
if (attachedPic.name) {
|
|
183
187
|
metadataArgs.push(
|
|
184
188
|
`-metadata:s:v title="${escapeQuotes(attachedPic.name)}"`
|
|
@@ -190,7 +194,8 @@ async function writeTrackMetadata(path, metadata, attachedPic) {
|
|
|
190
194
|
);
|
|
191
195
|
}
|
|
192
196
|
}
|
|
193
|
-
|
|
197
|
+
args.push(...metadataArgs);
|
|
198
|
+
const cmd = `ffmpeg -i ${quotePath(path)} ${args.join(" ")} -codec copy "${tmpPath}"`;
|
|
194
199
|
await execCmd(cmd);
|
|
195
200
|
await cp(tmpPath, path, { force: true });
|
|
196
201
|
} finally {
|