Filtrado de video guardado en iOS
-
14-11-2019 - |
Pregunta
¿Cómo puedo hacer el proceso que filtrando el video guardado en la biblioteca de fotos en iOS?
Tengo URLS de videos en la biblioteca utilizando ActivesLibrary Framework,
Luego, hizo una vista previa para el video.
Paso siguiente, quiero hacer un proceso de filtrado para el video usando CIFILTER.
En caso de problema en tiempo real, hice el proceso de filtro de video usando AVcaptureVideodataOutputSampleBufferDelegate.
Pero en caso de video guardado, no sé cómo hacer un proceso de filtro.
¿Utilizo avasset?Si debo usar eso, ¿cómo puedo filtrarlo?¿Y cómo guardarlo?
Siempre gracias.
Solución
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.
}
Otros consejos
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.