Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9018225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:28:18+00:00 2026-06-16T04:28:18+00:00

I want to return CMsampleBuffer from following Method -(CMSampleBufferRef )readMovieFrames{ AVURLAsset *mAsset = [[AVURLAsset

  • 0

I want to return CMsampleBuffer from following Method

-(CMSampleBufferRef )readMovieFrames{

    AVURLAsset *mAsset = [[AVURLAsset alloc] initWithURL:sampleURL options:NULL];
    tracks = [mAsset tracksWithMediaType:AVMediaTypeVideo];

//here getting one index

    AVAssetTrack *mTrack = [tracks objectAtIndex:0];


    NSString* key = (NSString*)kCVPixelBufferPixelFormatTypeKey;
    NSNumber* value = [NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA];
    NSDictionary * settings = [[NSDictionary alloc] initWithObjectsAndKeys:value, key, nil];

    AVAssetReaderTrackOutput *mOutput = [[AVAssetReaderTrackOutput alloc]
                                         initWithTrack:mTrack outputSettings:settings];


    AVAssetReader *mReader = [[AVAssetReader alloc] initWithAsset:mAsset error:nil];

    [movieFile readNextVideoFrameFromOutput:mOutput];

    [mReader addOutput:mOutput];
    [mReader startReading];

    CMSampleBufferRef sampleBuffer=[mOutput copyNextSampleBuffer];

    CVImageBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
    CVPixelBufferLockBaseAddress( pixelBuffer, 0 );

    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 600, 400, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, CVPixelBufferGetBaseAddress( pixelBuffer ));
    CVPixelBufferUnlockBaseAddress( pixelBuffer, 0 );

    return sampleBuffer;
}

here in view did load

[super viewDidLoad];
NSMutableArray *arrImages=[[NSMutableArray alloc] init];

//    filter = [[GPUImagePixellateFilter alloc] init];
//    filter = [[GPUImageUnsharpMaskFilter alloc] init];

filter = [[GPUImageDissolveBlendFilter alloc] init];
[(GPUImageDissolveBlendFilter *)filter setMix:0.5];

sampleURL = [[NSBundle mainBundle] URLForResource:@"Sydney" withExtension:@"m4v"];
movieFile = [[GPUImageMovie alloc] initWithURL:sampleURL];
movieFile.runBenchmark = YES;
movieFile.playAtActualSpeed = YES;
[movieFile addTarget:filter];
[movieFile prepareForImageCapture];


[movieFile processMovieFrame:[self readMovieFrames]];

MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL: sampleURL];
[player prepareToPlay];
[player.view setFrame: CGRectMake(0, 100, 320, 240)];  // player's frame must match parent's
[self.view addSubview: player.view];


AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:sampleURL];
CMTime duration = playerItem.duration;
float seconds = CMTimeGetSeconds(duration);
NSLog(@"duration: %.2f", seconds);

[player play];

GPUImagePicture *overlayPicture;

for (int i=0; i<seconds; i++) {

    UIImage *image = [player thumbnailImageAtTime:i timeOption:MPMovieTimeOptionNearestKeyFrame];

    [arrImages addObject:image];

    overlayPicture= [[GPUImagePicture alloc] initWithImage:[arrImages objectAtIndex:i]];

    [overlayPicture addTarget:filter];

    [overlayPicture processImage];

    NSLog(@"Image  -0-0-0-0- %@",image);
    UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
}

// Only rotate the video for display, leave orientation the same for recrding
GPUImageView *filterView = (GPUImageView *)self.view;
[filter addTarget:filterView];

// In addition to displaying to the screen, write out a processed version of the movie to disk
NSString *pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/EditedMovie.m4v"];
unlink([pathToMovie UTF8String]); // If a file already exists, AVAssetWriter won't let you record new frames, so delete the old movie
NSURL *movieURL = [NSURL fileURLWithPath:pathToMovie];

movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(640.0, 480.0)];
[filter addTarget:movieWriter];

// Configure this for video from the movie file, where we want to preserve all video frames and audio samples
movieWriter.shouldPassthroughAudio = YES;
movieFile.audioEncodingTarget = movieWriter;
[movieFile enableSynchronizedEncodingUsingMovieWriter:movieWriter];

[movieWriter startRecording];
[movieFile startProcessing];

[movieWriter setCompletionBlock:^{
    [filter removeTarget:movieWriter];
    [movieWriter finishRecording];
}];
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:28:19+00:00Added an answer on June 16, 2026 at 4:28 am

    Check this URL. hope this answers your Question

    http://www.7twenty7.com/blog/2010/11/video-processing-with-av-foundation

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to return from a Java method a reference to a Scala object.
i want to return a string value from an anonymous method/delegate. How can i
I want to return two String arrays from a method(which populates those arrays). Both
I want to return a private field from a remoted object but i get
I want to return a set of values from function till the point they
I want to return some errors to my jquery method. What is happening is
I want to return some files in a HttpResponse and I'm using the following
I have a JavaScript method that call JQuery.get() and i want to return value
I want to return false from $.ajax when success is complete: $.ajax({ url: ''
I want to return a DataTable from DLL file that is Created from ClassLibrary

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.