Iphone 在录制的视频中添加日期和时间

Iphone 在录制的视频中添加日期和时间,iphone,objective-c,video-recording,Iphone,Objective C,Video Recording,在我的应用程序中有录制视频的功能,我想在录制的视频上添加时间和日期细节 简单地说,我可以在应用程序中运行时添加,但我想做的是,如果我在照片应用程序中导出该视频或通过电子邮件发送该视频,那么日期和时间也应该在那里 我检查了来自苹果的这个示例代码,但在本文中可以是静态的,并且始终保持不变 有人能指引我或任何链接吗?如何在视频中添加时间戳详细信息 谢谢您的帮助。您链接的示例向您展示了如何获得90%的成功率。最后一步是查看文档中的内容。此类允许您将任何核心动画添加到视频中。如何做到这一点是通过将动画添

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

简单地说,我可以在应用程序中运行时添加,但我想做的是,如果我在照片应用程序中导出该视频或通过电子邮件发送该视频,那么日期和时间也应该在那里

我检查了来自苹果的这个示例代码,但在本文中可以是静态的,并且始终保持不变

有人能指引我或任何链接吗?如何在视频中添加时间戳详细信息


谢谢您的帮助。

您链接的示例向您展示了如何获得90%的成功率。最后一步是查看文档中的内容。此类允许您将任何核心动画添加到视频中。如何做到这一点是通过将动画添加到

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

Brad Larson可以使用它,它允许您根据需要向图像和视频添加过滤器。我只是实现了你最近在我的一个项目中要求的东西

我所做的是将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];
}];

我知道这个问题很老,但可能会帮助一些人,因为我花了一段时间才找到这个问题。

你有什么发现吗?@murugha23没有,还没有找到任何解决方案。给CALayer添加动态内容的可能性如何?@murugha23嗯,不确定,我当时尝试过各种方法,但没有成功。我也尝试过添加CATextlayer,但这是最后一个/第一个值。好的,谢谢您的时间!