在录制的视频上添加日期和时间 [英] Add Date and time on recorded video

查看:1608
本文介绍了在录制的视频上添加日期和时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In my application there feature of recording video, I want to add time and date details on the recorded video.

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

Simply i can add while it running within the app but what i want to do is If i export that video in Photo app or email that video, than also date and time should be there.

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

I checked this sample code from apple but in this text can be static that will remain same all time.

AVSimpleEditor

任何人都可以指导我或任何链接吗?如何在视频上添加时间戳详细信息..

Can any one guide me or any link ? How to add time stamp detail on video..

感谢您的帮助。

推荐答案

您可以使用Brad Larson的 GPUImage类,它允许您向图像添加过滤器和根据您的要求视频。我刚刚在我的一个项目中实现了你要求的确切内容。

You can use GPUImage Class by Brad Larson , It allows you to add filter to image and video as per your requirment . I just implement the exact thing that you asked for in one of my projects recently.

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

What i did was use UILabel as GPUImageUIElement and added it to GPUImageNormalBlendFilter. I updated the label text with every callback and it worked like a charm.

以下是代码:

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];
}];

我知道问题已经过时但可能对某人有所帮助,因为我花了一段时间才找到这个。

I Know question is old but might help someone as it took me a while to find this.

这篇关于在录制的视频上添加日期和时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆