Fixed doubly stacked rotation correction when converting rotated video with a custom process function (fixes #218)

This commit is contained in:
Vanilagy
2025-11-11 11:05:15 +01:00
parent 6022781e8c
commit 3db4aa8b91
3 changed files with 19 additions and 9 deletions
+9 -6
View File
@@ -48,6 +48,7 @@
target
});
let ctx = null;
const conversion = await Mediabunny.Conversion.init({
input: new Mediabunny.Input({
formats: Mediabunny.ALL_FORMATS,
@@ -56,6 +57,7 @@
output,
audio: (_, n) => ({
discard: n > 1,
//codec: 'opus',
/*
process: (sample) => {
return sample;
@@ -97,7 +99,7 @@
},
*/
video: () => ({
/*
//discard: true,
process: (sample) => {
if (!ctx) {
// Create a canvas for image compositing
@@ -108,13 +110,14 @@
ctx = canvas.getContext('2d');
}
console.log(ctx.canvas.width, ctx.canvas.height);
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
sample.draw(ctx, 0, 0);
ctx.drawImage(watermark, 32, 32);
sample.drawWithFit(ctx, { fit: 'fill' });
//ctx.drawImage(watermark, 32, 32);
return ctx.canvas;
},
*/
//width: 300,
//alpha: 'keep',
//width: 320,
@@ -170,8 +173,8 @@
}
},
trim: {
start: 0,
end: 10
//start: 0,
//end: 10
},
});
console.log(conversion);