Better Video Performance

Greetings,

I’m am trying to do some video work with multiple videos, different speeds, fast switching, etc. but ofVideoPlayer keeps lagging on me and also seems to crash/freeze if the playback rate goes to high.

I tried ofxHapPlayer but it doesn’t allow access to pixels, so I can’t use CV libraries with it.

Any thoughts on what video player I should be using for this?

Thank you!

T

depending on the platform you are using codec choice can make a big difference - some codecs are really optimised for playback in one direction at a fixed speed, and are really laggy at seeking, playing backwards etc, have a look at what you need and maybe do some tests with other codecs with closer keyframes, different algorithms etc.

Ah, interesting. Thank you @danb . Yes, I’ll do some testing. For what it’s worth, I’m on OS Catalina 10.15.7 and of_v0.11.0.

I was doing some more poking around–does anyone know if ofxAVFVideoPlayer is still supported? The internet “reviews” seem to be very positive on it but I’m definitely getting some problems.

Thank you!

Hi @tedmoore,

What’s the resolution and length of your videos?

For your first needs (multiple videos, fast switching, different speeds, seeking, …) You will most likely find the best performance with hardware accelerated video engines. These keep the load on CPU and HDD low and do the hard decompression work on the GPU. Such engines include ofxHapPlayer and my own addon ofxHPVPlayer. However, these addons don’t provide pixel access since this would require reading the un/decompressed pixels back from the GPU and…defeating the whole purpose.

For lengthy videos in HD+, you’re probably best off using platform specific video frameworks (AVFoundation on Mac). For shorter lengths, and smaller sizes, you might use image sequences that are easy to decode (e.g. JPEG, or even uncompressed if you have the HDD size) to buffer frames in RAM. This way you have full access to the pixels, although RAM will be the limiting factor here.

Best
Vincent

depending on what you want you can try codecs that do not do differential compression (ie compression between frames) as these have poorer performance in random frame seeking and in playing anything other than forwards, but you compromise on file size and some other areas. It used to be a thing (anyone with more uptodate knowledge on the latest codecs?) that frame/image sizes on 8 pixel multiples (eg 800x600px) decompress marginally faster than those on odd frame sizes. As @Vjacobs says try the jpeg codec perhaps as a comparison or if you’re feeling hardcore and it’s installed try the apple animation codec…

Thanks @Vjacobs and @danb. The videos are all 1920x1080 30 fps and around 1 minute long (I imagine using about 12-15 videos in the final product). Thanks for the pointers–I’ll render to JPEG and Animation and see if that makes a difference!

@Vjacobs, do you know what the current / best AVFoundation player implementation in oF is right now? I tried AVFVideoPlayer, but was not successful. It seemed just out of date / no longer supported.

Thanks for your help!

hello,
i did a project earlier this year, where we needed forward and backward jumping to specific frames. turned out that i was not the easiest job to do.
we tried different codes. h264, prores, photojpeg. different results on different platforms. in the end we went for image sequences.
if ram and audio is not a limitation, then this could be an option for you as well. there are a couple of addons available for managing image sequences.
this addon is still incomplete, but might be a good starting point in case you go that route.

1 Like

Hi @tedmoore,

If I’m not mistaken, using ofVideoPlayer on a recent Mac will automatically choose AVFoundation as the video backend, so that’s probably your best starting point.

Photo-JPEG or Motion-JPEG (quality 75%) would be my try-out when rendering a video. These tend to process fast when playing.

Best
Vincent

1 Like