Should ofAVFoundationPlayer be able to play an .h264 file?

I have some .h264 files that I am trying to play on the Mac. These play fine on the RPi with the native ofVideoPlayer however on OS X they don’t seem to be recognized.

I’m thinking this is because AVFoundation wants MPEG4 (see around the 11 minute mark here ) but wanted to make sure I wasn’t missing something simple

yes linux uses gstreamer which has lots of different demuxers for any weird format while avfoundation probably only suports mov or mp4 containers.

If you need to play those formats in osx you can always use ofxGStreamer but it needs the gstreamer sdk to be installed in the system

I think ofAVFoundationPlayer can also play HLS streams. I had a small addon for this in the past before it was added in.

I did find this writeup for anyone looking to do something similar.

Ended up getting it to work. It’s a pretty specific use case so I don’t think I’ll publish it as a supported ofxAddon but here is a working implementation in case someone needs it. It basically reads H264 data, sends to AVFoundation/VideoToolbox and sends out ofPixels


Great stuff! it would be great if some of this functionality could be integrated into ofVideoPlayer.
one question: does VTDecompressionSessionRef decodes H264 using mac hardware acceleration?

I’m pretty sure it does by default - for sure on iOS

1 Like