iOSで保存されたビデオフィルタリング
-
14-11-2019 - |
質問
iOSのフォトライブラリに保存されたビデオをフィルタリングするプロセスを作成する方法は?
アセトケードライブラリフレームワークを使用してライブラリ内のビデオのURLを手に入れました、
その後、ビデオのプレビューを作成しました。
次のステップ、私はCiFilterを使用してビデオのフィルタ処理プロセスを作りたい。
リアルタイムの問題の場合は、AvCaptureVideDataOutputSampleBufferDelegateを使用してビデオフィルタプロセスを作成しました。
しかし保存されたビデオの場合は、フィルタプロセスの作成方法がわかりません。
アバセットを使いますか?それを使用しなければならない場合は、どのようにフィルタをフィルタリングできますか?そしてそれを保存する方法?
常にありがとうございました。
解決
I hope this will help you
AVAsset *theAVAsset = [[AVURLAsset alloc] initWithURL:mNormalVideoURL options:nil];
NSError *error = nil;
float width = theAVAsset.naturalSize.width;
float height = theAVAsset.naturalSize.height;
AVAssetReader *mAssetReader = [[AVAssetReader alloc] initWithAsset:theAVAsset error:&error];
[theAVAsset release];
NSArray *videoTracks = [theAVAsset tracksWithMediaType:AVMediaTypeVideo];
AVAssetTrack *videoTrack = [videoTracks objectAtIndex:0];
mPrefferdTransform = [videoTrack preferredTransform];
NSDictionary *options = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:kCVPixelFormatType_32BGRA] forKey:(id)kCVPixelBufferPixelFormatTypeKey];
AVAssetReaderTrackOutput* mAssetReaderOutput = [[AVAssetReaderTrackOutput alloc] initWithTrack:videoTrack outputSettings:options];
[mAssetReader addOutput:mAssetReaderOutput];
[mAssetReaderOutput release];
CMSampleBufferRef buffer = NULL;
//CMSampleBufferRef buffer = NULL;
while ( [mAssetReader status]==AVAssetReaderStatusReading ){
buffer = [mAssetReaderOutput copyNextSampleBuffer];//read next image.
}
他のヒント
You should have a look at CVImageBufferRef pixBuf = CMSampleBufferGetImageBuffer(sbuf) then you can have the image pointer first address, so you can add filter to pixBuf, but i find that the performance is not good, If you have any new idea,we can discuss about it further.
所属していません StackOverflow