how to convert data to mp4 format - iphone

in my apps im able downloaded a short video file from my server using NSURLConnection but the data i received is in data format which cannot be played using MPMoviePlayerViewController. My question is: it is possible to convert NSdata to mp4 file? and how do i play it using MPMoviePlayerViewController. would really appreciate some code snippets cos i'm at a lost. Thanks in advance.

Look at AVAssetWriter. This allows you to encode image frames and audio into a MOV or MP4 file using hardware-accelerated methods where possible.

Related

iOS: Record audio in other format than caf

I am working on audio recording. I am able to record my audio in caf (Core audio format). Now I want to record sound in .mp3 or .amr.
I tried a lot of google but didn't found anything. I am not sure if my steps following work:
Write that Audio with .caf extention to document dir
Read data from that file
write the file again with .mp3 or .amr extention
I have 100% doubt that this will not going to work as this will just re save file with some other extension. This won't change audio codec.
I thought that for converting any format whether it is audio or video we need to change its codecs and data sequence.
Please also suggest me any player which don't play .caf files not anything else. So I can make sure that my files are converted successfully.
UPDATE Please also let me know that the way I am re-writing data with different extension is correct in the way I am needed?
You might be interested in the iPhoneExtAudioFileConvertTest example.
The MP3 format is however not available due to patents, maybe you can use LAME.
From the Document The Basics: Audio Codecs, Supported Audio Formats, and Audio Sessions

Mp3 from iPhone library convert to PCM?

I need to read some audio file from the iPhone/iPod library and then pass it to a function to do some detection.
I need to decode from MP3 to PCM in order to pass at the function some chunks of data. My question is: what's the best ay to do this? I know that it can be done by using AVAsset by reading and writing different file or using ExtAudioFileconvert (as seen in apple example). What's the most efficient?

How to convert a wav or caf audio file on iPhone

I am working on a iPhone IM app, which support audio message. I've tried caf and wav format follow "Speak Here", but the files are too large to be send through the internet. So I'm wondering if I can convert any of them to some small format, like mp3 or amr.
Thank you for you help in advance.
CoreAudio has som great built-in datatypes for just this Core Audio Data Types
Use iLBC, short for Internet Low Bitrate Codec, to record your audio. Limit your sample rate to 8kHz.
If you insist on mp3, use LAME - the open source MP3 encoder library to convert your audio.
After you've recorded the audio file, the iOS AVFoundation AVAsset Reader/Writer APIs can be used to convert the file by, say, reading a .wav and writing AAC or other compressed file type.

Converting video to .mp4 format within the app before uploading to server

Can u help me in this issue ? I am recording videos through my appliction.Is it posiible to record the video in the mp4 format or otherwise i need to convert it to .mp4 format recording it in default format before uploading it to the server? Is there any possibilities to convert the video to .mp4 format through coding, if possible please post a sample for it.
See Using FFMPEG library with iPhone SDK for video encoding

Is it possible at all to record audio in AAC/MP4 format on the iPhone?

In this link it says it does:
http://developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/MultimediaPG/UsingAudio/UsingAudio.html
However I have searched for an example that works on the web and can only see people complaining they can't get it to work. I have a working AudioQueue example for PCM but the very moment I switch this to AAC initialization fails. SpeakHere example also only uses PCM.
Has anyone ever managed to make this work or has a link to a code snippet that works?
Basically iPhone only record PCM. To get an AAC encoded file the original PCM stream should be stored into a AudioFile and then this AudioFile should be converted to AAC.
There's no way to record and convert on the fly on iPhone unless you include a third-party library that will do this for you.