Vector of ofVideoPlayer* - segmentation fault

#1

Hi all,

I have a around 2 hours of HD video material (each clip about a minute long), that i put into a vector of pointers to ofVideoPlayers. Loading and playing them is no problem. But as soon as i use loadAsync the program crashes with a segfault. I can however change the speed…

The machine I am using is a Nvidia Jetson Nano - which uses the ARM7 nightly build of openframeworks with Platform aarch64. As explained here: Setup Nvidia Jetson Nano for openFrameworks

ofApp.h

vector<ofVideoPlayer*> videos;

ofApp.cpp
in setup():

if (nFiles) {
	for (diaNum = 0; diaNum < vecSize; diaNum++) {
        	// first 3 videos added to the vector
	       filePath = dir.getPath(diaNum);
	       ofVideoPlayer *vid;

	       vid = new ofVideoPlayer();

           vid->setPixelFormat(OF_PIXELS_NATIVE);
	       vid->load(filePath);  
	       videos.push_back(vid);   
	
	       (*videos[diaNum]).setSpeed(0.5);   
           (*videos[diaNum]).play();   
	       (*videos[diaNum]).setPaused(true);  		

	       cout << "FilePATH: " << dir.getPath(diaNum) << endl;
	}
}
else ofLog(OF_LOG_WARNING) << "Could not find folder";

videos[frameIndex]->setPaused(false);
       

in update():

//update timers
timer.update();
bool changeFrame = timer.gotEndOfCycle();
alpha = timer.getOpacity() / 255.;
	
if (changeFrame) {		
	frameIndex++;

	if (diaNum == nFiles) {
		diaNum = 0;
	}
	if (frameIndex > maxIndex) {
		frameIndex = 0;
	}

	filePath = dir.getPath(diaNum);
	
    videos[getFrameIndex(frameIndex - 1, maxIndex)]->stop(); //stuck for ~5 seconds or crashes
	videos[getFrameIndex(frameIndex - 1, maxIndex)]->close(); //crashes
	videos[getFrameIndex(frameIndex - 1, maxIndex)]->loadAsync(filePath); //crashes
	videos[getFrameIndex(frameIndex - 1, maxIndex)]->setSpeed(1.5); // does NOT crash

	diaNum++;
	
	triggerPause = true;
}

videos[frameIndex]->update();
videos[getFrameIndex(frameIndex + 1, maxIndex)]->update();

I checked all the forum posts and I cant see what s wrong with the code, the adresses the pointers are pointing to, are the same as in setup … and as changing speed does work, it seems to me that the problem lies in the ofGstVideoPlayer ?

Thanks in advance,
numu

1 Like