2013-02-15 343 views
3

在我的应用程序中有录制视频的功能,我想在录制的视频上添加时间和日期的详细信息。在录制的视频上添加日期和时间

只需在应用程序内运行时添加它,但我想要做的是如果我在Photo应用程序或电子邮件中导出视频,那么日期和时间也应该在那里。

我从苹果检查了这个示例代码,但在这个文本中可以是静态的,将始终保持相同。

AVSimpleEditor

任何一个可以指导我还是什么联系呢?如何在视频上添加时间戳详细信息。

感谢您的任何帮助。

+0

你有什么? – 2013-11-01 07:00:16

+0

@ murugha23不,还没有得到任何解决方案。 – Nikunj 2013-11-01 07:31:38

+0

向CALayer添加动态内容的可能性如何? – 2013-11-01 08:15:05

回答

2

您可以使用Brad Larson的GPUImage Class,它允许您根据需要添加图像和视频过滤器。我刚刚实施了你最近在我的一个项目中要求的确切的事情。

我所做的是使用UILabel作为GPUImageUIElement并将其添加到GPUImageNormalBlendFilter。我用每个回调更新了标签文本,并且它像魅力一样工作。

下面是代码:

filterView = [[GPUImageView alloc] initWithFrame:self.videoRecordView.frame]; 
videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset1920x1080 cameraPosition:AVCaptureDevicePositionBack]; 

movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(1920,1080)]; 

[self.view addSubview:filterView]; 
movieWriter.encodingLiveVideo = YES; 
movieWriter.encodingLiveVideo = YES; 
videoCamera.audioEncodingTarget = movieWriter; 


GPUImageNormalBlendFilter *blendFilter1 = [[GPUImageNormalBlendFilter alloc] init]; 


UILabel *timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 635, 768.0f, 50.0f)]; 

timeLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:fontSize]; 
timeLabel.textAlignment = NSTextAlignmentCenter; 
timeLabel.backgroundColor = [UIColor clearColor]; 
timeLabel.textColor = [UIColor whiteColor]; 

uiElementInput = [[GPUImageUIElement alloc] initWithView:timeLabel]; 
[uiElementInput addTarget:blendFilter1]; 
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init]; 
[dateFormatter setDateFormat:@"MMMM dd, yyyy hh : mm : ss a"]; 


[blendFilter1 addTarget:filterView]; 
[blendFilter1 addTarget:movieWriter]; 
[videoCamera addTarget:blendFilter1]; 


__unsafe_unretained GPUImageUIElement *weakUIElementInput = uiElementInput; 
    [filter setFrameProcessingCompletionBlock:^(GPUImageOutput * filter, CMTime frameTime){ 

    timeLabel.textColor =[UIColor whiteColor]; 

    float sizefont =[[[NSUserDefaults standardUserDefaults]objectForKey:KfontSize] floatValue]; 
    timeLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:(sizefont)? sizefont:30]; 
    NSDate * originalDate = [NSDate dateWithTimeIntervalSinceNow:interval]; 

    NSString *timeString=[dateFormatter stringFromDate:originalDate]; 
    timeLabel.text = [NSString stringWithFormat:@"%@", timeString]; 
    [weakUIElementInput update]; 
}]; 

我知道问题是旧的,但可能会帮助别人,因为我花了一段时间来找到这个。

1

您链接的示例显示了如何获得90%的方式。最后一步是查看AVVideoCompositionCoreAnimationTool的文档。该课程允许您将任何核心动画添加到视频中。你如何做到这一点是通过将动画添加到CALayer

如果您使用CATextLayer,则可以为字符串属性设置动画效果。

+0

谢谢Paul,我正在检查文档 – Nikunj 2013-02-15 12:59:04