Recording Audio and Video using AVFoundation frame by frame - iphone

How to record audio and video using AVFoundation frame by frame in iOS4?

The AVCamDemo you mention is close to what you need to do and should be able to use that as reference, among those these are the following classes you need to use in order to achive what you are trying... All the classes are part of AVFoundation, you need
AVCaptureVideoDataOutput and AVCaptutureAudioDataOutput - use these classes to get raw samples from the video camera and the microphone
Use AVAssetWriter and AVAssetWriterInput in order to encode the raw samples into a file - the following sample mac OS X project shows how to use these classes (the sample should work for ios too), however they use an AVAssetReader for input (it reencodes a movie file) instead of the Camera and microphone... You can use the outputs mentioned above as the input in your case to write what you want
That should be all you need in order to achieve what you want to do...
Heres a link showing how to use VideoDataOutput
Hope it helps

If you are a registered developer, look at the videos from the 2011 WWDC (which you can find by searching in the developer portal). There are two sessions relating to AVFoundation. There was also some sample code from one of the WWDC sessions, which was extremely useful.

Related

AVFoundation: How to write video to file in real time instead of using exportAsync?

AVFoundation has been quite a struggle for me because most of the examples and documentation out there are in Obj-c.. As my title states, I would like to write to file in real time instead of calling exportAsync once the user has finished recording their video.
If anyone can offer some advice or documentation on how to do this it would be greatly appreciated!
It's not clear where your video is coming from, butexportAsync makes it sound like you're using AVAssetExportSession with an existing file or composition.
capture your video (and audio?) frames
a. if from an existing composition or file, with AVAssetReader
b. if from the camera, with AVCaptureSession etc
progressively write the frames to file using AVAssetWriter & AVAssetWriterInput
If you're expecting the writing to file to be interrupted for some reason,
consider setting the AVAssetWriter's movieFragmentInterval property to something small .

iOS: core animation to video

I'm making a photo gallery app. I use the photos as slides and shows them one by one with transactions made by core animation.
Now I need to turn this process in to a video so that I can share it on Youtube, but I don't know where to start or which reference should I read.
To make video in iphone you can AVAssetWriter.
Also have a look this post. You can capture your animation as images and make the video.
The AVAsset Apple APIs is used to do this sort of thing is. But be warned, it is not easy to use. If you would like to check out a working example Xcode project, see AVDecodeEncode. This example shows decoding from h.264 and then encoding the result back to h.264. You could write all you own code to do this, but just be aware that it is not for the faint of heart.

iOS Capturing Video

I want to make an app for the iPhone with the ability to record video. One thing I want to do with the video once it's recorded, is to take the audio from it and alter it, such as make it sound feminine or masculine etc. I've never done this before but is it better to use AVFoundation or UIImagePickerController. I've read that the UIImagePickerController is easier to use but will it allow be to extract and edit the audio of the recorded video and put it back in?
Any help or suggestions as to how to approach this are appreciated.
Thanks
It is easiest to capture with UIImagePickerController if you do not need to alter it live. Once the video is captured and you have altered the audio track somehow, write it again using AVFoundation's AVMutableComposition and an audio mix.

iPhone video capture (best method)

I am curious about the new APIs for iPhone iOS: AVCapture...
Does this include a documented way to grab a screenshot of the camera preview? The doc seems a bit confusing to me, and since it is out of NDA now, I thought I would post my question here.
Many thanks,
Brett
With AVFoundation you can grab photos from the camera session...The way it works is you use one of the subclasses of AVCaptureOutput in order to get what you need, for still images you are going to want to use the AVCaptureSTillImageOutput subclass, here is a link AVCaptureStillImageOutput ref. Besides that you also have AVCaptureMovieFileOutput which is used to record a quicktime movie from the capture session to a file, AVCaptureVideoDataOutput which allows you to intercept uncompressed individual frames from the capture session, you also have audio outputs which you can use as well...hope this helps

Audio/Voice Visualization

Hey you Objective-C bods.
Does anyone know how I would go about changing (transforming) an image based on the input from the Microphone on the iPhone?
i.e. When a user speaks into the Mic, the image will pulse or skew.
[edit] Anyone have any ideas, I have (what is basically) a voice recording app. I just wanted something to change as the voice input is provided. I've seen it in a sample project, but that wasn't with an UIImage. [/edit]
Thanking you!!
Apple put together some great frameworks for this! The AVFoundation framework and CoreAudio framework will be the most useful to you.
To get audio level information AVAudioRecorder is useful. Although it is made to be used for recording, it also provides levels data for the microphone. This would be useful for deforming your image base on how loud the user is shouting at his phone ;)
Here is the apple documentation for AVAudioRecorder: AVAudioRecorder Class Reference
A bit more detail:
// You will need an AVAudioRecorder object
AVAudioRecorder *myRecorderObject;
// To be able to get levels data from the microphone you need
// to enable metering for your recorder object
[myRecorderObject prepareToRecord];
myRecorderObject.meteringEnabled=YES;
// Now you can poll the microphone to get some levels data
float peakPower = [myRecorderObject peakPowerForChannel:0];
float averagePower = [myRecorderObject averagePowerForChannel:0];
If you want to see a great example of how an AVAudioRecorder object can be used to get levels data, check out this tutorial.
As far as deforming your image, that would be up to an image library. There are a lot to choose from and some great ones from apple. I am not familiar with anything though so that might be up for someone else to answer.
Best of luck!
You may try using gl-data-visualization-view extensible framework in order to visualize your sound levels.