Add .gitignore to exclude all node packages and lock files
This commit is contained in:
Generated
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
import type { MediaParserStructureUnstable } from '../parse-result';
|
||||
import type { ParserState } from '../state/parser-state';
|
||||
export type MediaParserMetadataEntry = {
|
||||
key: string;
|
||||
value: string | number;
|
||||
trackId: number | null;
|
||||
};
|
||||
export declare const getMetadata: (state: ParserState) => MediaParserMetadataEntry[];
|
||||
export declare const hasMetadata: (structure: MediaParserStructureUnstable) => boolean;
|
||||
Generated
Vendored
+74
@@ -0,0 +1,74 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.hasMetadata = exports.getMetadata = void 0;
|
||||
const get_metadata_from_flac_1 = require("../containers/flac/get-metadata-from-flac");
|
||||
const get_metadata_from_mp3_1 = require("../containers/mp3/get-metadata-from-mp3");
|
||||
const get_metadata_from_wav_1 = require("../containers/wav/get-metadata-from-wav");
|
||||
const metadata_from_iso_1 = require("./metadata-from-iso");
|
||||
const metadata_from_matroska_1 = require("./metadata-from-matroska");
|
||||
const metadata_from_riff_1 = require("./metadata-from-riff");
|
||||
const getMetadata = (state) => {
|
||||
var _a, _b;
|
||||
const structure = state.structure.getStructure();
|
||||
if (structure.type === 'matroska') {
|
||||
return (0, metadata_from_matroska_1.getMetadataFromMatroska)(structure);
|
||||
}
|
||||
if (structure.type === 'riff') {
|
||||
return (0, metadata_from_riff_1.getMetadataFromRiff)(structure);
|
||||
}
|
||||
if (structure.type === 'transport-stream' || structure.type === 'm3u') {
|
||||
return [];
|
||||
}
|
||||
if (structure.type === 'mp3') {
|
||||
const tags = (0, get_metadata_from_mp3_1.getMetadataFromMp3)(structure);
|
||||
// Not all MP3s file have this header.
|
||||
// Internal link: https://discord.com/channels/809501355504959528/1001500302375125055/1408880907602890752
|
||||
return tags !== null && tags !== void 0 ? tags : [];
|
||||
}
|
||||
if (structure.type === 'wav') {
|
||||
return (_a = (0, get_metadata_from_wav_1.getMetadataFromWav)(structure)) !== null && _a !== void 0 ? _a : [];
|
||||
}
|
||||
if (structure.type === 'aac') {
|
||||
return [];
|
||||
}
|
||||
if (structure.type === 'flac') {
|
||||
return (_b = (0, get_metadata_from_flac_1.getMetadataFromFlac)(structure)) !== null && _b !== void 0 ? _b : [];
|
||||
}
|
||||
if (structure.type === 'iso-base-media') {
|
||||
return (0, metadata_from_iso_1.getMetadataFromIsoBase)(state);
|
||||
}
|
||||
throw new Error('Unknown container ' + structure);
|
||||
};
|
||||
exports.getMetadata = getMetadata;
|
||||
// TODO: This forces some containers to check the whole file
|
||||
// we can do this better! skip over video data
|
||||
const hasMetadata = (structure) => {
|
||||
if (structure.type === 'mp3') {
|
||||
return (0, get_metadata_from_mp3_1.getMetadataFromMp3)(structure) !== null;
|
||||
}
|
||||
if (structure.type === 'wav') {
|
||||
return (0, get_metadata_from_wav_1.getMetadataFromWav)(structure) !== null;
|
||||
}
|
||||
// M3U, Transport Stream, AAC cannot store any metadata
|
||||
if (structure.type === 'm3u' ||
|
||||
structure.type === 'transport-stream' ||
|
||||
structure.type === 'aac') {
|
||||
return true;
|
||||
}
|
||||
if (structure.type === 'flac') {
|
||||
return (0, get_metadata_from_flac_1.getMetadataFromFlac)(structure) !== null;
|
||||
}
|
||||
// The following containers (MP4, Matroska, AVI) all have mechanisms
|
||||
// to skip over video sections, and tests for it in read-metadata.test.ts
|
||||
if (structure.type === 'iso-base-media') {
|
||||
return false;
|
||||
}
|
||||
if (structure.type === 'matroska') {
|
||||
return false;
|
||||
}
|
||||
if (structure.type === 'riff') {
|
||||
return false;
|
||||
}
|
||||
throw new Error('Unknown container ' + structure);
|
||||
};
|
||||
exports.hasMetadata = hasMetadata;
|
||||
Generated
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
import type { RegularBox } from '../containers/iso-base-media/base-media-box';
|
||||
import type { ParserState } from '../state/parser-state';
|
||||
import type { MediaParserMetadataEntry } from './get-metadata';
|
||||
export declare const parseIsoMetaBox: (meta: RegularBox, trackId: number | null) => MediaParserMetadataEntry[];
|
||||
export declare const getMetadataFromIsoBase: (state: ParserState) => MediaParserMetadataEntry[];
|
||||
Generated
Vendored
+154
@@ -0,0 +1,154 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getMetadataFromIsoBase = exports.parseIsoMetaBox = void 0;
|
||||
const traversal_1 = require("../containers/iso-base-media/traversal");
|
||||
const truthy_1 = require("../truthy");
|
||||
/**
|
||||
*
|
||||
* @param ilstBox ©ART - Artist
|
||||
▪ Hex: A9 41 52 54
|
||||
2. ©alb - Album
|
||||
▪ Hex: A9 61 6C 62
|
||||
3. ©cmt - Comment
|
||||
▪ Hex: A9 63 6D 74
|
||||
4. ©day - Release Date
|
||||
▪ Hex: A9 64 61 79
|
||||
5. ©gen - Genre
|
||||
▪ Hex: A9 67 65 6E
|
||||
6. ©nam - Title
|
||||
▪ Hex: A9 6E 61 6D
|
||||
7. ©too - Encoder
|
||||
▪ Hex: A9 74 6F 6F
|
||||
8. ©wrt - Writer
|
||||
▪ Hex: A9 77 72 74
|
||||
9. ©cpy - Copyright
|
||||
▪ Hex: A9 63 70 79
|
||||
10. ©dir - Director
|
||||
▪ Hex: A9 64 69 72
|
||||
11. ©prd - Producer
|
||||
▪ Hex: A9 70 72 64
|
||||
12. ©des - Description
|
||||
▪ Hex: A9 64 65 73
|
||||
*/
|
||||
const mapToKey = (index) => {
|
||||
if (index === '�ART') {
|
||||
return 'artist';
|
||||
}
|
||||
if (index === '�alb') {
|
||||
return 'album';
|
||||
}
|
||||
if (index === '�cmt') {
|
||||
return 'comment';
|
||||
}
|
||||
if (index === '�day') {
|
||||
return 'releaseDate';
|
||||
}
|
||||
if (index === '�gen') {
|
||||
return 'genre';
|
||||
}
|
||||
if (index === '�nam') {
|
||||
return 'title';
|
||||
}
|
||||
if (index === '�too') {
|
||||
return 'encoder';
|
||||
}
|
||||
if (index === '�wrt') {
|
||||
return 'writer';
|
||||
}
|
||||
if (index === '�cpy') {
|
||||
return 'copyright';
|
||||
}
|
||||
if (index === '�dir') {
|
||||
return 'director';
|
||||
}
|
||||
if (index === '�prd') {
|
||||
return 'producer';
|
||||
}
|
||||
if (index === '�des') {
|
||||
return 'description';
|
||||
}
|
||||
return null;
|
||||
};
|
||||
const parseIlstBoxWithoutKeys = (ilstBox) => {
|
||||
return ilstBox.entries
|
||||
.map((entry) => {
|
||||
const key = mapToKey(entry.index);
|
||||
if (!key) {
|
||||
return null;
|
||||
}
|
||||
if (entry.value.type === 'unknown') {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
trackId: null,
|
||||
key,
|
||||
value: entry.value.value,
|
||||
};
|
||||
})
|
||||
.filter(truthy_1.truthy);
|
||||
};
|
||||
const parseIsoMetaBox = (meta, trackId) => {
|
||||
const ilstBox = meta.children.find((b) => b.type === 'ilst-box');
|
||||
const keysBox = meta.children.find((b) => b.type === 'keys-box');
|
||||
if (!ilstBox || !keysBox) {
|
||||
if (ilstBox) {
|
||||
return parseIlstBoxWithoutKeys(ilstBox);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
const entries = [];
|
||||
for (let i = 0; i < ilstBox.entries.length; i++) {
|
||||
const ilstEntry = ilstBox.entries[i];
|
||||
const keysEntry = keysBox.entries[i];
|
||||
if (ilstEntry.value.type !== 'unknown') {
|
||||
const value = typeof ilstEntry.value.value === 'string' &&
|
||||
ilstEntry.value.value.endsWith('\u0000')
|
||||
? ilstEntry.value.value.slice(0, -1)
|
||||
: ilstEntry.value.value;
|
||||
entries.push({
|
||||
key: keysEntry.value,
|
||||
value,
|
||||
trackId,
|
||||
});
|
||||
}
|
||||
}
|
||||
return entries;
|
||||
};
|
||||
exports.parseIsoMetaBox = parseIsoMetaBox;
|
||||
const getMetadataFromIsoBase = (state) => {
|
||||
var _a, _b;
|
||||
const moov = (0, traversal_1.getMoovBoxFromState)({
|
||||
structureState: state.structure,
|
||||
isoState: state.iso,
|
||||
mp4HeaderSegment: (_b = (_a = state.m3uPlaylistContext) === null || _a === void 0 ? void 0 : _a.mp4HeaderSegment) !== null && _b !== void 0 ? _b : null,
|
||||
mayUsePrecomputed: true,
|
||||
});
|
||||
if (!moov) {
|
||||
return [];
|
||||
}
|
||||
const traks = (0, traversal_1.getTraks)(moov);
|
||||
const meta = moov.children.find((b) => b.type === 'regular-box' && b.boxType === 'meta');
|
||||
const udta = moov.children.find((b) => b.type === 'regular-box' && b.boxType === 'udta');
|
||||
const metaInUdta = udta === null || udta === void 0 ? void 0 : udta.children.find((b) => {
|
||||
return b.type === 'regular-box' && b.boxType === 'meta';
|
||||
});
|
||||
const metaInTracks = traks
|
||||
.map((t) => {
|
||||
const metaBox = t.children.find((child) => child.type === 'regular-box' && child.boxType === 'meta');
|
||||
if (metaBox) {
|
||||
const tkhd = (0, traversal_1.getTkhdBox)(t);
|
||||
if (!tkhd) {
|
||||
throw new Error('No tkhd box found');
|
||||
}
|
||||
return (0, exports.parseIsoMetaBox)(metaBox, tkhd.trackId);
|
||||
}
|
||||
return null;
|
||||
})
|
||||
.filter(truthy_1.truthy);
|
||||
return [
|
||||
...(meta ? (0, exports.parseIsoMetaBox)(meta, null) : []),
|
||||
...(metaInUdta ? (0, exports.parseIsoMetaBox)(metaInUdta, null) : []),
|
||||
...metaInTracks.flat(1),
|
||||
];
|
||||
};
|
||||
exports.getMetadataFromIsoBase = getMetadataFromIsoBase;
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
import type { MatroskaStructure } from '../parse-result';
|
||||
import type { MediaParserMetadataEntry } from './get-metadata';
|
||||
export declare const getMetadataFromMatroska: (structure: MatroskaStructure) => MediaParserMetadataEntry[];
|
||||
Generated
Vendored
+53
@@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getMetadataFromMatroska = void 0;
|
||||
const traversal_1 = require("../containers/webm/traversal");
|
||||
const removeEndZeroes = (value) => {
|
||||
return value.endsWith('\u0000') ? removeEndZeroes(value.slice(0, -1)) : value;
|
||||
};
|
||||
const parseSimpleTagIntoEbml = (children, trackId) => {
|
||||
const tagName = children.find((c) => c.type === 'TagName');
|
||||
const tagString = children.find((c) => c.type === 'TagString');
|
||||
if (!tagName || !tagString) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
trackId,
|
||||
key: tagName.value.toLowerCase(),
|
||||
value: removeEndZeroes(tagString.value),
|
||||
};
|
||||
};
|
||||
const getMetadataFromMatroska = (structure) => {
|
||||
var _a;
|
||||
const entries = [];
|
||||
for (const segment of structure.boxes) {
|
||||
if (segment.type !== 'Segment') {
|
||||
continue;
|
||||
}
|
||||
const tags = segment.value.filter((s) => s.type === 'Tags');
|
||||
for (const tag of tags) {
|
||||
for (const child of tag.value) {
|
||||
if (child.type !== 'Tag') {
|
||||
continue;
|
||||
}
|
||||
let trackId = null;
|
||||
const target = child.value.find((c) => c.type === 'Targets');
|
||||
if (target) {
|
||||
const tagTrackId = (_a = target.value.find((c) => c.type === 'TagTrackUID')) === null || _a === void 0 ? void 0 : _a.value;
|
||||
if (tagTrackId) {
|
||||
trackId = (0, traversal_1.getTrackWithUid)(segment, tagTrackId);
|
||||
}
|
||||
}
|
||||
const simpleTags = child.value.filter((s) => s.type === 'SimpleTag');
|
||||
for (const simpleTag of simpleTags) {
|
||||
const parsed = parseSimpleTagIntoEbml(simpleTag.value, trackId);
|
||||
if (parsed) {
|
||||
entries.push(parsed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return entries;
|
||||
};
|
||||
exports.getMetadataFromMatroska = getMetadataFromMatroska;
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
import type { RiffStructure } from '../containers/riff/riff-box';
|
||||
import type { MediaParserMetadataEntry } from './get-metadata';
|
||||
export declare const getMetadataFromRiff: (structure: RiffStructure) => MediaParserMetadataEntry[];
|
||||
skills/remotion-prompt-video/node_modules/@remotion/media-parser/dist/metadata/metadata-from-riff.js
Generated
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getMetadataFromRiff = void 0;
|
||||
const truthy_1 = require("../truthy");
|
||||
const getMetadataFromRiff = (structure) => {
|
||||
const boxes = structure.boxes.find((b) => b.type === 'list-box' && b.listType === 'INFO');
|
||||
if (!boxes) {
|
||||
return [];
|
||||
}
|
||||
const { children } = boxes;
|
||||
return children
|
||||
.map((child) => {
|
||||
if (child.type !== 'isft-box') {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
trackId: null,
|
||||
key: 'encoder',
|
||||
value: child.software,
|
||||
};
|
||||
})
|
||||
.filter(truthy_1.truthy);
|
||||
};
|
||||
exports.getMetadataFromRiff = getMetadataFromRiff;
|
||||
Reference in New Issue
Block a user