music-metadata 8.0.0 → 8.1.0

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.
Files changed (84) hide show
  1. package/README.md +4 -3
  2. package/lib/ParserFactory.d.ts +48 -0
  3. package/lib/aiff/AiffParser.d.ts +15 -0
  4. package/lib/aiff/AiffParser.js +13 -1
  5. package/lib/aiff/AiffTagMap.d.ts +4 -0
  6. package/lib/aiff/AiffTagMap.js +16 -0
  7. package/lib/aiff/AiffToken.d.ts +23 -0
  8. package/lib/apev2/APEv2Parser.d.ts +30 -0
  9. package/lib/apev2/APEv2TagMapper.d.ts +4 -0
  10. package/lib/apev2/APEv2Token.d.ts +100 -0
  11. package/lib/asf/AsfObject.d.ts +320 -0
  12. package/lib/asf/AsfParser.d.ts +17 -0
  13. package/lib/asf/AsfTagMapper.d.ts +7 -0
  14. package/lib/asf/AsfUtil.d.ts +14 -0
  15. package/lib/asf/GUID.d.ts +84 -0
  16. package/lib/common/BasicParser.d.ts +17 -0
  17. package/lib/common/CaseInsensitiveTagMap.d.ts +10 -0
  18. package/lib/common/CombinedTagMapper.d.ts +19 -0
  19. package/lib/common/CombinedTagMapper.js +3 -1
  20. package/lib/common/FourCC.d.ts +6 -0
  21. package/lib/common/FourCC.js +2 -5
  22. package/lib/common/GenericTagMapper.d.ts +51 -0
  23. package/lib/common/GenericTagTypes.d.ts +33 -0
  24. package/lib/common/MetadataCollector.d.ts +76 -0
  25. package/lib/common/MetadataCollector.js +2 -2
  26. package/lib/common/RandomFileReader.d.ts +22 -0
  27. package/lib/common/RandomUint8ArrayReader.d.ts +18 -0
  28. package/lib/common/Util.d.ts +57 -0
  29. package/lib/core.d.ts +48 -0
  30. package/lib/dsdiff/DsdiffParser.d.ts +14 -0
  31. package/lib/dsdiff/DsdiffToken.d.ts +9 -0
  32. package/lib/dsf/DsfChunk.d.ts +86 -0
  33. package/lib/dsf/DsfParser.d.ts +9 -0
  34. package/lib/flac/FlacParser.d.ts +28 -0
  35. package/lib/id3v1/ID3v1Parser.d.ts +13 -0
  36. package/lib/id3v1/ID3v1TagMap.d.ts +4 -0
  37. package/lib/id3v2/AbstractID3Parser.d.ts +17 -0
  38. package/lib/id3v2/FrameParser.d.ts +31 -0
  39. package/lib/id3v2/ID3v22TagMapper.d.ts +9 -0
  40. package/lib/id3v2/ID3v24TagMapper.d.ts +14 -0
  41. package/lib/id3v2/ID3v2Parser.d.ts +28 -0
  42. package/lib/id3v2/ID3v2Token.d.ts +73 -0
  43. package/lib/iff/index.d.ts +33 -0
  44. package/lib/index.d.ts +21 -0
  45. package/lib/lyrics3/Lyrics3.d.ts +3 -0
  46. package/lib/matroska/MatroskaDtd.d.ts +8 -0
  47. package/lib/matroska/MatroskaParser.d.ts +37 -0
  48. package/lib/matroska/MatroskaTagMapper.d.ts +4 -0
  49. package/lib/matroska/types.d.ts +175 -0
  50. package/lib/mp4/Atom.d.ts +16 -0
  51. package/lib/mp4/AtomToken.d.ts +395 -0
  52. package/lib/mp4/MP4Parser.d.ts +30 -0
  53. package/lib/mp4/MP4TagMapper.d.ts +5 -0
  54. package/lib/mpeg/ExtendedLameHeader.d.ts +27 -0
  55. package/lib/mpeg/MpegParser.d.ts +49 -0
  56. package/lib/mpeg/ReplayGainDataFormat.d.ts +55 -0
  57. package/lib/mpeg/XingTag.d.ts +45 -0
  58. package/lib/musepack/index.d.ts +5 -0
  59. package/lib/musepack/sv7/BitReader.d.ts +13 -0
  60. package/lib/musepack/sv7/MpcSv7Parser.d.ts +8 -0
  61. package/lib/musepack/sv7/StreamVersion7.d.ts +28 -0
  62. package/lib/musepack/sv8/MpcSv8Parser.d.ts +6 -0
  63. package/lib/musepack/sv8/StreamVersion8.d.ts +40 -0
  64. package/lib/ogg/Ogg.d.ts +72 -0
  65. package/lib/ogg/OggParser.d.ts +23 -0
  66. package/lib/ogg/opus/Opus.d.ts +48 -0
  67. package/lib/ogg/opus/OpusParser.d.ts +25 -0
  68. package/lib/ogg/speex/Speex.d.ts +36 -0
  69. package/lib/ogg/speex/SpeexParser.d.ts +22 -0
  70. package/lib/ogg/theora/Theora.d.ts +20 -0
  71. package/lib/ogg/theora/TheoraParser.d.ts +28 -0
  72. package/lib/ogg/vorbis/Vorbis.d.ts +69 -0
  73. package/lib/ogg/vorbis/VorbisDecoder.d.ts +12 -0
  74. package/lib/ogg/vorbis/VorbisParser.d.ts +36 -0
  75. package/lib/ogg/vorbis/VorbisTagMapper.d.ts +7 -0
  76. package/lib/riff/RiffChunk.d.ts +16 -0
  77. package/lib/riff/RiffInfoTagMap.d.ts +10 -0
  78. package/lib/type.d.ts +593 -0
  79. package/lib/wav/BwfChunk.d.ts +17 -0
  80. package/lib/wav/WaveChunk.d.ts +64 -0
  81. package/lib/wav/WaveParser.d.ts +24 -0
  82. package/lib/wavpack/WavPackParser.d.ts +14 -0
  83. package/lib/wavpack/WavPackToken.d.ts +64 -0
  84. package/package.json +13 -13
package/README.md CHANGED
@@ -55,6 +55,7 @@ Following tag header formats are supported:
55
55
  * [iTunes](https://github.com/sergiomb2/libmp4v2/wiki/iTunesMetadata)
56
56
  * [RIFF](https://wikipedia.org/wiki/Resource_Interchange_File_Format)/INFO
57
57
  * [Vorbis comment](https://wikipedia.org/wiki/Vorbis_comment)
58
+ * [AIFF](https://wikipedia.org/wiki/Audio_Interchange_File_Format)
58
59
 
59
60
  It allows many tags to be accessed in audio format, and tag format independent way.
60
61
 
@@ -79,7 +80,7 @@ Support for encoding / format details:
79
80
 
80
81
  Module: version 8 migrated from [CommonJS](https://en.wikipedia.org/wiki/CommonJS) to [pure ECMAScript Module (ESM)](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).
81
82
  JavaScript is compliant with [ECMAScript 2019 (ES10)](https://en.wikipedia.org/wiki/ECMAScript#10th_Edition_%E2%80%93_ECMAScript_2019).
82
- Requires Node.js ≥ 12.20 engine.
83
+ Requires Node.js ≥ 14.13.1 engine.
83
84
 
84
85
  ### Browser Support
85
86
 
@@ -91,8 +92,8 @@ import * as mm from 'music-metadata/lib/core';
91
92
  ```
92
93
 
93
94
  | function | `music-metadata` | `music-metadata/lib/core` |
94
- | -----------------------------------------------------| ---------------------------|----------------------------|
95
- | [`parseBuffer`](#parsefile-function) | ✓ | ✓ |
95
+ |------------------------------------------------------| ---------------------------|----------------------------|
96
+ | [`parseBuffer`](#parsebuffer-function) | ✓ | ✓ |
96
97
  | [`parseStream`](#parsestream-function) * | ✓ | ✓ |
97
98
  | [`parseFromTokenizer`](#parsefromtokenizer-function) | ✓ | ✓ |
98
99
  | [`parseFile`](#parsefile-function) | ✓ | |
@@ -0,0 +1,48 @@
1
+ import { INativeMetadataCollector } from './common/MetadataCollector.js';
2
+ import { IOptions, IAudioMetadata, ParserType } from './type.js';
3
+ import { ITokenizer } from 'strtok3/core';
4
+ export interface ITokenParser {
5
+ /**
6
+ * Initialize parser with output (metadata), input (tokenizer) & parsing options (options).
7
+ * @param metadata - Output
8
+ * @param tokenizer - Input
9
+ * @param options - Parsing options
10
+ */
11
+ init(metadata: INativeMetadataCollector, tokenizer: ITokenizer, options: IOptions): ITokenParser;
12
+ /**
13
+ * Parse audio track.
14
+ * Called after init(...).
15
+ * @returns Promise
16
+ */
17
+ parse(): Promise<void>;
18
+ }
19
+ export declare function parseHttpContentType(contentType: string): {
20
+ type: string;
21
+ subtype: string;
22
+ suffix?: string;
23
+ parameters: {
24
+ [id: string]: string;
25
+ };
26
+ };
27
+ export declare class ParserFactory {
28
+ /**
29
+ * Parse metadata from tokenizer
30
+ * @param tokenizer - Tokenizer
31
+ * @param opts - Options
32
+ * @returns Native metadata
33
+ */
34
+ static parseOnContentType(tokenizer: ITokenizer, opts: IOptions): Promise<IAudioMetadata>;
35
+ static parse(tokenizer: ITokenizer, parserId: ParserType, opts: IOptions): Promise<IAudioMetadata>;
36
+ /**
37
+ * @param filePath - Path, filename or extension to audio file
38
+ * @return Parser sub-module name
39
+ */
40
+ static getParserIdForExtension(filePath: string): ParserType;
41
+ static loadParser(moduleName: ParserType): Promise<ITokenParser>;
42
+ private static getExtension;
43
+ /**
44
+ * @param httpContentType - HTTP Content-Type, extension, path or filename
45
+ * @returns Parser sub-module name
46
+ */
47
+ private static getParserIdForMimeType;
48
+ }
@@ -0,0 +1,15 @@
1
+ import { BasicParser } from '../common/BasicParser.js';
2
+ import * as iff from '../iff/index.js';
3
+ /**
4
+ * AIFF - Audio Interchange File Format
5
+ *
6
+ * Ref:
7
+ * - http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/AIFF/AIFF.html
8
+ * - http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/AIFF/Docs/AIFF-1.3.pdf
9
+ */
10
+ export declare class AIFFParser extends BasicParser {
11
+ private isCompressed;
12
+ parse(): Promise<void>;
13
+ readData(header: iff.IChunkHeader): Promise<number>;
14
+ readTextChunk(header: iff.IChunkHeader): Promise<number>;
15
+ }
@@ -48,7 +48,6 @@ export class AIFFParser extends BasicParser {
48
48
  while (!this.tokenizer.fileInfo.size || this.tokenizer.fileInfo.size - this.tokenizer.position >= iff.Header.len) {
49
49
  debug('Reading AIFF chunk at offset=' + this.tokenizer.position);
50
50
  const chunkHeader = await this.tokenizer.readToken(iff.Header);
51
- debug(`Chunk id=${chunkHeader.chunkID}`);
52
51
  const nextChunk = 2 * Math.round(chunkHeader.chunkSize / 2);
53
52
  const bytesRead = await this.readData(chunkHeader);
54
53
  await this.tokenizer.ignore(nextChunk - bytesRead);
@@ -85,8 +84,21 @@ export class AIFFParser extends BasicParser {
85
84
  this.metadata.setFormat('bitrate', 8 * header.chunkSize / this.metadata.format.duration);
86
85
  }
87
86
  return 0;
87
+ case 'NAME': // Sample name chunk
88
+ case 'AUTH': // Author chunk
89
+ case '(c) ': // Copyright chunk
90
+ case 'ANNO': // Annotation chunk
91
+ return this.readTextChunk(header);
88
92
  default:
93
+ debug(`Ignore chunk id=${header.chunkID}, size=${header.chunkSize}`);
89
94
  return 0;
90
95
  }
91
96
  }
97
+ async readTextChunk(header) {
98
+ const value = await this.tokenizer.readToken(new Token.StringType(header.chunkSize, 'ascii'));
99
+ value.split('\0').map(v => v.trim()).filter(v => v && v.length > 0).forEach(v => {
100
+ this.metadata.addTag('AIFF', header.chunkID, v.trim());
101
+ });
102
+ return header.chunkSize;
103
+ }
92
104
  }
@@ -0,0 +1,4 @@
1
+ import { CommonTagMapper } from '../common/GenericTagMapper.js';
2
+ export declare class AiffTagMapper extends CommonTagMapper {
3
+ constructor();
4
+ }
@@ -0,0 +1,16 @@
1
+ import { CommonTagMapper } from '../common/GenericTagMapper.js';
2
+ /**
3
+ * ID3v1 tag mappings
4
+ */
5
+ const tagMap = {
6
+ NAME: 'title',
7
+ AUTH: 'artist',
8
+ '(c) ': 'copyright',
9
+ ANNO: 'comment'
10
+ };
11
+ export class AiffTagMapper extends CommonTagMapper {
12
+ constructor() {
13
+ super(['AIFF'], tagMap);
14
+ }
15
+ }
16
+ //# sourceMappingURL=AiffTagMap.js.map
@@ -0,0 +1,23 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { Buffer } from 'node:buffer';
3
+ import * as iff from '../iff/index.js';
4
+ import { IGetToken } from 'strtok3';
5
+ /**
6
+ * The Common Chunk.
7
+ * Describes fundamental parameters of the waveform data such as sample rate, bit resolution, and how many channels of
8
+ * digital audio are stored in the FORM AIFF.
9
+ */
10
+ export interface ICommon {
11
+ numChannels: number;
12
+ numSampleFrames: number;
13
+ sampleSize: number;
14
+ sampleRate: number;
15
+ compressionType?: string;
16
+ compressionName?: string;
17
+ }
18
+ export declare class Common implements IGetToken<ICommon> {
19
+ private isAifc;
20
+ len: number;
21
+ constructor(header: iff.IChunkHeader, isAifc: boolean);
22
+ get(buf: Buffer, off: number): ICommon;
23
+ }
@@ -0,0 +1,30 @@
1
+ import * as strtok3 from 'strtok3/core';
2
+ import { IOptions, IRandomReader, IApeHeader } from '../type.js';
3
+ import { INativeMetadataCollector } from '../common/MetadataCollector.js';
4
+ import { BasicParser } from '../common/BasicParser.js';
5
+ import { IFooter, IHeader } from './APEv2Token.js';
6
+ export declare class APEv2Parser extends BasicParser {
7
+ static tryParseApeHeader(metadata: INativeMetadataCollector, tokenizer: strtok3.ITokenizer, options: IOptions): Promise<void>;
8
+ /**
9
+ * Calculate the media file duration
10
+ * @param ah ApeHeader
11
+ * @return {number} duration in seconds
12
+ */
13
+ static calculateDuration(ah: IHeader): number;
14
+ /**
15
+ * Calculates the APEv1 / APEv2 first field offset
16
+ * @param reader
17
+ * @param offset
18
+ */
19
+ static findApeFooterOffset(reader: IRandomReader, offset: number): Promise<IApeHeader>;
20
+ private static parseTagFooter;
21
+ private ape;
22
+ /**
23
+ * Parse APEv1 / APEv2 header if header signature found
24
+ */
25
+ tryParseApeHeader(): Promise<void>;
26
+ parse(): Promise<void>;
27
+ parseTags(footer: IFooter): Promise<void>;
28
+ private parseDescriptorExpansion;
29
+ private parseHeader;
30
+ }
@@ -0,0 +1,4 @@
1
+ import { CaseInsensitiveTagMap } from '../common/CaseInsensitiveTagMap.js';
2
+ export declare class APEv2TagMapper extends CaseInsensitiveTagMap {
3
+ constructor();
4
+ }
@@ -0,0 +1,100 @@
1
+ import * as Token from 'token-types';
2
+ import { IGetToken } from 'strtok3/core';
3
+ /**
4
+ * APETag versionIndex history / supported formats
5
+ *
6
+ * 1.0 (1000) - Original APE tag spec. Fully supported by this code.
7
+ * 2.0 (2000) - Refined APE tag spec (better streaming support, UTF StringEncoding). Fully supported by this code.
8
+ *
9
+ * Notes:
10
+ * - also supports reading of ID3v1.1 tags
11
+ * - all saving done in the APE Tag format using CURRENT_APE_TAG_VERSION
12
+ *
13
+ * APE File Format Overview: (pieces in order -- only valid for the latest versionIndex APE files)
14
+ *
15
+ * JUNK - any amount of "junk" before the APE_DESCRIPTOR (so people that put ID3v2 tags on the files aren't hosed)
16
+ * APE_DESCRIPTOR - defines the sizes (and offsets) of all the pieces, as well as the MD5 checksum
17
+ * APE_HEADER - describes all of the necessary information about the APE file
18
+ * SEEK TABLE - the table that represents seek offsets [optional]
19
+ * HEADER DATA - the pre-audio data from the original file [optional]
20
+ * APE FRAMES - the actual compressed audio (broken into frames for seekability)
21
+ * TERMINATING DATA - the post-audio data from the original file [optional]
22
+ * TAG - describes all the properties of the file [optional]
23
+ */
24
+ export interface IDescriptor {
25
+ ID: string;
26
+ version: number;
27
+ descriptorBytes: number;
28
+ headerBytes: number;
29
+ seekTableBytes: number;
30
+ headerDataBytes: number;
31
+ apeFrameDataBytes: number;
32
+ apeFrameDataBytesHigh: number;
33
+ terminatingDataBytes: number;
34
+ fileMD5: Uint8Array;
35
+ }
36
+ /**
37
+ * APE_HEADER: describes all of the necessary information about the APE file
38
+ */
39
+ export interface IHeader {
40
+ compressionLevel: number;
41
+ formatFlags: number;
42
+ blocksPerFrame: number;
43
+ finalFrameBlocks: number;
44
+ totalFrames: number;
45
+ bitsPerSample: number;
46
+ channel: number;
47
+ sampleRate: number;
48
+ }
49
+ export interface IFooter {
50
+ ID: string;
51
+ version: number;
52
+ size: number;
53
+ fields: number;
54
+ flags: ITagFlags;
55
+ }
56
+ export declare enum DataType {
57
+ text_utf8 = 0,
58
+ binary = 1,
59
+ external_info = 2,
60
+ reserved = 3
61
+ }
62
+ /**
63
+ * APE_DESCRIPTOR: defines the sizes (and offsets) of all the pieces, as well as the MD5 checksum
64
+ */
65
+ export declare const DescriptorParser: IGetToken<IDescriptor>;
66
+ /**
67
+ * APE_HEADER: describes all of the necessary information about the APE file
68
+ */
69
+ export declare const Header: IGetToken<IHeader>;
70
+ /**
71
+ * APE Tag Header/Footer Version 2.0
72
+ * TAG: describes all the properties of the file [optional]
73
+ */
74
+ export declare const TagFooter: IGetToken<IFooter>;
75
+ /**
76
+ * APE Tag v2.0 Item Header
77
+ */
78
+ export interface ITagItemHeader {
79
+ size: number;
80
+ flags: ITagFlags;
81
+ }
82
+ /**
83
+ * APE Tag v2.0 Item Header
84
+ */
85
+ export declare const TagItemHeader: IGetToken<ITagItemHeader>;
86
+ export declare const TagField: (footer: any) => Token.Uint8ArrayType;
87
+ export interface ITagFlags {
88
+ containsHeader: boolean;
89
+ containsFooter: boolean;
90
+ isHeader: boolean;
91
+ readOnly: boolean;
92
+ dataType: DataType;
93
+ }
94
+ export declare function parseTagFlags(flags: any): ITagFlags;
95
+ /**
96
+ * @param num {number}
97
+ * @param bit 0 is least significant bit (LSB)
98
+ * @return {boolean} true if bit is 1; otherwise false
99
+ */
100
+ export declare function isBitSet(num: any, bit: any): boolean;
@@ -0,0 +1,320 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { IGetToken, ITokenizer } from 'strtok3/core';
3
+ import { Buffer } from 'node:buffer';
4
+ import { IPicture, ITag } from '../type.js';
5
+ import GUID from './GUID.js';
6
+ /**
7
+ * Data Type: Specifies the type of information being stored. The following values are recognized.
8
+ */
9
+ export declare enum DataType {
10
+ /**
11
+ * Unicode string. The data consists of a sequence of Unicode characters.
12
+ */
13
+ UnicodeString = 0,
14
+ /**
15
+ * BYTE array. The type of data is implementation-specific.
16
+ */
17
+ ByteArray = 1,
18
+ /**
19
+ * BOOL. The data is 2 bytes long and should be interpreted as a 16-bit unsigned integer. Only 0x0000 or 0x0001 are permitted values.
20
+ */
21
+ Bool = 2,
22
+ /**
23
+ * DWORD. The data is 4 bytes long and should be interpreted as a 32-bit unsigned integer.
24
+ */
25
+ DWord = 3,
26
+ /**
27
+ * QWORD. The data is 8 bytes long and should be interpreted as a 64-bit unsigned integer.
28
+ */
29
+ QWord = 4,
30
+ /**
31
+ * WORD. The data is 2 bytes long and should be interpreted as a 16-bit unsigned integer.
32
+ */
33
+ Word = 5
34
+ }
35
+ /**
36
+ * Ref: https://msdn.microsoft.com/en-us/library/windows/desktop/ee663575
37
+ */
38
+ export interface IAsfObjectHeader {
39
+ /**
40
+ * A GUID that identifies the object. 128 bits
41
+ */
42
+ objectId: GUID;
43
+ /**
44
+ * The size of the object (64-bits)
45
+ */
46
+ objectSize: number;
47
+ }
48
+ /**
49
+ * Interface for: 3. ASF top-level Header Object
50
+ * Ref: http://drang.s4.xrea.com/program/tips/id3tag/wmp/03_asf_top_level_header_object.html#3
51
+ */
52
+ export interface IAsfTopLevelObjectHeader extends IAsfObjectHeader {
53
+ numberOfHeaderObjects: number;
54
+ }
55
+ /**
56
+ * Token for: 3. ASF top-level Header Object
57
+ * Ref: http://drang.s4.xrea.com/program/tips/id3tag/wmp/03_asf_top_level_header_object.html#3
58
+ */
59
+ export declare const TopLevelHeaderObjectToken: IGetToken<IAsfTopLevelObjectHeader, Buffer>;
60
+ /**
61
+ * Token for: 3.1 Header Object (mandatory, one only)
62
+ * Ref: http://drang.s4.xrea.com/program/tips/id3tag/wmp/03_asf_top_level_header_object.html#3_1
63
+ */
64
+ export declare const HeaderObjectToken: IGetToken<IAsfObjectHeader, Buffer>;
65
+ export declare abstract class State<T> implements IGetToken<T> {
66
+ len: number;
67
+ constructor(header: IAsfObjectHeader);
68
+ abstract get(buf: Buffer, off: number): T;
69
+ protected postProcessTag(tags: ITag[], name: string, valueType: number, data: any): void;
70
+ }
71
+ export declare class IgnoreObjectState extends State<any> {
72
+ constructor(header: IAsfObjectHeader);
73
+ get(buf: Buffer, off: number): null;
74
+ }
75
+ /**
76
+ * Interface for: 3.2: File Properties Object (mandatory, one only)
77
+ *
78
+ * The File Properties Object defines the global characteristics of the combined digital media streams found within the Data Object.
79
+ */
80
+ export interface IFilePropertiesObject {
81
+ /**
82
+ * Specifies the unique identifier for this file.
83
+ * The value of this field shall be regenerated every time the file is modified in any way.
84
+ * The value of this field shall be identical to the value of the File ID field of the Data Object.
85
+ */
86
+ fileId: GUID;
87
+ /**
88
+ * Specifies the size, in bytes, of the entire file.
89
+ * The value of this field is invalid if the Broadcast Flag bit in the Flags field is set to 1.
90
+ */
91
+ fileSize: bigint;
92
+ /**
93
+ * Specifies the date and time of the initial creation of the file. The value is given as the number of 100-nanosecond
94
+ * intervals since January 1, 1601, according to Coordinated Universal Time (Greenwich Mean Time). The value of this
95
+ * field may be invalid if the Broadcast Flag bit in the Flags field is set to 1.
96
+ */
97
+ creationDate: bigint;
98
+ /**
99
+ * Specifies the number of Data Packet entries that exist within the Data Object. The value of this field is invalid
100
+ * if the Broadcast Flag bit in the Flags field is set to 1.
101
+ */
102
+ dataPacketsCount: bigint;
103
+ /**
104
+ * Specifies the time needed to play the file in 100-nanosecond units.
105
+ * This value should include the duration (estimated, if an exact value is unavailable) of the the last media object
106
+ * in the presentation. The value of this field is invalid if the Broadcast Flag bit in the Flags field is set to 1.
107
+ */
108
+ playDuration: bigint;
109
+ /**
110
+ * Specifies the time needed to send the file in 100-nanosecond units.
111
+ * This value should include the duration of the last packet in the content.
112
+ * The value of this field is invalid if the Broadcast Flag bit in the Flags field is set to 1.
113
+ * Players can ignore this value.
114
+ */
115
+ sendDuration: bigint;
116
+ /**
117
+ * Specifies the amount of time to buffer data before starting to play the file, in millisecond units.
118
+ * If this value is nonzero, the Play Duration field and all of the payload Presentation Time fields have been offset
119
+ * by this amount. Therefore, player software must subtract the value in the preroll field from the play duration and
120
+ * presentation times to calculate their actual values. It follows that all payload Presentation Time fields need to
121
+ * be at least this value.
122
+ */
123
+ preroll: bigint;
124
+ /**
125
+ * The flags
126
+ */
127
+ flags: {
128
+ /**
129
+ * Specifies, if set, that a file is in the process of being created (for example, for recording applications),
130
+ * and thus that various values stored in the header objects are invalid. It is highly recommended that
131
+ * post-processing be performed to remove this condition at the earliest opportunity.
132
+ */
133
+ broadcast: boolean;
134
+ /**
135
+ * Specifies, if set, that a file is seekable.
136
+ * Note that for files containing a single audio stream and a Minimum Data Packet Size field equal to the Maximum
137
+ * Data Packet Size field, this flag shall always be set to 1.
138
+ * For files containing a single audio stream and a video stream or mutually exclusive video streams,
139
+ * this flag is only set to 1 if the file contains a matching Simple Index Object for each regular video stream
140
+ * (that is, video streams that are not hidden according to the method described in section 8.2.2).
141
+ */
142
+ seekable: boolean;
143
+ };
144
+ /**
145
+ * Specifies the minimum Data Packet size in bytes. In general, the value of this field is invalid if the Broadcast
146
+ * Flag bit in the Flags field is set to 1.
147
+ * However, for the purposes of this specification, the values for the Minimum Data Packet Size and Maximum Data
148
+ * Packet Size fields shall be set to the same value, and this value should be set to the packet size, even when the
149
+ * Broadcast Flag in the Flags field is set to 1.
150
+ */
151
+ minimumDataPacketSize: number;
152
+ /**
153
+ * Specifies the maximum Data Packet size in bytes.
154
+ * In general, the value of this field is invalid if the Broadcast Flag bit in the Flags field is set to 1.
155
+ * However, for the purposes of this specification, the values of the Minimum Data Packet Size and Maximum Data Packet
156
+ * Size fields shall be set to the same value,
157
+ * and this value should be set to the packet size, even when the Broadcast Flag field is set to 1.
158
+ */
159
+ maximumDataPacketSize: number;
160
+ /**
161
+ * Specifies the maximum instantaneous bit rate in bits per second for the entire file.
162
+ * This shall equal the sum of the bit rates of the individual digital media streams.
163
+ * It shall be noted that the digital media stream includes ASF data packetization overhead as well as digital media
164
+ * data in payloads.
165
+ * Only those streams that have a free-standing Stream Properties Object in the header shall have their bit rates
166
+ * included in the sum;
167
+ * streams whose Stream Properties Object exists as part of an Extended Stream Properties Object in the Header
168
+ * Extension Object shall not have their bit rates included in this sum, except when this value would otherwise be 0.
169
+ */
170
+ maximumBitrate: number;
171
+ }
172
+ /**
173
+ * Token for: 3.2: File Properties Object (mandatory, one only)
174
+ * Ref: http://drang.s4.xrea.com/program/tips/id3tag/wmp/03_asf_top_level_header_object.html#3_2
175
+ */
176
+ export declare class FilePropertiesObject extends State<IFilePropertiesObject> {
177
+ static guid: GUID;
178
+ constructor(header: IAsfObjectHeader);
179
+ get(buf: Buffer, off: number): IFilePropertiesObject;
180
+ }
181
+ /**
182
+ * Interface for: 3.3 Stream Properties Object (mandatory, one per stream)
183
+ */
184
+ export interface IStreamPropertiesObject {
185
+ /**
186
+ * Stream Type
187
+ */
188
+ streamType: string;
189
+ /**
190
+ * Error Correction Type
191
+ */
192
+ errorCorrectionType: GUID;
193
+ }
194
+ /**
195
+ * Token for: 3.3 Stream Properties Object (mandatory, one per stream)
196
+ * Ref: http://drang.s4.xrea.com/program/tips/id3tag/wmp/03_asf_top_level_header_object.html#3_3
197
+ */
198
+ export declare class StreamPropertiesObject extends State<IStreamPropertiesObject> {
199
+ static guid: GUID;
200
+ constructor(header: IAsfObjectHeader);
201
+ get(buf: Buffer, off: number): IStreamPropertiesObject;
202
+ }
203
+ export interface IHeaderExtensionObject {
204
+ reserved1: GUID;
205
+ reserved2: number;
206
+ extensionDataSize: number;
207
+ }
208
+ /**
209
+ * 3.4: Header Extension Object (mandatory, one only)
210
+ * Ref: http://drang.s4.xrea.com/program/tips/id3tag/wmp/03_asf_top_level_header_object.html#3_4
211
+ */
212
+ export declare class HeaderExtensionObject implements IGetToken<IHeaderExtensionObject> {
213
+ static guid: GUID;
214
+ len: number;
215
+ constructor();
216
+ get(buf: Buffer, off: number): IHeaderExtensionObject;
217
+ }
218
+ export interface ICodecEntry {
219
+ type: {
220
+ videoCodec: boolean;
221
+ audioCodec: boolean;
222
+ };
223
+ codecName: string;
224
+ description: string;
225
+ information: Buffer;
226
+ }
227
+ /**
228
+ * 3.5: Read the Codec-List-Object, which provides user-friendly information about the codecs and formats used to encode the content found in the ASF file.
229
+ * Ref: http://drang.s4.xrea.com/program/tips/id3tag/wmp/03_asf_top_level_header_object.html#3_5
230
+ */
231
+ export declare function readCodecEntries(tokenizer: ITokenizer): Promise<ICodecEntry[]>;
232
+ /**
233
+ * 3.10 Content Description Object (optional, one only)
234
+ * Ref: http://drang.s4.xrea.com/program/tips/id3tag/wmp/03_asf_top_level_header_object.html#3_10
235
+ */
236
+ export declare class ContentDescriptionObjectState extends State<ITag[]> {
237
+ static guid: GUID;
238
+ private static contentDescTags;
239
+ constructor(header: IAsfObjectHeader);
240
+ get(buf: Buffer, off: number): ITag[];
241
+ }
242
+ /**
243
+ * 3.11 Extended Content Description Object (optional, one only)
244
+ * Ref: http://drang.s4.xrea.com/program/tips/id3tag/wmp/03_asf_top_level_header_object.html#3_11
245
+ */
246
+ export declare class ExtendedContentDescriptionObjectState extends State<ITag[]> {
247
+ static guid: GUID;
248
+ constructor(header: IAsfObjectHeader);
249
+ get(buf: Buffer, off: number): ITag[];
250
+ }
251
+ export interface IStreamName {
252
+ streamLanguageId: number;
253
+ streamName: string;
254
+ }
255
+ /**
256
+ * 4.1 Extended Stream Properties Object (optional, 1 per media stream)
257
+ * Ref: http://drang.s4.xrea.com/program/tips/id3tag/wmp/04_objects_in_the_asf_header_extension_object.html#4_1
258
+ */
259
+ export interface IExtendedStreamPropertiesObject {
260
+ startTime: bigint;
261
+ endTime: bigint;
262
+ dataBitrate: number;
263
+ bufferSize: number;
264
+ initialBufferFullness: number;
265
+ alternateDataBitrate: number;
266
+ alternateBufferSize: number;
267
+ alternateInitialBufferFullness: number;
268
+ maximumObjectSize: number;
269
+ flags: {
270
+ reliableFlag: boolean;
271
+ seekableFlag: boolean;
272
+ resendLiveCleanpointsFlag: boolean;
273
+ };
274
+ streamNumber: number;
275
+ streamLanguageId: number;
276
+ averageTimePerFrame: number;
277
+ streamNameCount: number;
278
+ payloadExtensionSystems: number;
279
+ streamNames: IStreamName[];
280
+ streamPropertiesObject: number;
281
+ }
282
+ /**
283
+ * 4.1 Extended Stream Properties Object (optional, 1 per media stream)
284
+ * Ref: http://drang.s4.xrea.com/program/tips/id3tag/wmp/04_objects_in_the_asf_header_extension_object.html#4_1
285
+ */
286
+ export declare class ExtendedStreamPropertiesObjectState extends State<IExtendedStreamPropertiesObject> {
287
+ static guid: GUID;
288
+ constructor(header: IAsfObjectHeader);
289
+ get(buf: Buffer, off: number): IExtendedStreamPropertiesObject;
290
+ }
291
+ /**
292
+ * 4.7 Metadata Object (optional, 0 or 1)
293
+ * Ref: http://drang.s4.xrea.com/program/tips/id3tag/wmp/04_objects_in_the_asf_header_extension_object.html#4_7
294
+ */
295
+ export declare class MetadataObjectState extends State<ITag[]> {
296
+ static guid: GUID;
297
+ constructor(header: IAsfObjectHeader);
298
+ get(uint8Array: Uint8Array, off: number): ITag[];
299
+ }
300
+ export declare class MetadataLibraryObjectState extends MetadataObjectState {
301
+ static guid: GUID;
302
+ constructor(header: IAsfObjectHeader);
303
+ }
304
+ export interface IWmPicture extends IPicture {
305
+ type: string;
306
+ format: string;
307
+ description: string;
308
+ size: number;
309
+ data: Buffer;
310
+ }
311
+ /**
312
+ * Ref: https://msdn.microsoft.com/en-us/library/windows/desktop/dd757977(v=vs.85).aspx
313
+ */
314
+ export declare class WmPictureToken implements IGetToken<IWmPicture> {
315
+ len: any;
316
+ static fromBase64(base64str: string): IPicture;
317
+ static fromBuffer(buffer: Buffer): IWmPicture;
318
+ constructor(len: any);
319
+ get(buffer: Buffer, offset: number): IWmPicture;
320
+ }
@@ -0,0 +1,17 @@
1
+ import { BasicParser } from '../common/BasicParser.js';
2
+ /**
3
+ * Windows Media Metadata Usage Guidelines
4
+ * - Ref: https://msdn.microsoft.com/en-us/library/ms867702.aspx
5
+ *
6
+ * Ref:
7
+ * - https://tools.ietf.org/html/draft-fleischman-asf-01
8
+ * - https://hwiegman.home.xs4all.nl/fileformats/asf/ASF_Specification.pdf
9
+ * - http://drang.s4.xrea.com/program/tips/id3tag/wmp/index.html
10
+ * - https://msdn.microsoft.com/en-us/library/windows/desktop/ee663575(v=vs.85).aspx
11
+ */
12
+ export declare class AsfParser extends BasicParser {
13
+ parse(): Promise<void>;
14
+ private parseObjectHeader;
15
+ private addTags;
16
+ private parseExtensionObject;
17
+ }
@@ -0,0 +1,7 @@
1
+ import { CommonTagMapper } from '../common/GenericTagMapper.js';
2
+ import { IRating, ITag } from '../type.js';
3
+ export declare class AsfTagMapper extends CommonTagMapper {
4
+ static toRating(rating: string): IRating;
5
+ constructor();
6
+ protected postMap(tag: ITag): void;
7
+ }
@@ -0,0 +1,14 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { Buffer } from 'node:buffer';
3
+ import { DataType } from './AsfObject.js';
4
+ export declare type AttributeParser = (buf: Buffer) => boolean | string | number | bigint | Buffer;
5
+ export declare class AsfUtil {
6
+ static getParserForAttr(i: DataType): AttributeParser;
7
+ static parseUnicodeAttr(uint8Array: Uint8Array): string;
8
+ private static attributeParsers;
9
+ private static parseByteArrayAttr;
10
+ private static parseBoolAttr;
11
+ private static parseDWordAttr;
12
+ private static parseQWordAttr;
13
+ private static parseWordAttr;
14
+ }