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

Offline Video Rendering

$
0
0

@Takky wrote:

Hi!

I’m looking for an alternative to matlab for video processing. I’ve tried OpenCV and it works fine for this, but OF seems to be better designed, has a larger community and has better options if I want to expand into interactive real-time stuff or graphics.

OF seems to be mostly geared toward real-time applications however, and I can’t figure out how to process each frame in a video sequentially. This is the simple code I’ve written that is supposed to just read each frame in a video and save them:

void ofApp::setup()
{
	video.load("video.MP4");
	idx = 0;
}
void ofApp::update()
{
	idx++;
	if (idx == video.getTotalNumFrames())
	{
		OF_EXIT_APP(0);
	}
	video.setFrame(idx); // ofVideoPlayer::nextFrame() doesen't seem to work.
	video.update();

	ofImage img(video.getPixels());
	img.saveImage("test_" + std::to_string(idx) + ".png");
}

However, this just saves empty black images. video.getCurrentFrame() reports that the correct frame is set on the video object. If I call video.play() in ofApp::setup(), the images are correctly saved but it just selects whatever frame is ‘current’ in the real-time video stream, which results in tons of frames being skipped in between.

Is there any way of sequentially iterating through each frame in a video or is OF just the wrong tool for this kind of thing?

Posts: 6

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles