Comparing version 4.1.0 to 4.2.0
@@ -0,1 +1,3 @@ | ||
declare type TransformationMatrix = [number, number, number, number, number, number, number, number, number]; | ||
declare interface VideoOptions { | ||
@@ -15,5 +17,5 @@ /** | ||
/** | ||
* The clockwise rotation of the video in degrees. | ||
* The clockwise rotation of the video in degrees, or a transformation matrix. | ||
*/ | ||
rotation?: 0 | 90 | 180 | 270 | ||
rotation?: 0 | 90 | 180 | 270 | TransformationMatrix | ||
} | ||
@@ -204,3 +206,10 @@ | ||
export { Muxer, MuxerOptions, ArrayBufferTarget, StreamTarget, FileSystemWritableFileStreamTarget }; | ||
export as namespace Mp4Muxer; | ||
export { | ||
Muxer, | ||
MuxerOptions, | ||
ArrayBufferTarget, | ||
StreamTarget, | ||
FileSystemWritableFileStreamTarget, | ||
TransformationMatrix | ||
}; | ||
export as namespace Mp4Muxer; |
@@ -240,2 +240,8 @@ "use strict"; | ||
let u32OrU64 = needsU64 ? u64 : u32; | ||
let matrix; | ||
if (track.info.type === "video") { | ||
matrix = typeof track.info.rotation === "number" ? rotationMatrix(track.info.rotation) : track.info.rotation; | ||
} else { | ||
matrix = IDENTITY_MATRIX; | ||
} | ||
return fullBox("tkhd", +needsU64, 3, [ | ||
@@ -262,3 +268,3 @@ u32OrU64(creationTime), | ||
// Reserved | ||
matrixToBytes(rotationMatrix(track.info.type === "video" ? track.info.rotation : 0)), | ||
matrixToBytes(matrix), | ||
// Matrix | ||
@@ -1236,4 +1242,7 @@ fixed_16_16(track.info.type === "video" ? track.info.width : 0), | ||
} | ||
if (options.video.rotation !== void 0 && ![0, 90, 180, 270].includes(options.video.rotation)) { | ||
throw new Error(`Invalid video rotation: ${options.video.rotation}. Has to be 0, 90, 180 or 270.`); | ||
const videoRotation = options.video.rotation; | ||
if (typeof videoRotation === "number" && ![0, 90, 180, 270].includes(videoRotation)) { | ||
throw new Error(`Invalid video rotation: ${videoRotation}. Has to be 0, 90, 180 or 270.`); | ||
} else if (Array.isArray(videoRotation) && (videoRotation.length !== 9 || videoRotation.some((value) => typeof value !== "number"))) { | ||
throw new Error(`Invalid video transformation matrix: ${videoRotation.join()}`); | ||
} | ||
@@ -1240,0 +1249,0 @@ } |
{ | ||
"name": "mp4-muxer", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"description": "MP4 multiplexer in pure TypeScript with support for WebCodecs API, video & audio.", | ||
@@ -5,0 +5,0 @@ "main": "./build/mp4-muxer.js", |
@@ -97,3 +97,5 @@ # mp4-muxer - JavaScript MP4 multiplexer | ||
height: number, | ||
rotation?: 0 | 90 | 180 | 270 // Adds rotation metadata to the file | ||
// Adds rotation metadata to the file | ||
rotation?: 0 | 90 | 180 | 270 | TransformationMatrix | ||
}, | ||
@@ -216,4 +218,4 @@ | ||
output with no change in memory footprint. | ||
- `'fragmented'`: Produces a _fragmented MP4 (fMP4)_ file, evenly placing sample metadata throughout the file by grouping | ||
it into "fragments" (short sections of media), while placing general metadata at the beginning of the file. | ||
- `'fragmented'`: Produces a _fragmented MP4 (fMP4)_ file, evenly placing sample metadata throughout the file by | ||
grouping it into "fragments" (short sections of media), while placing general metadata at the beginning of the file. | ||
Fragmented files are ideal for streaming, as they are optimized for random access with minimal to no seeking. | ||
@@ -349,2 +351,2 @@ Furthermore, they remain lightweight to create no matter how large the file becomes, as they don't require media to | ||
code into the `build` directory. Run `npm run check` to run the TypeScript type checker, and `npm run lint` to run | ||
ESLint. | ||
ESLint. |
Sorry, the diff of this file is not supported yet
139911
3319
350