openFrameworks icon indicating copy to clipboard operation
openFrameworks copied to clipboard

ofVideoPlayer AVFoundation, setPosition can work with arbitrary frames.

Open dimitre opened this issue 1 year ago • 4 comments

by lowering seekToTime tolerance to zero it will force the video frame to be displayed correctly.

Today if I load a video recorded with a camera, lets say Sony alpha 6500 in h264, it makes one keyframe each second. if I'm trying to setPosition in an arbitrary position it will only display one frame per second (the keyframe)

with this change we assure it will be positioned in the correct frame even if it takes more cpu cycles to calculate (in the case of random access or backwards access). it doesn't change anything for normal play because frame difference will be accumulating.

quick way of testing

	float pos = ofMap(mouseX, 0, ofGetWindowWidth(), 0, 1);
	video.setPosition(pos);
	video.update();

dimitre avatar Nov 13 '24 17:11 dimitre

it's great to be able to do that!

however it might also be good to have the option to maintain the current (default) to retrieve only keyframes as inter-frame decode presumably takes more CPU it will change the performance of existing code. ex:

video.setTolerance(ofVideoPlayer::TOLERANCE_ZERO);
video.setTolerance(ofVideoPlayer::TOLERANCE_INFINITY); // historical default

artificiel avatar Nov 14 '24 21:11 artificiel

We can optionally expose something like that if it is useful I can only see a setPosition that just works. the historical implementation is not good, I know people gave up using videoPlayer on macOS (which performs great btw)

dimitre avatar Nov 14 '24 22:11 dimitre

@ofTheo greattt news about the release! take a look at this one when you have time I know a project was moved from OF to another platform because of this one

dimitre avatar May 03 '25 16:05 dimitre

closes https://github.com/openframeworks/openFrameworks/issues/4538

dimitre avatar Nov 12 '25 15:11 dimitre