相关疑难解决方法(0)

ASSETWriterInput用于在Iphone问题上从UIImages制作视频

我尝试了以下两种方法来附加UIImages pixelbuffer ASSETWriterInput.除了视频文件中没有数据外,一切看起来都不错.怎么了?

1适配器类

AVAssetWriterInputPixelBufferAdaptor * avAdaptor = [AVAssetWriterInputPixelBufferAdaptor assetWriterInputPixelBufferAdaptorWithAssetWriterInput:writerInput sourcePixelBufferAttributes:NULL];

[avAdaptor appendPixelBufferixelBuffer withPresentationTime:CMTimeMake(1, 10)];
Run Code Online (Sandbox Code Playgroud)

2制作

// Create sample buffer.
CMSampleBufferRef sampleBuffer = NULL;
result = CMSampleBufferCreateForImageBuffer(kCFAllocatorDef ault, pixelBuffer, true, NULL, NULL, videoInfo, &timing, &sampleBuffer);

// Ship out the frame.
NSParameterAssert(CMSampleBufferDataIsReady(sample Buffer));
NSParameterAssert([writerInput isReadyForMoreMediaData]);
BOOL success = [writerInput appendSampleBuffer:sampleBuffer];
Run Code Online (Sandbox Code Playgroud)

iphone video image avfoundation

26
推荐指数
1
解决办法
2万
查看次数

使用AVVideoCompositionCoreAnimationTool在CALayer中将视频与静态图像混合

我试图混合视频,来自相机与静态图像(水印).

我在这里查看了一些问题/答案和一些例子,包括来自Apple的WWDC AVEditDemo,并以下面的代码结束.遗憾的是,导出的视频不包含带图像的图层.有任何想法吗?

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

/// incoming video
NSURL *videoURL = [info valueForKey:UIImagePickerControllerMediaURL];

/// UIImage into CALayer
UIImage *myImage = [UIImage imageNamed:@"m1h.png"];
CALayer *aLayer = [CALayer layer];
aLayer.contents = (id)myImage.CGImage;

AVURLAsset* url = [AVURLAsset URLAssetWithURL:videoURL options:nil];
AVMutableComposition *videoComposition = [AVMutableComposition composition];
NSError *error;
NSFileManager *fileManager = [NSFileManager defaultManager];

AVMutableCompositionTrack *compositionVideoTrack = [videoComposition  addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];
AVAssetTrack *clipVideoTrack = [[url tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];
[compositionVideoTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, [url duration])  ofTrack:clipVideoTrack atTime:kCMTimeZero error:&error];

AVMutableVideoComposition* videoComp = [[AVMutableVideoComposition videoComposition] retain];
videoComp.renderSize = CGSizeMake(640, …
Run Code Online (Sandbox Code Playgroud)

objective-c avfoundation calayer ios4 ios

15
推荐指数
2
解决办法
1万
查看次数

标签 统计

avfoundation ×2

calayer ×1

image ×1

ios ×1

ios4 ×1

iphone ×1

objective-c ×1

video ×1