@invintusmedia/tomp4 1.0.3 → 1.0.4
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/tomp4.js +2 -2
- package/package.json +6 -3
- package/src/index.js +17 -2
package/dist/tomp4.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* toMp4.js v1.0.
|
|
2
|
+
* toMp4.js v1.0.4
|
|
3
3
|
* Convert MPEG-TS and fMP4 to standard MP4
|
|
4
4
|
* https://github.com/TVWIT/toMp4.js
|
|
5
5
|
* MIT License
|
|
@@ -1751,7 +1751,7 @@
|
|
|
1751
1751
|
toMp4.isMpegTs = isMpegTs;
|
|
1752
1752
|
toMp4.isFmp4 = isFmp4;
|
|
1753
1753
|
toMp4.isStandardMp4 = isStandardMp4;
|
|
1754
|
-
toMp4.version = '1.0.
|
|
1754
|
+
toMp4.version = '1.0.4';
|
|
1755
1755
|
|
|
1756
1756
|
return toMp4;
|
|
1757
1757
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@invintusmedia/tomp4",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Convert MPEG-TS and
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": "Convert MPEG-TS, fMP4, and HLS streams to MP4 with clipping support - pure JavaScript, zero dependencies",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"module": "src/index.js",
|
|
7
7
|
"types": "src/index.d.ts",
|
|
@@ -39,7 +39,10 @@
|
|
|
39
39
|
"converter",
|
|
40
40
|
"transmux",
|
|
41
41
|
"hls",
|
|
42
|
-
"streaming"
|
|
42
|
+
"streaming",
|
|
43
|
+
"clip",
|
|
44
|
+
"trim",
|
|
45
|
+
"cut"
|
|
43
46
|
],
|
|
44
47
|
"author": "Invintus Media",
|
|
45
48
|
"license": "MIT",
|
package/src/index.js
CHANGED
|
@@ -269,9 +269,24 @@ async function toMp4(input, options = {}) {
|
|
|
269
269
|
throw new Error('Input must be a URL string, HlsStream, Uint8Array, ArrayBuffer, or Blob');
|
|
270
270
|
}
|
|
271
271
|
|
|
272
|
+
// Adjust clip times if we downloaded HLS with a time range
|
|
273
|
+
// The downloaded segments have been normalized to start at 0,
|
|
274
|
+
// so we need to adjust the requested clip times accordingly
|
|
275
|
+
let convertOptions = { ...options };
|
|
276
|
+
if (data._hlsTimeRange && (options.startTime !== undefined || options.endTime !== undefined)) {
|
|
277
|
+
const segmentStart = data._hlsTimeRange.actualStart;
|
|
278
|
+
if (options.startTime !== undefined) {
|
|
279
|
+
convertOptions.startTime = Math.max(0, options.startTime - segmentStart);
|
|
280
|
+
}
|
|
281
|
+
if (options.endTime !== undefined) {
|
|
282
|
+
convertOptions.endTime = options.endTime - segmentStart;
|
|
283
|
+
}
|
|
284
|
+
log(`Adjusted clip: ${convertOptions.startTime?.toFixed(2) || 0}s - ${convertOptions.endTime?.toFixed(2) || '∞'}s (offset: -${segmentStart.toFixed(2)}s)`);
|
|
285
|
+
}
|
|
286
|
+
|
|
272
287
|
// Convert
|
|
273
288
|
log('Converting...');
|
|
274
|
-
const mp4Data = convertData(data,
|
|
289
|
+
const mp4Data = convertData(data, convertOptions);
|
|
275
290
|
|
|
276
291
|
return new Mp4Result(mp4Data, filename);
|
|
277
292
|
}
|
|
@@ -293,7 +308,7 @@ toMp4.isHlsUrl = isHlsUrl;
|
|
|
293
308
|
toMp4.analyze = analyzeTsData;
|
|
294
309
|
|
|
295
310
|
// Version (injected at build time for dist, read from package.json for ESM)
|
|
296
|
-
toMp4.version = '1.0.
|
|
311
|
+
toMp4.version = '1.0.4';
|
|
297
312
|
|
|
298
313
|
// Export
|
|
299
314
|
export {
|