Вопрос

Как я могу сделать процесс, который фильтрует сохраненное видео в фото библиотеке в iOS?

Я получил URL-адреса видео в библиотеке, используя anseetslibrary Framework,

Затем сделал предварительный просмотр видео.

Следующий шаг, я хочу сделать процесс фильтрации для видео с помощью Cifilter.

В случае выпуска реального времени, я сделал процесс фильтрации видео с использованием AVCaptureVideodataUTUTSPAMPERBUFFERDELEGET.

Но в случае сохраненного видео я не знаю, как сделать процесс фильтра.

Я пользуюсь Avasset?Если я должен использовать это, как я могу отфильтровать его?и как его сохранить?

Всегда спасибо.

Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top