hls-streamer 2.1.0 β 2.2.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.
- package/README.md +136 -197
- package/dist/Interfaces/HlsStreamer.d.ts +17 -0
- package/dist/Interfaces/HlsStreamer.d.ts.map +1 -1
- package/dist/Libs/FileLib.d.ts +15 -1
- package/dist/Libs/FileLib.d.ts.map +1 -1
- package/dist/Libs/FileLib.js +238 -108
- package/dist/Libs/FileLib.js.map +1 -1
- package/dist/cjs/Interfaces/HlsStreamer.d.ts +17 -0
- package/dist/cjs/Interfaces/HlsStreamer.d.ts.map +1 -1
- package/dist/cjs/Libs/FileLib.d.ts +15 -1
- package/dist/cjs/Libs/FileLib.d.ts.map +1 -1
- package/dist/cjs/Libs/FileLib.js +241 -108
- package/dist/cjs/Libs/FileLib.js.map +1 -1
- package/dist/cjs/index.d.ts +5 -7
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +133 -133
- package/dist/cjs/index.js.map +1 -1
- package/dist/index.d.ts +5 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +133 -133
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,254 +2,193 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://badge.fury.io/js/hls-streamer)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
|
-
[](
|
|
5
|
+
[](https://www.typescriptlang.org/)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
HLS Streamer turns any MP3 into an HTTP Live Streaming (HLS) playlist on the fly. It analyses the source audio in-memory, builds frame-aligned byte ranges, and streams them without temporary files, native bindings, or external binaries like ffmpeg.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
- π **True Zero Dependencies** - No external dependencies, no ffmpeg, no native binaries
|
|
12
|
-
- π΅ **Built-in MP3 Parser** - Custom MP3 duration parsing without external libraries
|
|
13
|
-
- π **Frame-Aligned Segments** - Ensures all MP3 segments start at valid frame boundaries for seamless playback
|
|
14
|
-
- πΎ **No Temporary Files** - Stream directly from source
|
|
15
|
-
- β‘ **Fast Startup** - Optional smaller initial segments for quick playback start
|
|
16
|
-
- π― **TypeScript Support** - Full type definitions included
|
|
17
|
-
- π§ **Configurable** - Customizable segment sizes and naming
|
|
18
|
-
- π± **Memory Efficient** - Byte-range streaming with minimal memory footprint
|
|
19
|
-
|
|
20
|
-
## π¦ Installation
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
npm install hls-streamer
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
yarn add hls-streamer
|
|
28
|
-
```
|
|
9
|
+
---
|
|
29
10
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
11
|
+
- [Why HLS Streamer?](#why-hls-streamer)
|
|
12
|
+
- [How It Works](#how-it-works)
|
|
13
|
+
- [Quick Start](#quick-start)
|
|
14
|
+
- [Serving Over HTTP](#serving-over-http)
|
|
15
|
+
- [Configuration Reference](#configuration-reference)
|
|
16
|
+
- [Playlist Anatomy](#playlist-anatomy)
|
|
17
|
+
- [Operational Tips](#operational-tips)
|
|
18
|
+
- [Development](#development)
|
|
19
|
+
- [Support](#support)
|
|
33
20
|
|
|
34
|
-
##
|
|
21
|
+
## Why HLS Streamer?
|
|
35
22
|
|
|
36
|
-
|
|
23
|
+
- **Zero dependencies** β no shared libraries, no ffmpeg, no native compilation. Drop it into Docker, serverless, or edge runtimes.
|
|
24
|
+
- **Accurate segments** β real MP3 frame parsing provides true durations, `#EXTINF` metadata, and target durations that match playback.
|
|
25
|
+
- **Frame-aligned byte ranges** β every segment begins and ends on verified MP3 frame boundaries, preventing pops and clipped audio.
|
|
26
|
+
- **No temp files** β streams straight from the source MP3 using byte-range reads.
|
|
27
|
+
- **Fast-start aware** β optional smaller first segments improve startup latency for constrained networks.
|
|
28
|
+
- **TypeScript first** β authored in TypeScript with full type definitions for your tooling and IDEs.
|
|
37
29
|
|
|
38
|
-
|
|
39
|
-
- β
**No native modules** - Pure JavaScript/TypeScript implementation
|
|
40
|
-
- β
**No runtime dependencies** - Check `package.json` - completely empty dependencies
|
|
41
|
-
- β
**Custom MP3 parser** - Built-in MP3 header parsing and duration calculation
|
|
42
|
-
- β
**Frame-perfect segmentation** - MP3 segments start at valid frame boundaries
|
|
43
|
-
- β
**Cross-platform** - Works on any platform that supports Node.js
|
|
30
|
+
## How It Works
|
|
44
31
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
-
|
|
49
|
-
- π **Security-conscious environments** - No external binaries to audit
|
|
32
|
+
1. **Metadata analysis** β the package inspects ID3v2/ID3v1 tags, parses MP3 frame headers, and produces a frame table with offsets, durations, and bitrates.
|
|
33
|
+
2. **Segment planning** β segment boundaries are calculated from the frame table so each segment contains whole frames while matching your target sizes.
|
|
34
|
+
3. **Playlist generation** β `createM3U8()` emits an `#EXTM3U` playlist with accurate `#EXTINF` entries and `#EXT-X-TARGETDURATION` derived from the longest segment.
|
|
35
|
+
4. **On-demand byte ranges** β `getFileBuffer(start, end)` streams the exact bytes for a segment without reading the entire file into memory.
|
|
50
36
|
|
|
51
|
-
|
|
37
|
+
```
|
|
38
|
+
βββββββββββββββ ββββββββββββββββββ ββββββββββββββββββ
|
|
39
|
+
β MP3 Source β ββββββΆ β Frame Analyzer β ββββββΆ β Segment Plannerβ
|
|
40
|
+
βββββββββββββββ ββββββββββββββββββ ββββββββββ¬ββββββββ
|
|
41
|
+
β
|
|
42
|
+
βΌ
|
|
43
|
+
ββββββββββββββββββββββββ
|
|
44
|
+
β HLS Playlist & Bytes β
|
|
45
|
+
ββββββββββββββββββββββββ
|
|
46
|
+
```
|
|
52
47
|
|
|
53
|
-
|
|
48
|
+
## Quick Start
|
|
54
49
|
|
|
55
|
-
```
|
|
50
|
+
```ts
|
|
56
51
|
import { HlsStreamer } from 'hls-streamer';
|
|
57
52
|
|
|
58
|
-
const
|
|
59
|
-
filePath: '
|
|
53
|
+
const streamer = new HlsStreamer({
|
|
54
|
+
filePath: '/media/library/song.mp3',
|
|
60
55
|
segmentSizeKB: 512,
|
|
61
|
-
fileName: '
|
|
62
|
-
baseUrl: '
|
|
63
|
-
enableFastStart: true
|
|
56
|
+
fileName: 'track',
|
|
57
|
+
baseUrl: 'audio/stream/session-42',
|
|
58
|
+
enableFastStart: true,
|
|
64
59
|
});
|
|
65
60
|
|
|
66
|
-
|
|
67
|
-
|
|
61
|
+
const playlist = await streamer.createM3U8();
|
|
62
|
+
console.log(playlist);
|
|
68
63
|
|
|
69
|
-
|
|
70
|
-
const buffer = await hls.getFileBuffer(startByte, endByte);
|
|
64
|
+
const firstSegmentBuffer = await streamer.getFileBuffer(0, 512 * 1024);
|
|
71
65
|
```
|
|
72
66
|
|
|
73
|
-
|
|
67
|
+
## Serving Over HTTP
|
|
68
|
+
|
|
69
|
+
Create playlists and segment endpoints with any HTTP framework. The example below shows an Express setup:
|
|
74
70
|
|
|
75
|
-
```
|
|
71
|
+
```ts
|
|
76
72
|
import express from 'express';
|
|
77
73
|
import { HlsStreamer } from 'hls-streamer';
|
|
78
74
|
|
|
79
75
|
const app = express();
|
|
80
76
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
77
|
+
app.get('/streams/:id/playlist.m3u8', async (req, res, next) => {
|
|
78
|
+
try {
|
|
79
|
+
const streamer = new HlsStreamer({
|
|
80
|
+
filePath: resolveAudioPath(req.params.id),
|
|
81
|
+
baseUrl: `streams/${req.params.id}`,
|
|
82
|
+
enableFastStart: true,
|
|
83
|
+
});
|
|
88
84
|
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
res.type('application/vnd.apple.mpegurl');
|
|
86
|
+
res.send(await streamer.createM3U8());
|
|
87
|
+
} catch (error) {
|
|
88
|
+
next(error);
|
|
89
|
+
}
|
|
91
90
|
});
|
|
92
91
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
92
|
+
app.get('/streams/:id/:start/:end/:filename', async (req, res, next) => {
|
|
93
|
+
try {
|
|
94
|
+
const streamer = new HlsStreamer({
|
|
95
|
+
filePath: resolveAudioPath(req.params.id),
|
|
96
|
+
baseUrl: `streams/${req.params.id}`,
|
|
97
|
+
});
|
|
99
98
|
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
const start = Number(req.params.start);
|
|
100
|
+
const end = Number(req.params.end);
|
|
102
101
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
res.type('audio/mpeg');
|
|
103
|
+
res.set('Accept-Ranges', 'bytes');
|
|
104
|
+
res.send(await streamer.getFileBuffer(start, end));
|
|
105
|
+
} catch (error) {
|
|
106
|
+
next(error);
|
|
107
|
+
}
|
|
106
108
|
});
|
|
107
109
|
```
|
|
108
110
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
### HlsStreamer
|
|
112
|
-
|
|
113
|
-
#### Constructor Options
|
|
114
|
-
|
|
115
|
-
```typescript
|
|
116
|
-
interface HlsStreamerOptions {
|
|
117
|
-
/** Path to the MP3 file */
|
|
118
|
-
filePath: string;
|
|
119
|
-
/** Segment size in KB (default: 512) */
|
|
120
|
-
segmentSizeKB?: number;
|
|
121
|
-
/** Base filename for segments (default: "file") */
|
|
122
|
-
fileName?: string;
|
|
123
|
-
/** Base URL path for segment URLs */
|
|
124
|
-
baseUrl?: string;
|
|
125
|
-
/** Enable smaller initial segments for faster startup */
|
|
126
|
-
enableFastStart?: boolean;
|
|
127
|
-
}
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
#### Methods
|
|
131
|
-
|
|
132
|
-
##### `createM3U8(): Promise<string>`
|
|
133
|
-
Generates an HLS M3U8 playlist file content.
|
|
134
|
-
|
|
135
|
-
**Returns:** M3U8 playlist as a string
|
|
136
|
-
|
|
137
|
-
##### `getFileBuffer(startByte: number, endByte: number): Promise<Buffer>`
|
|
138
|
-
Retrieves a specific byte range from the MP3 file.
|
|
111
|
+
### Segment URL Contract
|
|
139
112
|
|
|
140
|
-
|
|
141
|
-
- `startByte` - Starting byte position (inclusive)
|
|
142
|
-
- `endByte` - Ending byte position (exclusive)
|
|
113
|
+
Generated playlists follow the pattern below:
|
|
143
114
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
##### `getSegmentDuration(segmentIndex: number): Promise<number>`
|
|
147
|
-
Gets the accurate duration of a specific segment.
|
|
148
|
-
|
|
149
|
-
**Parameters:**
|
|
150
|
-
- `segmentIndex` - Zero-based segment index
|
|
151
|
-
|
|
152
|
-
**Returns:** Duration in seconds
|
|
153
|
-
|
|
154
|
-
### Error Handling
|
|
155
|
-
|
|
156
|
-
The package includes custom error types for better error handling:
|
|
157
|
-
|
|
158
|
-
```typescript
|
|
159
|
-
import {
|
|
160
|
-
FileNotFoundError,
|
|
161
|
-
InvalidFileError,
|
|
162
|
-
InvalidRangeError,
|
|
163
|
-
InvalidParameterError
|
|
164
|
-
} from 'hls-streamer';
|
|
165
|
-
|
|
166
|
-
try {
|
|
167
|
-
const hls = new HlsStreamer({ filePath: 'nonexistent.mp3' });
|
|
168
|
-
} catch (error) {
|
|
169
|
-
if (error instanceof FileNotFoundError) {
|
|
170
|
-
console.error('File not found:', error.message);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
115
|
+
```
|
|
116
|
+
/{baseUrl}/{startByte}/{endByte}/{fileName}{index}.mp3
|
|
173
117
|
```
|
|
174
118
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
|
182
|
-
|
|
|
183
|
-
| `
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
119
|
+
- `startByte` is inclusive, `endByte` is exclusive.
|
|
120
|
+
- `index` is zero-padded to three digits (`000`, `001`, ...).
|
|
121
|
+
- Use the provided byte range as-is when serving `audio/mpeg` responses.
|
|
122
|
+
|
|
123
|
+
## Configuration Reference
|
|
124
|
+
|
|
125
|
+
| Option | Type | Default | Description |
|
|
126
|
+
| ------------------- | --------- | ------- | ----------- |
|
|
127
|
+
| `filePath` | `string` | β | Absolute or relative path to the MP3 file. |
|
|
128
|
+
| `segmentSizeKB` | `number` | `512` | Target segment size in kilobytes. Fast-start mode splits the first two segments into quarters/halves of this value. |
|
|
129
|
+
| `fileName` | `string` | `"file"` | Base name used in generated segment URLs (the index is appended automatically). |
|
|
130
|
+
| `baseUrl` | `string` | `""` | URL prefix inserted before each segment path. Useful when mounting under a route or CDN prefix. |
|
|
131
|
+
| `enableFastStart` | `boolean` | `false` | When true, the first two segments are smaller to reduce initial buffering time. |
|
|
132
|
+
|
|
133
|
+
### API Surface
|
|
134
|
+
|
|
135
|
+
- `createM3U8(): Promise<string>` β Returns a full playlist with frame-accurate durations.
|
|
136
|
+
- `getFileBuffer(start: number, end: number): Promise<Buffer>` β Streams a byte range from the MP3.
|
|
137
|
+
- `getSegmentDuration(index: number): Promise<number>` β Reads the cached segment table to return the duration of a segment in seconds.
|
|
138
|
+
|
|
139
|
+
Custom error classes are exported to help with error handling: `FileNotFoundError`, `InvalidFileError`, `InvalidRangeError`, and `InvalidParameterError`.
|
|
140
|
+
|
|
141
|
+
## Playlist Anatomy
|
|
142
|
+
|
|
143
|
+
```m3u8
|
|
144
|
+
#EXTM3U
|
|
145
|
+
#EXT-X-VERSION:6
|
|
146
|
+
#EXT-X-PLAYLIST-TYPE:VOD
|
|
147
|
+
#EXT-X-TARGETDURATION:6
|
|
148
|
+
#EXT-X-MEDIA-SEQUENCE:0
|
|
149
|
+
#EXTINF:5.973,
|
|
150
|
+
/audio/session/0/260736/track000.mp3
|
|
151
|
+
#EXTINF:5.994,
|
|
152
|
+
/audio/session/260736/521472/track001.mp3
|
|
153
|
+
...
|
|
154
|
+
#EXT-X-ENDLIST
|
|
203
155
|
```
|
|
204
156
|
|
|
205
|
-
|
|
157
|
+
- `#EXT-X-TARGETDURATION` is rounded up from the longest real segment duration.
|
|
158
|
+
- `#EXTINF` entries retain millisecond precision for smooth playback on strict clients.
|
|
159
|
+
- Segment paths directly encode the byte ranges your route must return.
|
|
206
160
|
|
|
207
|
-
|
|
208
|
-
class AudioStreamer {
|
|
209
|
-
async streamAudio(userId: string, audioId: string) {
|
|
210
|
-
const filePath = await this.getAudioPath(userId, audioId);
|
|
161
|
+
## Operational Tips
|
|
211
162
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
});
|
|
163
|
+
- **Caching** β Construct the streamer once per unique MP3 and reuse it. Segment planning caches the metadata, so repeated calls to `createM3U8()` or `getSegmentDuration()` are cheap.
|
|
164
|
+
- **CDN friendliness** β Because segment URLs are deterministic byte ranges, edge caches can serve them efficiently. Configure consistent caching headers (e.g. `Cache-Control: public, max-age=86400`).
|
|
165
|
+
- **Serverless** β The zero-dependency design works well in Lambda/Cloud Functions. For large MP3s, prefer streaming reads (`getFileBuffer`) instead of loading entire files into memory.
|
|
166
|
+
- **Monitoring** β Log segment `start`/`end` pairs and durations to correlate playback issues with specific byte ranges or frame parsing warnings.
|
|
167
|
+
- **Troubleshooting** β For corrupted MP3s, inspect `FileLib.analyzeMP3File()` (available internally) to review parsing warnings and ID3 metadata.
|
|
218
168
|
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
## π§ͺ Testing
|
|
225
|
-
|
|
226
|
-
```bash
|
|
227
|
-
npm test
|
|
228
|
-
npm run test:watch
|
|
229
|
-
npm run test:coverage
|
|
230
|
-
```
|
|
169
|
+
## Development
|
|
231
170
|
|
|
232
|
-
|
|
171
|
+
Clone the repo, install dependencies, and run the usual scripts:
|
|
233
172
|
|
|
234
173
|
```bash
|
|
235
|
-
npm
|
|
236
|
-
npm
|
|
237
|
-
npm run build
|
|
174
|
+
npm install
|
|
175
|
+
npm test -- --runInBand --watchman=false
|
|
176
|
+
npm run build
|
|
238
177
|
```
|
|
239
178
|
|
|
240
|
-
|
|
179
|
+
The Jest flag `--watchman=false` avoids macOS sandbox issues when running in restricted environments.
|
|
241
180
|
|
|
242
|
-
|
|
181
|
+
To explore the example playlist generator, see `example/test-hls-generation.js` and the bundled `example/sample.mp3` fixture.
|
|
243
182
|
|
|
244
|
-
##
|
|
183
|
+
## Support
|
|
245
184
|
|
|
246
|
-
|
|
185
|
+
- π Bug reports: [GitHub Issues](https://github.com/LordVersA/hls-streamer/issues)
|
|
186
|
+
- π¬ Questions & ideas: [GitHub Discussions](https://github.com/LordVersA/hls-streamer/discussions)
|
|
187
|
+
- π¦ npm registry: [hls-streamer](https://www.npmjs.com/package/hls-streamer)
|
|
247
188
|
|
|
248
|
-
##
|
|
189
|
+
## Contributing
|
|
249
190
|
|
|
250
|
-
|
|
251
|
-
- π¬ **Questions:** [GitHub Discussions](https://github.com/LordVersA/hls-streamer/discussions)
|
|
252
|
-
- π¦ **NPM:** [hls-streamer](https://www.npmjs.com/package/hls-streamer)
|
|
191
|
+
Contributions are welcome! Please open an issue to discuss substantial changes before submitting a pull request. Make sure `npm test -- --runInBand --watchman=false` and `npm run build` pass prior to filing the PR.
|
|
253
192
|
|
|
254
193
|
---
|
|
255
194
|
|
|
@@ -10,8 +10,25 @@ export interface SegmentInfo {
|
|
|
10
10
|
end: number;
|
|
11
11
|
duration: number;
|
|
12
12
|
}
|
|
13
|
+
export interface Mp3FrameInfo {
|
|
14
|
+
index: number;
|
|
15
|
+
offset: number;
|
|
16
|
+
length: number;
|
|
17
|
+
duration: number;
|
|
18
|
+
samples: number;
|
|
19
|
+
sampleRate: number;
|
|
20
|
+
bitrate: number;
|
|
21
|
+
padding: 0 | 1;
|
|
22
|
+
}
|
|
13
23
|
export interface Mp3FileInfo {
|
|
14
24
|
size: number;
|
|
15
25
|
duration: number;
|
|
26
|
+
audioDataSize: number;
|
|
27
|
+
sampleRate?: number;
|
|
28
|
+
averageBitrate?: number;
|
|
29
|
+
id3v2Size?: number;
|
|
30
|
+
id3v1Size?: number;
|
|
31
|
+
frames: Mp3FrameInfo[];
|
|
32
|
+
warnings?: string[];
|
|
16
33
|
}
|
|
17
34
|
//# sourceMappingURL=HlsStreamer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HlsStreamer.d.ts","sourceRoot":"","sources":["../../src/Interfaces/HlsStreamer.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,kBAAkB;IAEjC,QAAQ,EAAE,MAAM,CAAC;IAEjB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAKD,MAAM,WAAW,WAAW;IAE1B,KAAK,EAAE,MAAM,CAAC;IAEd,GAAG,EAAE,MAAM,CAAC;IAEZ,QAAQ,EAAE,MAAM,CAAC;CAClB;AAKD,MAAM,WAAW,WAAW;IAE1B,IAAI,EAAE,MAAM,CAAC;IAEb,QAAQ,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"HlsStreamer.d.ts","sourceRoot":"","sources":["../../src/Interfaces/HlsStreamer.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,kBAAkB;IAEjC,QAAQ,EAAE,MAAM,CAAC;IAEjB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAKD,MAAM,WAAW,WAAW;IAE1B,KAAK,EAAE,MAAM,CAAC;IAEd,GAAG,EAAE,MAAM,CAAC;IAEZ,QAAQ,EAAE,MAAM,CAAC;CAClB;AAQD,MAAM,WAAW,YAAY;IAI3B,KAAK,EAAE,MAAM,CAAC;IAEd,MAAM,EAAE,MAAM,CAAC;IAEf,MAAM,EAAE,MAAM,CAAC;IAEf,QAAQ,EAAE,MAAM,CAAC;IAEjB,OAAO,EAAE,MAAM,CAAC;IAEhB,UAAU,EAAE,MAAM,CAAC;IAEnB,OAAO,EAAE,MAAM,CAAC;IAEhB,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC;CAChB;AAKD,MAAM,WAAW,WAAW;IAE1B,IAAI,EAAE,MAAM,CAAC;IAEb,QAAQ,EAAE,MAAM,CAAC;IAEjB,aAAa,EAAE,MAAM,CAAC;IAEtB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,MAAM,EAAE,YAAY,EAAE,CAAC;IAEvB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB"}
|
package/dist/Libs/FileLib.d.ts
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
|
+
import { Mp3FileInfo } from '../Interfaces/HlsStreamer';
|
|
1
2
|
export declare class FileLib {
|
|
3
|
+
private static readonly BITRATE_INDEX;
|
|
4
|
+
private static readonly SAMPLE_RATE_INDEX;
|
|
2
5
|
static getFileSizeInBytes(buffer: Buffer): number;
|
|
3
6
|
static getMP3DurationFromBuffer(mp3Buffer: Buffer): Promise<number>;
|
|
4
|
-
|
|
7
|
+
static analyzeMP3Buffer(buffer: Buffer, opts?: {
|
|
8
|
+
fileSize?: number;
|
|
9
|
+
}): Mp3FileInfo;
|
|
10
|
+
static analyzeMP3File(filePath: string): Promise<Mp3FileInfo>;
|
|
11
|
+
private static calculateFrameLength;
|
|
12
|
+
private static getId3Offsets;
|
|
13
|
+
private static syncSafeInteger;
|
|
14
|
+
private static isFrameSync;
|
|
15
|
+
private static parseFrameHeader;
|
|
16
|
+
private static decodeVersion;
|
|
17
|
+
private static decodeLayer;
|
|
18
|
+
private static getSamplesPerFrame;
|
|
5
19
|
}
|
|
6
20
|
//# sourceMappingURL=FileLib.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileLib.d.ts","sourceRoot":"","sources":["../../src/Libs/FileLib.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FileLib.d.ts","sourceRoot":"","sources":["../../src/Libs/FileLib.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAgB,MAAM,2BAA2B,CAAC;AAqBtE,qBAAa,OAAO;IAClB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAgBnC;IAEF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAIvC;IAKF,MAAM,CAAC,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;WAWpC,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAQzE,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,WAAW;WA6HzE,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IASnE,OAAO,CAAC,MAAM,CAAC,oBAAoB;IASnC,OAAO,CAAC,MAAM,CAAC,aAAa;IA8B5B,OAAO,CAAC,MAAM,CAAC,eAAe;IAO9B,OAAO,CAAC,MAAM,CAAC,WAAW;IAW1B,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAqC/B,OAAO,CAAC,MAAM,CAAC,aAAa;IAa5B,OAAO,CAAC,MAAM,CAAC,WAAW;IAa1B,OAAO,CAAC,MAAM,CAAC,kBAAkB;CAWlC"}
|