[Reprinted] source code sharing of iPhone recording screen and sound mixed implementation

Source: Internet
Author: User

From http://www.cocoachina.com/iphonedev/toolthain/2011/1010/3342.html

 

 

 

The source code is shared by tanhaogg, a Forum member. The recording screen and sound effect functions are implemented.

because the recording screen function needs to be added to the project some time ago, like Tom, you can record and share the video.
I have never been familiar with audio and video, and this information is hard to find.

one of the foreign forums wrote a custom view called screencaptureview (the specific Code can be selected by Google ), the main principle is to regularly paint the screen, and then build audio files based on the key frame, but the efficiency is not very good, the actual work There are still many problems.

So I like to stand on the shoulders of giants and start YY from here. I wrote a thcapture Class Based on its principle (why do I always like the beginning of th, I really don't understand, haha). It is mainly used to set recording-related attributes,
In addition, there is a thcaptureutilities class, which currently provides a method to achieve the mixing of video and audio.

1. The following describes some of the methods:
Thcapture has three attributes:
Framerate is used to set the frame rate for recording. It is the number of frames recorded in a second.
Capturelayer is used to set the layer you want to record.
Delegate is Program Everyone understands

There are two recording-related methods
// Start recording
-(Bool) startrecording;
// End recording
-(Void) stoprecording;

Two recording callback Methods
// Recording successful
-(Void) recordingfinished :( nsstring *) outputpath;
// Recording failed
-(Void) recordingfaild :( nserror *) error;

2. The directory in the thcaptureutilities class has only one class method.
// The audio and video merging. Action format is as follows:
//-(Void) mergedidfinish :( nsstring *) videopath witherror :( nserror *) error;
+ (Void) mergevideo :( nsstring *) videopath andaudio :( nsstring *) audiopath andtarget :( ID) Target andaction :( SEL) action;

You can understand the role of this method based on the method name.

currently, the code can work well, but the recorded results are not very good and need to be optimized, it is expected that some performance optimizations will be provided by the following experts:
for convenience, I wrote an example to achieve that 10 seconds of video recording will be used and saved to the album, download, try out, and provide comments

Source codeDownload: Thscreencaptureviewtest_1.1.0_latest version. Zip (552 K)

Original post address: http://www.cocoachina.com/bbs/read.php? Tid-73869.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.