Video feedback or trails

hello,

I am trying to smooth movements while playing a video to wipe artefacts on plane colors.
My idea is to use a slight feedback. I had a look to the motion trail example in the openframeworks package.
I tried something similar while playing a video but i can’t make it to work like expected : alpha doesn’t seem to work, i have only one image at once instead of multiple merged images.

Does the video needs to have embedded alpha layer ?

I have read multiple threads about effects like this but everything was about drawing graphics not playing videos.

some suggestions might help.

thanks a lot

void ofApp::setup(){
    
    ofBackground(0,0,0);
    ofSetFrameRate(60);
    
    gui.setup();
    gui.add(bFade.set(false));
    gui.add(fade.set("Fade", 100, 0, 100));
    
    fbo.allocate(1280, 800, GL_RGBA);
    
    fbo.begin();
    ofClear(255,255,255, 0);
    fbo.end();
    
    video.load("particles.mp4");
    video.play();
}

void ofApp::update(){
    
    video.update();
    
    ofEnableAlphaBlending();
    
    fbo.begin();
    drawVideo();
    fbo.end();
}

void ofApp::drawVideo(){
    if(bFade){
        ofFill();
        ofSetColor(0,0,0, fade);
        //ofSetColor(255,255,255, fade);
        ofDrawRectangle(0,0,1280,800);
        
        ofFill();
        ofSetColor(255,255,255, 255);
        
        video.draw(0, 0);
    }
    else{
        ofClear(255,255,255, 0);
    }
}

void ofApp::draw(){
    ofSetColor(255,255,255);
    fbo.draw(0,0);
    gui.draw();
    
}

you are drawing the video with a solid color every time so it’s covering whatever there was already in the screen. since the video is the size of the fbo you don’t need to draw any aditional rect on top of the previous frame, just the next frame with some alpha so:

    if(bFade){
        ofFill();
        ofSetColor(0,0,0, fade);
        //ofSetColor(255,255,255, fade);
        ofDrawRectangle(0,0,1280,800);
        
        ofFill();
        ofSetColor(255,255,255, 255);
        
        video.draw(0, 0);
    }

should be

    if(bFade){
        ofSetColor(255,255,255, fade);
        video.draw(0, 0);
    }

I am trying to create a fading trail of the video pattern, that’s why i am drawing a black frame with transparency in every loop.

Your suggestion just fades the video in or out, but no video feedback appears.

that should work, the video might be faded but you should see several frames at once. you can also try other blending methods like screen or multiply which won’t fade the video as much.

No i can’t make it to work…

Where should i change the blending mode ?

void ofApp::setup(){
    
    ofBackground(0,0,0);
    ofSetFrameRate(60);
    
    gui.setup();
    gui.add(bFade.set(false));
    gui.add(fade.set("Fade", 0, 0, 255));
    
    fbo.allocate(1280, 800, GL_RGBA);
    
    fbo.begin();
    ofClear(255,255,255, 0);
    fbo.end();
    
    video.setPixelFormat(OF_PIXELS_RGBA);
    video.load("particles.mp4");
    video.play();
}

void ofApp::update(){
    
    video.update();
    
    ofEnableAlphaBlending();
    
    fbo.begin();
    drawVideo();
    fbo.end();
}

void ofApp::drawVideo(){
    if(bFade){
//        ofFill();
//        ofSetColor(0,0,0, fade);
//        //ofSetColor(255,255,255, fade);
//        ofDrawRectangle(0,0,1280,800);
//        
//        ofFill();
//        ofSetColor(255,255,255, 255);
//        
//        video.draw(0, 0);
            ofSetColor(255,255,255, fade);
            video.draw(0, 0);
    }
    else{
        ofClear(255,255,255, 0);
    }
}

void ofApp::draw(){
    ofSetColor(255,255,255);
    fbo.draw(0,0);
    gui.draw();
    
}