在我的應用程序中有錄製視頻的功能,我想在錄製的視頻上添加時間和日期的詳細信息。在錄製的視頻上添加日期和時間
只需在應用程序內運行時添加它,但我想要做的是如果我在Photo應用程序或電子郵件中導出視頻,那麼日期和時間也應該在那裏。
我從蘋果檢查了這個示例代碼,但在這個文本中可以是靜態的,將始終保持相同。
任何一個可以指導我還是什麼聯繫呢?如何在視頻上添加時間戳詳細信息。
感謝您的任何幫助。
在我的應用程序中有錄製視頻的功能,我想在錄製的視頻上添加時間和日期的詳細信息。在錄製的視頻上添加日期和時間
只需在應用程序內運行時添加它,但我想要做的是如果我在Photo應用程序或電子郵件中導出視頻,那麼日期和時間也應該在那裏。
我從蘋果檢查了這個示例代碼,但在這個文本中可以是靜態的,將始終保持相同。
任何一個可以指導我還是什麼聯繫呢?如何在視頻上添加時間戳詳細信息。
感謝您的任何幫助。
您可以使用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];
}];
我知道問題是舊的,但可能會幫助別人,因爲我花了一段時間來找到這個。
您鏈接的示例顯示瞭如何獲得90%的方式。最後一步是查看AVVideoCompositionCoreAnimationTool的文檔。該課程允許您將任何核心動畫添加到視頻中。你如何做到這一點是通過將動畫添加到CALayer。
如果您使用CATextLayer,則可以爲字符串屬性設置動畫效果。
謝謝Paul,我正在檢查文檔 – Nikunj 2013-02-15 12:59:04
你有什麼? – 2013-11-01 07:00:16
@ murugha23不,還沒有得到任何解決方案。 – Nikunj 2013-11-01 07:31:38
向CALayer添加動態內容的可能性如何? – 2013-11-01 08:15:05