相关疑难解决方法(0)

视频中的AVfoundation模糊背景

在我的应用程序中,我修复了1280 x 720的合成渲染大小.因此,如果要导入任何肖像视频,那么我必须在中心显示带有填充和视频宽高比的模糊背景.像这样:

https://www.youtube.com/watch?v=yCOrqUA0ws4

我实现了使用两种视频AVMtableComposition,但我不知道如何模糊特定的背景音轨.我在我的代码中做了以下事情:

self.composition = [AVMutableComposition composition];
AVAsset *firstAsset = [AVAsset assetWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"ScreenFlow_Blend" ofType:@"mp4"]]];


[self addAsset:firstAsset toComposition:self.composition withTrackID:1];
[self addAsset:firstAsset toComposition:self.composition withTrackID:2];
//  [self addAsset:ThirdAsset toComposition:self.composition withTrackID:3];

AVAssetTrack *backVideoTrack = [firstAsset tracksWithMediaType:AVMediaTypeVideo][0];;

self.videoComposition = [AVMutableVideoComposition videoComposition];
self.videoComposition.renderSize = CGSizeMake(1280, 720);
self.videoComposition.frameDuration = CMTimeMake(1, 30);

AVMutableVideoCompositionInstruction *instruction = [AVMutableVideoCompositionInstruction videoCompositionInstruction];
instruction.timeRange = [backVideoTrack timeRange];

CGFloat scale = 1280/backVideoTrack.naturalSize.width;
CGAffineTransform t = CGAffineTransformMakeScale(scale, scale);
t = CGAffineTransformTranslate(t, 0, -backVideoTrack.naturalSize.height/2 + self.videoComposition.renderSize.height/2);

AVMutableVideoCompositionLayerInstruction *frontLayerInstruction = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstruction]; …
Run Code Online (Sandbox Code Playgroud)

video avfoundation video-editing ios

14
推荐指数
1
解决办法
1209
查看次数

标签 统计

avfoundation ×1

ios ×1

video ×1

video-editing ×1