可可 - 添加视频水印基本信息 [英] Cocoa - Add Video Watermark General Info

查看:234
本文介绍了可可 - 添加视频水印基本信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是在寻找如何以编程方式添加水印或使用可可某类覆盖的视频。不找一个一步一步(尽管这真棒),但或多或​​少地寻找,我应该开始寻找学习如何。是否有发展的框架,为这项工作。想的东西原产于可可或目标-C或C,因为我想最终给这个在iPhone上一展身手。任何帮助将是巨大的。

Just looking for how to programmatically add a watermark or some sort of overlay to video using cocoa. Not looking for a step by step ( although that would awesome ), but more or less looking for where I should start looking to learn how. Are there frameworks developed to work for this. Would like something native to cocoa or objective-c or c because I would like to eventually give this a go on the iPhone. Any help would be great.

推荐答案

我不知道,如果你的意思只是播放,或者如果你想将视频导出带水印的信息就会显示在其他玩家。

I'm not sure if you mean just for playback, or if you'd like to export a video with a watermark that'll show up on other players.

如果你的意思是只播放,你可能只需要添加在Mac和iPhone播放器查看包含水印的顶视图。

If you mean just for playback, you can probably just add a view on top of the player view on Mac and iPhone that contains the watermark.

如果您想在视频本身的水印,这是很难在Mac上,可能在iPhone上不可能没有本质上的QuickTime重写。

If you'd like a watermark on the video itself, this is hard on the Mac and probably impossible on the iPhone without essentially rewriting QuickTime.

在Mac上,code可能是这样(您需要导入QTKit):

On the Mac, the code might look like this (you need to import QTKit):

// Make a new movie so we don't destroy the existing one
QTMovie* movie = [[QTMovie alloc] initWithMovie:currentMovie 
                                      timeRange:QTMakeTimeRange(QTMakeTime(0,1000), [currentMovie duration]) 
                                          error:nil];

// Make it editable
[movie setAttribute:[NSNumber numberWithBool:YES] 
             forKey:QTMovieEditableAttribute];

//Get the size
NSValue *value = [movie attributeForKey:QTMovieNaturalSizeAttribute];
NSSize size = [value sizeValue];

// Add a new track to the movie and make it the frontmost layer
QTTrack *track = [movie addVideoTrackWithSize:size];
[track setAttribute:[NSNumber numberWithShort:-1] forKey:QTTrackLayerAttribute];    	

// Create a codec dictionary for the image we're about to add
NSDictionary *imageDict = [NSDictionary dictionaryWithObjectsAndKeys:
        @"tiff", QTAddImageCodecType,
        [NSNumber numberWithLong:codecHighQuality], QTAddImageCodecQuality, nil];


// Get the video length in QT speak

QTTime qttime = [currentMovie duration];
NSTimeInterval reftime;

QTGetTimeInterval(qttime, &reftime);

//Add the image for the entire duration of the video 

[track addImage:image forDuration:qttime withAttributes:imageDict];

// Finally, tell the track that it should use its alpha correctly

MediaHandler media = GetMediaHandler([[track media] quickTimeMedia]);
MediaSetGraphicsMode(media, graphicsModeStraightAlpha, NULL);

...这就是它!你的电影现在有水印,你可以将其导出到文件中。

... And that's it! Your movie now has a watermark, and you can export it to file.

这篇关于可可 - 添加视频水印基本信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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