mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-28 11:23:45 +02:00
Small adjustments
This commit is contained in:
+8
-3
@@ -34,8 +34,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas');
|
||||||
canvas.width = 640;
|
canvas.width = 1920;
|
||||||
canvas.height = 480;
|
canvas.height = 1080;
|
||||||
const context = canvas.getContext('2d');
|
const context = canvas.getContext('2d');
|
||||||
|
|
||||||
let format = new Mediabunny.MkvOutputFormat({ streamable: false });
|
let format = new Mediabunny.MkvOutputFormat({ streamable: false });
|
||||||
@@ -193,12 +193,17 @@ Testing... <00:17.350>One... <00:18.125>Two...
|
|||||||
|
|
||||||
//subtitleSource.add(simpleWebvttFile);
|
//subtitleSource.add(simpleWebvttFile);
|
||||||
//subtitleSource.close();
|
//subtitleSource.close();
|
||||||
|
|
||||||
|
const p = document.createElement('p');
|
||||||
|
document.body.append(p);
|
||||||
|
|
||||||
for (let i = 0; i < 100; i++) {
|
for (let i = 0; i < 100; i++) {
|
||||||
context.fillStyle = ['red', 'green', 'blue', 'yellow'][i % 4];
|
context.fillStyle = ['red', 'green', 'blue', 'yellow'][i % 4];
|
||||||
context.fillRect(canvas.width * Math.random(), canvas.height * Math.random(), canvas.width * Math.random(), canvas.height * Math.random());
|
context.fillRect(canvas.width * Math.random(), canvas.height * Math.random(), canvas.width * Math.random(), canvas.height * Math.random());
|
||||||
|
|
||||||
await videoSource.add(i / 10, 1 / 10);
|
await videoSource.add(i / 10, 1 / 10);
|
||||||
|
|
||||||
|
p.textContent = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
let audioContext = new AudioContext();
|
let audioContext = new AudioContext();
|
||||||
@@ -211,5 +216,5 @@ Testing... <00:17.350>One... <00:18.125>Two...
|
|||||||
await output.finalize();
|
await output.finalize();
|
||||||
|
|
||||||
console.log(target);
|
console.log(target);
|
||||||
download(new Blob([target.buffer]), 'test' + format.fileExtension);
|
//download(new Blob([target.buffer]), 'test' + format.fileExtension);
|
||||||
</script>
|
</script>
|
||||||
+8
-4
@@ -380,8 +380,8 @@ class VideoEncoderWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.splitter) {
|
if (this.splitter) {
|
||||||
const alphaFrame = this.splitter.extractAlpha(videoFrame);
|
|
||||||
const colorFrame = this.splitter.extractColor(videoFrame);
|
const colorFrame = this.splitter.extractColor(videoFrame);
|
||||||
|
const alphaFrame = this.splitter.extractAlpha(videoFrame);
|
||||||
|
|
||||||
this.alphaFrameQueue.push(alphaFrame);
|
this.alphaFrameQueue.push(alphaFrame);
|
||||||
this.encoder.encode(colorFrame, finalEncodeOptions);
|
this.encoder.encode(colorFrame, finalEncodeOptions);
|
||||||
@@ -910,13 +910,17 @@ class ColorAlphaSplitter {
|
|||||||
assert(yuv[width * height] === 128); // Where chroma data starts
|
assert(yuv[width * height] === 128); // Where chroma data starts
|
||||||
assert(yuv[yuv.length - 1] === 128); // Assert the YUV data has been fully written
|
assert(yuv[yuv.length - 1] === 128); // Assert the YUV data has been fully written
|
||||||
|
|
||||||
return new VideoFrame(yuv, {
|
// Defining this separately because TypeScript doesn't know `transfer` and I can't be bothered to do declaration
|
||||||
format: 'I420',
|
// merging right now
|
||||||
|
const init = {
|
||||||
|
format: 'I420' as const,
|
||||||
codedWidth: width,
|
codedWidth: width,
|
||||||
codedHeight: height,
|
codedHeight: height,
|
||||||
timestamp: sourceFrame.timestamp,
|
timestamp: sourceFrame.timestamp,
|
||||||
duration: sourceFrame.duration ?? undefined,
|
duration: sourceFrame.duration ?? undefined,
|
||||||
});
|
transfer: [yuv.buffer],
|
||||||
|
};
|
||||||
|
return new VideoFrame(yuv, init);
|
||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
|
|||||||
Reference in New Issue
Block a user