size - How to use custom video resolution when use AVFoundation and AVCaptureVideoDataOutput on mac -


i need process each frame of captured video frame, although avcapturedevice.formats provided many different dimension of frame sizes, seems avcapturesession support frame sizes defined in presets.

i've tried set avcapturedevice.activeformat before avcaptureinputdevice or after, no matter setting set, if set avcapturesessionpresethigh in avcapturesession, give me frame of 1280x720. similar , if set avcapturesessionpreset 640x480, can frame size of 640x480.

so, how can set custom video frame size 800x600? using media foundation under windows or v4l2 under linux, it's easy set custom frame size when capture.

it seems not possible under mac.

set kcvpixelbufferwidthkey , kcvpixelbufferheightkey options on avcapturevideodataoutput object. minimal sample below ( add error check ).

_sessionoutput = [[avcapturevideodataoutput alloc] init];  nsdictionary *pixelbufferoptions = [nsdictionary dictionarywithobjectsandkeys:                               [nsnumber numberwithdouble:width], (id)kcvpixelbufferwidthkey,                               [nsnumber numberwithdouble:height], (id)kcvpixelbufferheightkey,                               [nsnumber numberwithunsignedint:kcvpixelformattype_32bgra], (id)kcvpixelbufferpixelformattypekey,                               nil]; [_sessionoutput setvideosettings:pixelbufferoptions]; 

note: width/height override session preset width/height (if different).


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -