core icon indicating copy to clipboard operation
core copied to clipboard

Add mask to video for speaking avatar?

Open voladelta opened this issue 1 year ago • 6 comments

Is there a way to shape/crop video into any size and shape?

For example: A 16:9 video can be shaped into 1:1 or crop center in 9:16 box, or a circle?

voladelta avatar Oct 29 '24 07:10 voladelta

It's not implemented yet, although it shouldn’t take more than an hour to get done.

k9p5 avatar Oct 29 '24 18:10 k9p5

It's not implemented yet, although it shouldn’t take more than an hour to get done.

So how about you spend that hour for timeline and i could help for that?

girayk avatar Oct 29 '24 18:10 girayk

I'm constantly working on the timeline but go ahead, I appreciate any help I can get

k9p5 avatar Oct 29 '24 18:10 k9p5

I'm constantly working on the timeline but go ahead, I appreciate any help I can get

Exactly please keep going on timeline and i will happy to help , if I can

girayk avatar Oct 29 '24 18:10 girayk

Screenshot 2024-10-29 at 23 52 22

` import {Clip, VisualMixin} from "@diffusionstudio/core"; import { Graphics } from "pixi.js";

class CircleMaskProps { radius?: string; fill?: string; position: { x: number, y: number, } }

export class CircleMask extends VisualMixin(Clip<CircleMaskProps>) {

public graphics = new Graphics()
public radius = 50;
public fill = null

public constructor(props: CircleMaskProps = {}) {
    super();

    console.log(this)
    Object.assign(this, props);

    this.graphics.circle(this._position.x + this.radius , this._position.y + this.radius , this.radius)
    if (this.fill === null){
        this.graphics.fill({color: '#FFF', alpha: 1});
    }
    else{
        this.graphics.fill({color: this.fill, alpha: this.alpha});

    }
}

} `

and for the add let mask = new CircleMask({radius: 360, position: {x: 250, y: 0}}) videoClip.addMask(mask)

write way?

girayk avatar Oct 29 '24 20:10 girayk

I would implement it exactly the same as the filters and each mask should inherit from graphics. E.g. class CircleMask extends Graphics. Then you can draw the circle in the constructor.

k9p5 avatar Oct 29 '24 22:10 k9p5