Cocoa - ビデオ透かしを追加する 一般情報
-
22-09-2019 - |
質問
Cocoaを使用してビデオにウォーターマークまたはある種のオーバーレイをプログラムで追加する方法を探しています。ステップバイステップを探しているのではなく(それは素晴らしいことですが)、多かれ少なかれ、どこからどのように学ぶべきかを探しています。これを実現するために開発されたフレームワークはありますか。最終的には iPhone で試してみたいので、cocoa または object-c または c にネイティブなものが欲しいです。助けていただければ幸いです。
解決
あなただけの再生のために意味場合、私はわからない、またはあなたが他のプレイヤーに表示されます透かしがビデオをエクスポートしたい場合。
あなただけの再生のために意味した場合、あなたはおそらく、透かしが含まれているMacとiPhone上のプレーヤーのビューの上にビューを追加することができます。
あなたがビデオ自体に透かしをたい場合は、は、これは基本的にQuickTimeのを書き換えることなく、iPhone上のMacのハード、おそらく不可能です。
Macでは、コードは(あなたが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);
...そして、それはそれです!あなたの映画は今、透かしを持っており、あなたはそれをファイルにエクスポートすることができます。
所属していません StackOverflow