Transparent video read/write support (#145)

* Add support for reading transparent Matroska and implement alpha side data & decode

* Few fixes

* Implement alpha encoding

* Gracefully handle inability to acquire WebGL context, properly clean up WebGL contexts

* Improve touch device detection

* Test test

* Test test #2

* Test test 3

* Test test 4

* Test test 5

* Test test 6

* Test test 7

* Test test 8

* Test test 9

* Test test 10

* Test test 11

* Test test 12

* Test test 13

* Test test 14

* Test test 15

* Test test 16

* Test test 17

* Test test 18

* Test test 19

* Test test 20

* Fix type errors, improve MetadataTags docs

* Do a bunch of docs work

* Test test?

* "Unexpected only modifier 🤓"

* Add InputVideoTrack.canBeTransparent()

* Some clean-up

* Adjust CI to be less spammy in PRs

* Fix broken license headers
This commit is contained in:
David P.
2025-09-24 21:20:14 +02:00
committed by GitHub
parent 0878dd2ca9
commit fa4e064345
34 changed files with 1537 additions and 181 deletions
+10 -6
View File
@@ -14,16 +14,20 @@
source: new Mediabunny.BlobSource(file),
});
window.doDispose = () => input.dispose();
const videoTrack = await input.getPrimaryVideoTrack();
const sink = new Mediabunny.VideoSampleSink(videoTrack);
const sample = await sink.getSample(0);
console.log(sample);
/*
const sink = new Mediabunny.EncodedPacketSink(videoTrack);
for await (const sample of sink.packets()) {
console.log(sample.timestamp)
//sample.close();
await new Promise(resolve => setTimeout(resolve, 0))
for await (const packet of sink.packets()) {
console.log(packet.timestamp, packet.type, await videoTrack.determinePacketType(packet));
}
*/
/*
console.log(await input.computeDuration());
+5 -3
View File
@@ -34,8 +34,8 @@
}
const canvas = document.createElement('canvas');
canvas.width = 1280;
canvas.height = 720;
canvas.width = 640;
canvas.height = 480;
const context = canvas.getContext('2d');
let format = new Mediabunny.MkvOutputFormat({ streamable: false });
@@ -47,6 +47,7 @@
format = new Mediabunny.MkvOutputFormat();
format = new Mediabunny.MovOutputFormat();
format = new Mediabunny.Mp4OutputFormat({ fastStart: 'reserve' });
format = new Mediabunny.MkvOutputFormat();
let target = new Mediabunny.BufferTarget();
/*
@@ -120,6 +121,7 @@
codec: 'vp9',
//fullCodecString: 'avc1.42001f',
bitrate: 1e6,
alpha: 'keep',
onEncoderConfig: console.log,
});
let audioSource = new Mediabunny.AudioBufferSource({
@@ -209,5 +211,5 @@ Testing... <00:17.350>One... <00:18.125>Two...
await output.finalize();
console.log(target);
//download(new Blob([target.buffer]), 'test' + format.fileExtension);
download(new Blob([target.buffer]), 'test' + format.fileExtension);
</script>