2

According to:

Can I use AVFoundation to stream downloaded video frames into an OpenGL ES texture?

It's posible to get the frames from an remote media. However I've been trying the suggestion, but the documentation about the use of AVPlayerItemVideoOutput is not very clear, it seems to have a delegate method outputMediaDataWillChange, which have the pointer to the AVPlayerItemVideoOutput instance.

Maybe I'm doing a wrong assumption , but this delegate method it's called every time the data will change?. It is the right place to get the CVPixelBuffer?.

Community
  • 1
  • 1
lalfonso
  • 33
  • 1
  • 5

3 Answers3

0

Probably not. You will need to update the texture on the same thread as your GL is doing all the work or some other thread with shared context, not on the thread you get a delegate callback that the media data has been updated. You could put some boolean value to true in this callback to notify the GL thread that the buffer is ready and it should collect it. Alternatively you could push some "target selector pair" to be performed to on the GL thread to collect the data (system like "performSelectorOnMainThread") but then again you should ask yourself if such pair already exists on the stack in case that media update is changing data faster then your GL is refreshing... I any case if you use that delegate and not handle it correctly it will not update the texture at all or it will block your GL thread.

Matic Oblak
  • 16,318
  • 3
  • 24
  • 43
0

Method outputMediaDataWillChange will only be called after registering requestNotificationOfMediaDataChangeWithAdvanceInterval, usually when you will pause your app or the like.

You can access the pixel buffer in your display link hook. Look for hasNewPixelBufferForItemTime and copyPixelBufferForItemTime in Apple sample (it's for OS X, but basically it's the same for iOS.

djromero
  • 19,551
  • 4
  • 71
  • 68
0

I think, you should use ffmpeg library, as this library can connect any streaming server and get the picture in raw data. After that you can do anything with that pic.

Tarum
  • 161
  • 5