English 中文(简体)
Continuing the prev question of ASSETWriterInput for making Video from UIImages on Iphone Issues
原标题:

I want a new thread because I like to post some codes , the little comment section wouldn t do it.

Thanks peter Deweese previously, but I still have issues..

I have a loop, getting a screen capture 30 times. Each time I got an image I call convert to append that image to video. After that, close the video file

so, anything I did wrong. on this particular one I am not getting the video

[self init_video]; for (index=0; index< 30; index++) {

[self.view.layer renderInContext:ctx];
global_image = UIGraphicsGetImageFromCurrentImageContext();

    //Once I have UIImageview of global_image I call convert
    [self convert];

} [self end_video];

////////////////////////////////////////////////////////////

-(void) init_video { ........video setup and setup adaptor

AVAssetWriterInputPixelBufferAdaptor * avAdaptor = [AVAssetWriterInputPixelBufferAdaptor assetWriterInputPixelBufferAdaptorWithAssetWriterInput:writerInput sourcePixelBufferAttributes:NULL];

[videoWriter addInput:writerInput]; [videoWriter startWriting];

[videoWriter startSessionAtSourceTime:kCMTimeZero]; }

/////////////////////////////////////////////////////

-(void) convert {..........getting the image pixel buffer

CMTime frameTime = CMTimeMake(1, 15);

CMTime lastTime=CMTimeMake(index, 15); //index is from 0 to 29 of the loop above

CMTime presentTime=CMTimeAdd(lastTime, frameTime);

//according to Peter DeWeese, needs to call twice to make it work.

[avAdaptor appendPixelBuffer:pixelBuffer withPresentationTime:lastTime];

[avAdaptor appendPixelBuffer:pixelBuffer withPresentationTime:presentTime];

}

//////////////////////////////////////////////////////////

-(void) end_video { [writerInput markAsFinished];

     //want 2 seconds of video, with 15 frame for each seconds.
[videoWriter endSessionAtSourceTime:CMTimeMake(30, 15)];  


[videoWriter finishWriting];

}

问题回答

暂无回答




相关问题
How to implement Webcam effects?

And now for some fun... I d like to reproduce the technology behind Logitech Video Effects as seen here: http://www.youtube.com/watch?v=7qZLgA2g7Ow4 How do they track the user s head, eyes and mouth (...

Are there any algorithms for removing lighting from a video?

Are there any algorithms for removing lighting from video? I have a video in which some objects are too strongly lit. How might I remove lighting from that objects without corrupting the entire video?

Solid FFmpeg wrapper for C#/.NET

I have been searching the web for some time for a solid FFmpeg wrapper for C#/.NET. But I have yet to come up with something useful. I have found the following three projects, but all of them apears ...

How to perform video editing with Silverlight?

I would like to port an ActiveX of mine (to Silverlight) that have the following features: Embedding a logo image in any video file. Embedding subtitles in any video file. Cropping any video file (...

stitching videos together using ffmpeg on the command line

Does anybody know how to stitch two (or more) videos together using ffmpeg (or another cli)? This is assuming that all the videos are in the same format and the video format being used allows for ...

Using C++ in xcode for image and video processing

I am studying in the area of image and video processing - specifically in the field of pattern recognition (objects, people etc.). I wish to use a programming language to apply the transformation to ...

热门标签