문제

iOS의 사진 라이브러리에서 저장된 비디오를 필터링하는 방법은 무엇입니까?

AssetSlibrary 프레임 워크를 사용하여 라이브러리의 동영상 URL이 있습니다

그런 다음 비디오에 대한 미리보기를 작성했습니다.

다음 단계에서는 Cifilter를 사용하여 비디오에 대한 필터링 프로세스를 만들고 싶습니다.

실시간 이슈의 경우 AVCAPTUREVIDEODATAUTPUTSAMPLEBUFFERDELEGETSAMPLEBIDEODELEGET을 사용하여 비디오 필터 프로세스를 만들었습니다.

그러나 저장된 비디오의 경우 필터 프로세스를 만드는 방법을 모르겠습니다.

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