我已经从Github获取了AVAnimator库的最新代码。除了AutoPropertyRelease.h和AutoPropertyRelease.m之外,我还添加了文件夹AVAnimator和LZMASDK。
我使用以下代码播放带alpha通道的视频(从另一个AVAnimator应用示例中采用):
CGRect iPhoneExplosionRect = CGRectMake(0, -2, 640/2, 480/2);
CGRect iPadExplosionRect = CGRectMake(0, -5, 840, 630);
NSString *rgbResourceName = @"ExplosionAdjusted_rgb_CRF_30_24BPP.m4v";
NSString *alphaResourceName = @"ExplosionAdjusted_alpha_CRF_30_24BPP.m4v";
// Output filename
NSString *tmpFilename;
NSString *tmpPath;
tmpFilename = @"Explosion.mvid";
tmpPath = [AVFileUtil getTmpDirPath:tmpFilename];
// Set to TRUE to always decode from H.264
BOOL alwaysDecode = FALSE;
if (alwaysDecode && [AVFileUtil fileExists:tmpPath]) {
BOOL worked = [[NSFileManager defaultManager] removeItemAtPath:tmpPath error:nil];
NSAssert(worked, @"could not remove file %@", tmpPath);
}
// This loader will join 2 H.264 videos together into a single 32BPP .mvid
AVAssetJoinAlphaResourceLoader *resLoader = [AVAssetJoinAlphaResourceLoader aVAssetJoinAlphaResourceLoader];
resLoader.movieRGBFilename = rgbResourceName;
resLoader.movieAlphaFilename = alphaResourceName;
resLoader.outPath = tmpPath;
//resLoader.alwaysGenerateAdler = TRUE;
AVAnimatorMedia *media = [AVAnimatorMedia aVAnimatorMedia];
media.resourceLoader = resLoader;
self.expMedia = media;
// Frame decoder will read from generated .mvid file
AVMvidFrameDecoder *aVMvidFrameDecoder = [AVMvidFrameDecoder aVMvidFrameDecoder];
media.frameDecoder = aVMvidFrameDecoder;
// Create layer that video data will be directed into
CGRect expFrame;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
expFrame = iPhoneExplosionRect;
} else {
expFrame = iPadExplosionRect;
}
CALayer *layer = [CALayer layer];
layer.frame = expFrame;
}
if (FALSE) {
layer.backgroundColor = [UIColor orangeColor].CGColor;
}
[self.view.layer addSublayer:layer];
AVAnimatorLayer *animatorLayer = [AVAnimatorLayer aVAnimatorLayer:layer];
self.expAnimatorLayer = animatorLayer;
// Finally connect the media object to the layer so that rendering will be
// sent to the layer.
[animatorLayer attachMedia:media];
//media.animatorRepeatCount = 3;
//media.animatorRepeatCount = 30;
//media.animatorRepeatCount = INT_MAX;
[media prepareToAnimate];
一旦prepareToAnimate
被命中,应用程序就会在断言中失败,如下所述
** Assertion failure in -[AVMvidFrameDecoder advanceToFrame:], /Users/user/Documents/.../AVAnimator/AVMvidFrameDecoder.m:844
...*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'framebuffer num bytes'
我使用的架构(32位和64位)是否会导致它或其他什么?
我希望有人能让我走上正轨
AF
答案 0 :(得分:1)
我研究了这种断言以及可能被复制的不同方式。我尝试不正确地设置arch标志,在可执行文件中只包含32位或仅64位代码,并在64位设备和模拟器上进行测试。我无法重现这个问题,目前尚不清楚它是如何发生的。为了收集更多信息,我添加了一个在分配帧缓冲区时以DEBUG或OPT模式编译的额外检查,是否可以从github中提取最新版本的AVAnimator或从patch here获取补丁。请确保您的代码版本中没有修改任何定义,并且您使用的是最新版本的Xcode。