Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

ofVideoPlayer shows black frame sometimes when loading

$
0
0

@hamoid wrote:

// .h
class ofApp : public ofBaseApp {
    public:
        void setup();
        void update();
        void draw();
        void keyPressed(int key);
        ofVideoPlayer vid;
        int id {1};
};
// .cpp
void ofApp::setup() {
    ofSetBackgroundColor(255);
}

void ofApp::update() {
    if(vid.isLoaded()) {
        vid.update();
    }
}

void ofApp::draw() {
    if(vid.isLoaded() && vid.getCurrentFrame() >= 0) {
        vid.draw(0, 0, 400, 200);
    }
}

void ofApp::keyPressed(int) {
    // vid.close(); // stops working
    vid.loadAsync("/path/tut" + ofToString(1 + (++id % 7)) + ".mp4");
    vid.play();
    vid.setLoopState(ofLoopType::OF_LOOP_NORMAL);
}

Why can it be that while loading a video a black frame is flashed during one frame? I tried checking if the video is loaded, allocated, the frame not being -1 (sometimes it is), but none of the tests help with this.

Mmm… by looking at the gst code, it seems like bLoaded is never set to false, unless you close() it. But if you do then you can’t load other movies. Wouldn’t it make sense to set it to false when starting to load, and to true when loaded? Or what’s the right approach to switch movies?

Posts: 5

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles