Is this a bug? ofVideoPlayer + ofSystemLoadDialog + crash

Hi,
I’m trying to modify "fileOpenSaveDialog"example (utils) using a vector of ofVideoPlayer instead of ofImage.When I open the dialog for first time and select a video folder every thing is fine. If I repeat the operation a second time my program will crash. Populating the vector with ofImage objects don’t cause the crash. So I guess is something related to ofVideoPlayer, right?
or Am I doing something wrong?
what could be a solution or workaround?

here my code:

void testApp::setup()
ofBackground(0, 0, 0);
gui.setup();
gui.add(opendir.setup("select video directory "));
}
void testApp::update(){
}
void testApp::draw(){
    ofSetColor(255, 255, 255);
    if(opendir){
        //Open the Open File Dialog
		ofFileDialogResult openFileResult= ofSystemLoadDialog("Select video dir", true);
		//Check if the user opened a file
		if (openFileResult.bSuccess){
			//We have a file, check it and process it
			processOpenFileSelection(openFileResult);
		}else {
			ofLogVerbose("User hit cancel");
		}
    }
    gui.draw();
}
void testApp::processOpenFileSelection(ofFileDialogResult openFileResult){
    ofLog() << "getPath(): "  <<  openFileResult.getPath();
    files.allowExt("mov");
    files.listDir(openFileResult.getPath());
    ofLog() << "video " << files.getPath(counter);
    loadedVideos.clear()
}

thanks in advance!
husk

Hi, I added a couple of lines trying to explain better my problem:

.h

#include "ofMain.h"
#include "ofxGui.h"

class testApp : public ofBaseApp{

	public:
		void setup();
		void update();
		void draw();


		void processOpenFileSelection(ofFileDialogResult openFileResult);

        ofDirectory files;
        vector<ofVideoPlayer>loadedVideos;
        ofxPanel gui;
        ofxButton opendir;

.ccp;

void testApp::setup()
    ofBackground(0, 0, 0);
    gui.setup();
    gui.add(opendir.setup("select video directory "));
    }
    void testApp::update(){
    }
    void testApp::draw(){
        ofSetColor(255, 255, 255);
        if(opendir){
            //Open the Open File Dialog
    		ofFileDialogResult openFileResult= ofSystemLoadDialog("Select video dir", true);
    		//Check if the user opened a file
    		if (openFileResult.bSuccess){
    			//We have a file, check it and process it
    			processOpenFileSelection(openFileResult);
    		}else {
    			ofLogVerbose("User hit cancel");
    		}
        }
        gui.draw();
    }
    void testApp::processOpenFileSelection(ofFileDialogResult openFileResult){
ofLog() << "getPath(): "  <<  openFileResult.getPath();
files.allowExt("mov");
files.listDir(openFileResult.getPath());
ofLog() << "video " << files.getPath(counter);
loadedVideos.clear();
ofVideoPlayer video;
video.loadMovie(files.getPath(counter));
video.play();
loadedVideos.push_back(video);
    }

The first time I click the button and choose a video directory every thing works as aspected, but the second time it crash.

What I’m doing wrong?
any suggestion is really appreciated.
thanks
husk

Not sure what it actually does. But have you tried to close the already loaded movies before loading new ones?
http://www.openframeworks.cc/documentation/video/ofVideoPlayer.html#show_closeMovie

this is a known problem in 0.8.1, it’s fixed in master already, if you don’t want to download the full github version you can fix it downloading this file only:

https://raw.githubusercontent.com/openframeworks/openFrameworks/master/libs/openFrameworks/utils/ofSystemUtils.cpp

in libs/openFrameworks/utils

Hey @arturo,
thanks for the help.
I changed ofSystemUtils.cpp with the new one but now I get an error compiling OF:

./../../libs/openFrameworks/utils/ofSystemUtils.cpp: In function 'std::string gtkFileDialog(GtkFileChooserAction, std::string, std::string)':
../../../libs/openFrameworks/utils/ofSystemUtils.cpp:212:49: error: 'getGstMainLoop' is not a member of 'ofGstUtils'
   g_main_context_invoke(g_main_loop_get_context(ofGstUtils::getGstMainLoop()), &file_dialog_gtk, &dialogData);
                                                 ^
../../../libs/openFrameworks/utils/ofSystemUtils.cpp: In function 'void ofSystemAlertDialog(std::string)':
../../../libs/openFrameworks/utils/ofSystemUtils.cpp:280:51: error: 'getGstMainLoop' is not a member of 'ofGstUtils'
     g_main_context_invoke(g_main_loop_get_context(ofGstUtils::getGstMainLoop()), &alert_dialog_gtk, &dialogData);
                                                   ^
../../../libs/openFrameworks/utils/ofSystemUtils.cpp: In function 'std::string ofSystemTextBoxDialog(std::string, std::string)':
../../../libs/openFrameworks/utils/ofSystemUtils.cpp:590:49: error: 'getGstMainLoop' is not a member of 'ofGstUtils'
   g_main_context_invoke(g_main_loop_get_context(ofGstUtils::getGstMainLoop()), &text_dialog_gtk, &dialogData);
                                                 ^
makefileCommon/compile.core.mk:228: recipe for target '../../../libs/openFrameworksCompiled/lib/linux/obj/Debug/libs/openFrameworks/utils/ofSystemUtils.o' failed
make[1]: *** [../../../libs/openFrameworksCompiled/lib/linux/obj/Debug/libs/openFrameworks/utils/ofSystemUtils.o] Error 1
makefileCommon/compile.core.mk:207: recipe for target 'Debug' failed
make: *** [Debug] Error 2
there has been a problem compiling Debug OF library

I’m a gnu/linux debian sid kernel 3.13.6-031306-generic

husk

mmh, i thought it might be completely compatible with 0.8.1, you can try downloading ofGst* in video too, or just download the full version from github