On Nov 29, 2014, at 2:31 AM, Ben <[email protected]> wrote:
> I'm trying to get the video dimensions by using
> AVCaptureInputPortFormatDescriptionDidChangeNotification however the width &
> height returns a number way higher than I am expecting.
> Expecting 320/480 or similar but getting width = 1088784512, height =
> 1819304813.
>
> Any ideas what I am doing wrong?
>
>
> -
> (void)avCaptureInputPortFormatDescriptionDidChangeNotification:(NSNotification
> *)notification {
>
> AVCaptureInputPort * captureInputPort = notification.object;
>
>
> CMFormatDescriptionRef formatDescription =
> captureInputPort.formatDescription;
> if (formatDescription) {
> CMVideoDimensions dimensions =
> CMVideoFormatDescriptionGetDimensions(formatDescription);
>
>
> }
>
>
> Printing description of dimensions:
> (CMVideoDimensions) dimensions = (width = 1088784512, height = 1819304813)
>
>
>
> Printing description of formatDescription:
> <CMAudioFormatDescription 0x19acd1f0 [0x3aa74460]> {
> mediaType:'soun'
> mediaSubType:'lpcm'
> mediaSpecific: {
> ASBD: {
> mSampleRate: 44100.000000
> mFormatID: 'lpcm'
> mFormatFlags: 0xc
> mBytesPerPacket: 2
> mFramesPerPacket: 1
> mBytesPerFrame: 2
> mChannelsPerFrame: 1
> mBitsPerChannel: 16 }
> cookie: {(null)}
> ACL: {(null)}
> }
> extensions: {<CFBasicHash 0x19acd250 [0x3aa74460]>{type = immutable
> dict, count = 1,
> entries =>
> 2 : <CFString 0x3ab282e0 [0x3aa74460]>{contents =
> "VerbatimSampleDescription"} = <CFData 0x19acdca0 [0x3aa74460]>{length = 52,
> capacity = 52, bytes = 0x00000034736f7774000000000000ffff ...
> 0000000200000002}
> }
> }
> }
Looks like you’re assuming that the formatDescription is a
CMVideoFormatDescriptionRef, when printing it shows that it is a
CMAudioFormatDescriptionRef. I don’t have direct experience with the API, but
would guess that CMVideoFormatDescriptionGetDimensions doesn’t return any
useful value when passed a CMAudioFormatDescriptionRef.
As to why you’re receiving a notification for an audio format or input port
instead of the video format/port you’re expecting, that’s left to you to
determine.
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]