ofVideoPlayer get Texture to ofImage

Hi guys,

I’m beginner with openframeworks and I got stuck since few days with simple problem. I want to create video gallery with thumbnails, so I want to get texture from frame of video file and put it ofImage variable.

Here is some piece of code, but it crashes on readToPixels:

testApp.h

  
  
	        ofTexture movieTexture;  
		ofImage imageTexture;  
		ofPixels pixelFrame;  
	        ofVideoPlayer* fingerMovie;  
  

testApp.cpp

  
  
void testApp::getTexturetoImage()  
{  
	movieTexture = fingerMovie->getTextureReference();  
	pixelFrame.allocate(movieTexture.texData.width,movieTexture.texData.height,OF_IMAGE_COLOR);  
  
	if(pixelFrame.isAllocated())  
	{  
		movieTexture.readToPixels(pixelFrame);  
		imageTexture.setFromPixels(pixelFrame);  
		imageTexture.draw(90,400);  
	}  
}  
  
void testApp::setVideoPlayer()  
{  
	fingerMovie = new ofVideoPlayer();  
	fingerMovie->loadMovie("movies/Welcome to Earth [HD].mp4");  
	fingerMovie->setFrame(150);  
	fingerMovie->play();  
}  
void testApp::setup(){  
	ofEnableSmoothing();   
	ofBackground(100);   
	ofSetFrameRate(30);  
	setVideoPlayer();  
	getTexturetoImage();  
}  
  
//--------------------------------------------------------------  
void testApp::update(){  
	if(fingerMovie != nullptr)  
	{  
		fingerMovie->idleMovie();  
	}  
}  
  
//--------------------------------------------------------------  
void testApp::draw(){  
	if(fingerMovie != nullptr)  
	{  
	updateMoviePlayer();  
	movieTexture.draw(600,300,200,100);  
	imageTexture.draw(700,500,200,100);  
	}  
}  
  
void testApp::updateMoviePlayer()  
{  
		fingerMovie->draw(90,150,400,300);  
}  
  
  
  

Another thing is that I should use getTexture() instead of getTextureReference, but I don’t know how to deal with it, application crashes when I’m trying to use that. Please, help me!

The way i tend to copy video pixels into images is like this

  
  
ofVideoPlayer p;  
ofImage image;  
//....  
//play the video  
//....  
image.setFromPixels(p.getPixelsRef());  
image.saveImage("path/to/desired/file/withAName.png");