在 iOS 中使用 FFMPEG 解码后图像不能显示,以及运行 iFrameExtractor 出错

2014-07-20 00:32:59 +08:00
 qinng
在iOS代码中,我用FFMPEG把视频文件解码成RGB24之后,保存为RGB文件可以正常播放,但把RGB转为UIImage之后无法显示图像。
CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault;
CFDataRef data = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault,(uint8_t*)(pFrameYUV->data[0]), (pCodecCtx->width)*(pCodecCtx->height)*3,kCFAllocatorNull);
CGDataProviderRef provider = CGDataProviderCreateWithCFData(data);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();

CGImageRef cgImage = CGImageCreate(pCodecCtx->width,
pCodecCtx->height,
8,
24,
pCodecCtx->width * 3,
colorSpace,
bitmapInfo,
provider,
NULL,
YES,
kCGRenderingIntentDefault);
CGColorSpaceRelease(colorSpace);

UIImage* image = [[UIImage alloc]initWithCGImage:cgImage];
self.imageTest.image = image;

CGImageRelease(cgImage);
CGDataProviderRelease(provider);
CFRelease(data);
谁能看出来这是哪里错了吗?

还有一个问题是我运行iFrameExtractor这个例子时出错。其实之前已经可以正常运行了的,但后来手误把文件夹给删了,按之前的方法重新弄一个就出错了。
iFrameExtractor[4850:60b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIImageView 0x9e3dc00> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key window.'
*** First throw call stack:
(
0 CoreFoundation 0x033cb1e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0261e8e5 objc_exception_throw + 44
2 CoreFoundation 0x0345afe1 -[NSException raise] + 17
3 Foundation 0x011a5d9e -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
4 Foundation 0x011121d7 _NSSetUsingKeyValueSetter + 88
5 Foundation 0x01111731 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
6 UIKit 0x01773508 -[UIView(CALayerDelegate) setValue:forKey:] + 168
7 Foundation 0x01173b0a -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412
8 UIKit 0x019bb1f4 -[UIRuntimeOutletConnection connect] + 106
9 libobjc.A.dylib 0x026307de -[NSObject performSelector:] + 62
10 CoreFoundation 0x033c676a -[NSArray makeObjectsPerformSelector:] + 314
11 UIKit 0x019b9d4d -[UINib instantiateWithOwner:options:] + 1417
12 UIKit 0x019bbada -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 165
13 UIKit 0x0170461b -[UIApplication _loadMainNibFileNamed:bundle:] + 58
14 UIKit 0x01704949 -[UIApplication _loadMainInterfaceFile] + 245
15 UIKit 0x0170354e -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 543
16 UIKit 0x01717f92 -[UIApplication handleEvent:withNewEvent:] + 3517
17 UIKit 0x01718555 -[UIApplication sendEvent:] + 85
18 UIKit 0x01705250 _UIApplicationHandleEvent + 683
19 GraphicsServices 0x03bbaf02 _PurpleEventCallback + 776
20 GraphicsServices 0x03bbaa0d PurpleEventCallback + 46
21 CoreFoundation 0x03346ca5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
22 CoreFoundation 0x033469db __CFRunLoopDoSource1 + 523
23 CoreFoundation 0x0337168c __CFRunLoopRun + 2156
24 CoreFoundation 0x033709d3 CFRunLoopRunSpecific + 467
25 CoreFoundation 0x033707eb CFRunLoopRunInMode + 123
26 UIKit 0x01702d9c -[UIApplication _run] + 840
27 UIKit 0x01704f9b UIApplicationMain + 1225
28 iFrameExtractor 0x00001f1d main + 125
29 iFrameExtractor 0x00001e95 start + 53
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
3539 次点击
所在节点    问与答
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/123530

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX