我正在尝试为视频添加指定颜色的边框以获得类似http://d.pr/i/1WXs
的内容这就是我正在做的事情
GPUImageNormalBlendFilter *blendFilter = [GPUImageNormalBlendFilter new];
_movie = [[GPUImageMovie alloc] initWithURL:_movieUrl];
_sourcePicture = [[GPUImagePicture alloc] initWithImage:[self imageWithColor:RGBACOLOR(255, 0, 0, 0.5f)]];
[_sourcePicture processImage];
[_sourcePicture addTarget:blendFilter atTextureLocation:0];
[_movie addTarget:blendFilter atTextureLocation:1];
[blendFilter addTarget:_videoView];
[_movie startProcessing];
据我了解,转换过滤器无法调整视频大小以添加空格? 我怎样才能做到这一点?
感谢。
答案 0 :(得分:0)
使用Transform&链解决裁剪过滤器。
[transformFilter setBackgroundColorRed:1 green:0 blue:0 alpha:0]; // For example
// Calculate scale for exact crop size
// For 16x9 scale = 16 * videoSize.height / (9 * videoSize.width);
CGFloat scale = [self scaleForCropSize:self.cropSize];
transformFilter.affineTransform = CGAffineTransformMakeScale(scale, scale);
CGSize videoSize = [self.paramsContainer.videoTrack naturalSize];
CGRect cropRegion;
if (videoSize.width > videoSize.height) {
cropRegion = CGRectMake((1 - scale) / 2, 0, scale, 1);
} else {
cropRegion = CGRectMake(0, (1 - scale) / 2, 1, scale);
}
cropFilter.cropRegion = cropRegion;