V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
qinng
V2EX  ›  问与答

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

  •  
  •   qinng · 2014-07-20 00:32:59 +08:00 · 3660 次点击
    这是一个创建于 3761 天前的主题,其中的信息可能已经有所发展或是发生改变。
    在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)
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3064 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 13:37 · PVG 21:37 · LAX 05:37 · JFK 08:37
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.