libav-wasm 0.6.2 → 0.7.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 +61 -61
- package/build/index.js +1 -1
- package/build/libav.wasm +0 -0
- package/build/worker.js +1661 -1475
- package/package.json +41 -41
package/README.md
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
# LibAV WASM
|
|
2
|
-
|
|
3
|
-
This library can be used to remux from MKV -> MP4, it could technically do any remux but i haven't had the need for it, create an issue if you'd like it.
|
|
4
|
-
|
|
5
|
-
[src/test.ts](https://github.com/Banou26/libav-wasm/blob/main/src/test.ts)
|
|
6
|
-
Contains a full example of a MKV video player
|
|
7
|
-
|
|
8
|
-
Basic usage
|
|
9
|
-
```ts
|
|
10
|
-
const remuxer = await makeRemuxer({
|
|
11
|
-
// the path at which the wasm file is getting served
|
|
12
|
-
publicPath: new URL('/dist/', new URL(import.meta.url).origin).toString(),
|
|
13
|
-
// url of the worker file of libavWASM
|
|
14
|
-
workerUrl: new URL('../build/worker.js', import.meta.url).toString(),
|
|
15
|
-
// reads will be done in 2.5mb chunks
|
|
16
|
-
bufferSize: 2_500_000,
|
|
17
|
-
// byte length of the video file
|
|
18
|
-
length: contentLength,
|
|
19
|
-
// fetch returning a ReadableStream
|
|
20
|
-
getStream: async (offset, size) =>
|
|
21
|
-
fetch(
|
|
22
|
-
VIDEO_URL,
|
|
23
|
-
{
|
|
24
|
-
headers: {
|
|
25
|
-
Range: `bytes=${offset}-${size ? Math.min(offset + size, contentLength) - 1 : ''}`
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
).then(res => res.body)
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
// returns the header of the video with all the metadata
|
|
32
|
-
const header = await remuxer.init()
|
|
33
|
-
|
|
34
|
-
// Returns a chunk that looks like {
|
|
35
|
-
// offset: number,
|
|
36
|
-
// buffer: Uint8Array,
|
|
37
|
-
// pos: number,
|
|
38
|
-
// pts: number, // timestamp
|
|
39
|
-
// duration: number
|
|
40
|
-
// }
|
|
41
|
-
// buffer can be appended to the MediaSource API(MSE API)
|
|
42
|
-
const chunk = await remuxer.read()
|
|
43
|
-
|
|
44
|
-
// allows you to seek to timestamp and start reading from there
|
|
45
|
-
const seekChunk = await remuxer.seek(number)
|
|
46
|
-
// ...
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
## Intellisense
|
|
51
|
-
To have C++ autocompletion, put a ffmpeg repo clone folder in the root
|
|
52
|
-
`git clone https://github.com/FFmpeg/FFmpeg` & `git clone https://github.com/emscripten-core/emscripten`
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
## Issues to fix / features to implement
|
|
57
|
-
- Try to play around with `sourceBuffer.timestampOffset = res.pts` and always increasing timestamps to not have to re-init on backwards seeks
|
|
58
|
-
- Transcoding
|
|
59
|
-
- Base transcoding off of https://cconcolato.github.io/media-mime-support/#audio_codecs
|
|
60
|
-
<!-- https://www.ffmpeg.org/doxygen/trunk/remuxing_8c-example.html -->
|
|
61
|
-
<!-- https://github.com/leandromoreira/ffmpeg-libav-tutorial -->
|
|
1
|
+
# LibAV WASM
|
|
2
|
+
|
|
3
|
+
This library can be used to remux from MKV -> MP4, it could technically do any remux but i haven't had the need for it, create an issue if you'd like it.
|
|
4
|
+
|
|
5
|
+
[src/test.ts](https://github.com/Banou26/libav-wasm/blob/main/src/test.ts)
|
|
6
|
+
Contains a full example of a MKV video player
|
|
7
|
+
|
|
8
|
+
Basic usage
|
|
9
|
+
```ts
|
|
10
|
+
const remuxer = await makeRemuxer({
|
|
11
|
+
// the path at which the wasm file is getting served
|
|
12
|
+
publicPath: new URL('/dist/', new URL(import.meta.url).origin).toString(),
|
|
13
|
+
// url of the worker file of libavWASM
|
|
14
|
+
workerUrl: new URL('../build/worker.js', import.meta.url).toString(),
|
|
15
|
+
// reads will be done in 2.5mb chunks
|
|
16
|
+
bufferSize: 2_500_000,
|
|
17
|
+
// byte length of the video file
|
|
18
|
+
length: contentLength,
|
|
19
|
+
// fetch returning a ReadableStream
|
|
20
|
+
getStream: async (offset, size) =>
|
|
21
|
+
fetch(
|
|
22
|
+
VIDEO_URL,
|
|
23
|
+
{
|
|
24
|
+
headers: {
|
|
25
|
+
Range: `bytes=${offset}-${size ? Math.min(offset + size, contentLength) - 1 : ''}`
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
).then(res => res.body)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
// returns the header of the video with all the metadata
|
|
32
|
+
const header = await remuxer.init()
|
|
33
|
+
|
|
34
|
+
// Returns a chunk that looks like {
|
|
35
|
+
// offset: number,
|
|
36
|
+
// buffer: Uint8Array,
|
|
37
|
+
// pos: number,
|
|
38
|
+
// pts: number, // timestamp
|
|
39
|
+
// duration: number
|
|
40
|
+
// }
|
|
41
|
+
// buffer can be appended to the MediaSource API(MSE API)
|
|
42
|
+
const chunk = await remuxer.read()
|
|
43
|
+
|
|
44
|
+
// allows you to seek to timestamp and start reading from there
|
|
45
|
+
const seekChunk = await remuxer.seek(number)
|
|
46
|
+
// ...
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
## Intellisense
|
|
51
|
+
To have C++ autocompletion, put a ffmpeg repo clone folder in the root
|
|
52
|
+
`git clone https://github.com/FFmpeg/FFmpeg` & `git clone https://github.com/emscripten-core/emscripten`
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
## Issues to fix / features to implement
|
|
57
|
+
- Try to play around with `sourceBuffer.timestampOffset = res.pts` and always increasing timestamps to not have to re-init on backwards seeks
|
|
58
|
+
- Transcoding
|
|
59
|
+
- Base transcoding off of https://cconcolato.github.io/media-mime-support/#audio_codecs
|
|
60
|
+
<!-- https://www.ffmpeg.org/doxygen/trunk/remuxing_8c-example.html -->
|
|
61
|
+
<!-- https://github.com/leandromoreira/ffmpeg-libav-tutorial -->
|
package/build/index.js
CHANGED
|
@@ -1013,7 +1013,7 @@ const makeRemuxer = async ({
|
|
|
1013
1013
|
bufferSize = 25e5
|
|
1014
1014
|
}) => {
|
|
1015
1015
|
const worker = new Worker(workerUrl, workerOptions);
|
|
1016
|
-
const { makeRemuxer: makeRemuxer2 } = await expose({}, {
|
|
1016
|
+
const { makeRemuxer: makeRemuxer2 } = await expose({}, { transport: worker });
|
|
1017
1017
|
let reader;
|
|
1018
1018
|
const remuxer = await makeRemuxer2({
|
|
1019
1019
|
publicPath,
|
package/build/libav.wasm
CHANGED
|
File without changes
|