objective c - How can I display the result from [AVPlayerItemVideoOutput copyPixelBufferForItemTime:]? -


i have cadisplaylink, , avplayeritemvideooutput under ios 6.1. have cvpixelbufferref , want modify (e.g. display timecode on video, etc). think have modify part implemented correctly , have cgimageref or cgcontextref new frame.

my question now: how supposed display that? found special classes os x, none ios. there any? can use gpuimage framework shortcut? (but dedicated gpuimage movie player doesn't audio :( ).

( there book advanced avfoundation? )

here code, drawn text isn't shown on video (video , audio plays nicely). code called (i checked) via cadisplaylink callback.

cvpixelbufferref ref = [_playeritemvideooutput copypixelbufferforitemtime:_playeritem.currenttime itemtimefordisplay:nil]; size_t width = cvpixelbuffergetwidth(ref); size_t height = cvpixelbuffergetheight(ref); size_t bytes_per_row = cvpixelbuffergetbytesperrow(ref);  cvpixelbufferlockbaseaddress(ref, 0); void *pxdata = cvpixelbuffergetbaseaddress(ref); cgcolorspaceref rgbcolorspace = cgcolorspacecreatedevicergb(); cgcontextref context = cgbitmapcontextcreate(pxdata, width,         height, 8, bytes_per_row, rgbcolorspace, kcgimagealphanoneskipfirst); cgcontextretain(context);  cgcontextselectfont(context, "helvetica", 10, kcgencodingmacroman); cgcontextsettextdrawingmode(context, kcgtextfill); cgcontextshowtextatpoint(context, 0.0, 0.0, "o brother thou?", 20);  cgcolorspacerelease(rgbcolorspace); cvpixelbufferunlockbaseaddress(ref, 0); cgcontextrelease(context); cvbufferrelease(ref); 

edit: problem is/was, can't display modified pixel buffer avplayerlayer. have output via other methods (on mac there avsamplebufferoutput, no public equivalent on ios :/ ).

i think asked wrong question. seems want process video in real time ask cgimageref?

i recommend study session 517 of wwdc 2012. there sample code osx , ios, download [related] avfoundation samples , check them out. search new ios 6 methods narrow quest.

once have code in place (basically cadisplaylink callback you'll extract pixel buffers copypixelbufferforitemtime:itemtimefordisplay: @ right times) can modify pixel buffer gpuimage, core image or own opengl code. must done when video play in avplayer, otherwise able display images not audio. @ least not synchronized audio.

i may more if ask specific.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -