ofxSimpleScreenRecorder

hi, im trying to figure out why at using this addon i get the images flipped like this


i imagine this part of the code its where i should flip the image some how can someone point out how to do this

void begin(){
        
        fbo.begin();
        ofClear(0);
    }
    
    void end(){
        if(stopTriggered) showWarning();
        fbo.end();
        
        
        fbo.draw(0,0);
        
        
        bool _save = saveCount%2 == 0 ? true : false;
        if(_save && isRunning && !stopTriggered){
            if(!isInit)

                bffr_ping.unmap();
            
            isInit = false;
            
            fbo.getTexture().copyTo(bffr_ping);
            
            bffr_pong.bind(GL_PIXEL_UNPACK_BUFFER);
            unsigned char * p = bffr_pong.map<unsigned char>(GL_READ_ONLY);

            pixels[bffrCount].setFromPixels(p,w,h,OF_PIXELS_RGB);
            std::swap(bffr_ping, bffr_pong);
            
            bffrCount++;
            
            if(bffrCount >= numBffr) {
                std::cout<<"ofxSSR::buffer reaches limit - stopping rendering" << endl << "use setNumBffr(int _num) to increase limit. current value is " << numBffr << endl;
                stop();
            }
        }
        saveCount++;
        
        if(stopTriggered && bffrCount-1 <= thrdBffrCount){
            isRunning = false;
            runFFMpeg();
            reset();
            stopThread();
        }
    }

Did you tried to draw into another aux Fbo?
And doing something like

if (!vflip) {
			fbo_FxChain.draw(0, 0, window_W, window_H);
}
else {
			fbo_FxChain.draw(0, window_H, window_W, -window_H);
}

@cyrstem
i have seen around another way to flip:

if (vflip)
{
  ofPushMatrix();
  ofTranslate(x, y + h, 0);
  ofScale(1, -1, 1);
}
else glTranslatef(x, y, 0);
fbo.draw(0, 0, w, h);
if (vflip) ofPopMatrix();

havent try this yet thanks

i try this it didnt work maybe its becouse im using a shader inside the fbo ?and then another fbo for the recording ?
@moebiussurfing

I think has nothing to do with shaders and another fbo’s. I’m using this addon with shader and fbo’s and works well at mos of the cases.
Where are you get the addon ?
I’ll attach my version of this addon, take a try and tell us if it worked for you.
ofxSimpleScreenRecorder.h (8.3 KB)

i got the same result

then post some of your draw code

void ofApp::setup(){
    //ofSetLogLevel(OF_LOG_VERBOSE);
    ofSetWindowShape(900,960);
    ofSetWindowTitle("glitch");
    ofSetFrameRate(8);  
    
    vid.load("ML.mp4");
    //img.load("RUNE.png");

    vid.setLoopState(OF_LOOP_NORMAL);
    shaderB.load("glitch2");
    shader.load("glitch");

    vid.play();

    ofFboSettings s;
    s.width =vid.getWidth();
    s.height =vid.getHeight();
    s.internalformat =GL_RGBA;
    s.useDepth = true;
    fbo.allocate(s);
    

    ofFboSettings v;
    v.width = 900;
    v.height = 960;
    v.internalformat =GL_RGBA;
    v.useDepth = true;
    fbo0.allocate(v);


    gui.setup();
    gui.add(valueA.set("Value A",0.0005,0.0,1.0));
    gui.add(valueB.set("Value B",0.0001,0,1));


    for(int i = 0; i < fbo.getHeight(); i++)
    {
        y_noise.push_back(glm::vec3(0.f,0.f,0.f));

    }
    showGui = false;
    scene = false;

    mRenderer.setup(ofGetWidth(), ofGetHeight());

}

//--------------------------------------------------------------
void ofApp::update(){
    vid.update();
    fbo.begin();
    ofClear(0);
    fbo.end();

    fbo0.begin();
    ofClear(0);
    fbo0.end();

    glm::vec3 noise_value;

    for(int  y = 0; y < y_noise.size(); y++)
    {
        for(int i = 0; i < 3; i++)
        {
            noise_value[i] = ofMap(ofNoise(i,y *valueA +ofGetElapsedTimef()*valueB) ,0,1,-1,1);

        }
        y_noise[y] = noise_value;   
    }
}

//--------------------------------------------------------------
void ofApp::draw(){
    fbo.begin();
        vid.draw(0,0,900,960);
    fbo.end();

    fbo0.begin();
    //ofBackground(ofColor::black);
        //svg.draw();
        img.draw(0,0);
        //ofDrawRectangle(0,0,40,40);
    fbo0.end();

 mRenderer.begin(); 
if (scene)
{
    shaderB.begin();
    shaderB.setUniform1f("u_time",ofGetElapsedTimef());
    shaderB.setUniformTexture("u_tex0",fbo0.getTexture(),1);
    shaderB.setUniform2f("u_resolution",900,960);
        fbo0.draw(0,0);
    shaderB.end();
}else
{
    shader.begin();
    shader.setUniform1f("u_time",ofGetElapsedTimef());
        shader.setUniform2f("u_resolution",900,960);
        shader.setUniformTexture("u_tex0",fbo.getTexture(),1);
        shader.setUniform1f("u_date",ofGetDay());
        shader.setUniform3fv("y_noise", &y_noise[0].x,ofGetHeight());
    fbo.draw(0,0);
    shader.end();

}

mRenderer.end();

the shader

#version 150

out vec4 outputColor;
uniform float u_time;
// uniform float random;
uniform vec2 u_resolution;
uniform sampler2DRect u_tex0;
uniform  float u_colorFactor;


float random (vec2 st) {
    return fract(sin(dot(st.xy,
       vec2(20.9898,78.233)))*
        43758.5453123);
}

mat2 scale(vec2 _scale){
    return mat2(_scale.x,0.0,
                0.0,_scale.y);
}



// 2D Noise based on Morgan McGuire @morgan3d
// https://www.shadertoy.com/view/4dS3Wd
float noise (in vec2 st) {
    vec2 i = floor(st);
    vec2 f = fract(st);

    // Four corners in 2D of a tile
    float a = random(i);
    float b = random(i + vec2(1.0, 0.0));
    float c = random(i + vec2(0.0, 1.0));
    float d = random(i + vec2(1.0, 1.0));

    // Smooth Interpolation

    // Cubic Hermine Curve.  Same as SmoothStep()
    vec2 u = f*f*(3.0-2.0*f);
    // u = smoothstep(0.,1.,f);

    // Mix 4 coorners percentages
    return mix(a, b, u.x) +
            (c - a)* u.y * (1.0 - u.x) +
            (d - b) * u.x * u.y;
}

void main()
{
     vec2 st = gl_FragCoord.xy/u_resolution.xy;
     st.y = 1.-st.y; // invert y to draw normally per openFrameworks
	 st *= u_resolution; // de-normalize coords

	float timePassed = u_time;
    vec4 color = vec4(st.x,st.y,0.0,0.0);
    color = texture2DRect(u_tex0,st); 

     vec2 translate =scale( vec2(sin(u_time)) ) * st;
    st += translate*0;
    vec2 ipos = floor(st);
    vec2 fpos = fract(st);
    //move ipos  to 30
    vec2 pos = vec2(st* random(fpos));

    // Use the noise function
    float n = noise(pos);
    
     //color.r = gl_FragCoord.y -u_resolution.y / tan(gl_FragCoord.y -u_time)*1;
     //color.g = gl_FragCoord.y +u_resolution.y -cos(gl_FragCoord.y +u_time)*100;
     //color.b = gl_FragCoord.x +u_resolution.y -sin(gl_FragCoord.x +u_time)*400;

    //outputColor = vec4(color.r,color.g,color.b,1);
     float grey =0.21 *color.r +0.91 *color.g +0.07 * color.b;

  outputColor = vec4(color.r * u_colorFactor + grey * (1.0 - u_colorFactor),color.g * u_colorFactor + grey * (1.0 - u_colorFactor),color.b * u_colorFactor + grey * (1.0 - u_colorFactor),1.0);

i re arrange my code and implemented this again and it works thanks

1 Like