Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ofVideoPlayer AVFoundation, setPosition can work with arbitrary frames. #8189

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

dimitre
Copy link
Member

@dimitre dimitre commented Nov 13, 2024

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 dimitre marked this pull request as ready for review November 13, 2024 17:21
@artificiel
Copy link
Contributor

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

@dimitre
Copy link
Member Author

dimitre commented Nov 14, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants