Which format support the audio file with a playing video? - iphone

i am playing the video and in the background i have to play the audio file and if i do this audio is not playing its sound as it just play video is it a extension problem i am using the .mp3 for the audio and .mp4 for the video .
how can we do this we have to play simultanisouly .both the file
balraj verma

Have a look at this:
http://developer.apple.com/iphone/library/documentation/MusicAudio/Conceptual/CoreAudioOverview/CoreAudioEssentials/CoreAudioEssentials.html#//apple_ref/doc/uid/TP40003577-CH10-SW67
"To play multiple sounds simultaneously, create one playback audio queue object for each sound. For each audio queue, schedule the first buffer of audio to start at the same time using the AudioQueueEnqueueBufferWithParameters function.
Audio format is critical when you play sounds simultaneously on iPhone or iPod touch. This is because playback of certain compressed formats in iPhone OS employs an efficient hardware codec. Only a single instance of one of the following formats can play on the device at a time:
AAC
ALAC (Apple Lossless)
MP3"

Related

how to record only audio using UIImagePickerController?

I am working on media recording on IOS. I was able to record with both audio and video using UIImagePickerController. For my specification I want to record only audio. Is it possible with UIImagePickerController? or Do I need to think about other methods?
thanks.
UIImagePickerController cannot be used to record audio. Instead you should take a look at the SpeakHere sample code from Apple.
Also check Audio Queue - Recording to a compressed audio format on how to record as compressed audio format and conserve disk space.

Record video iphone and play a sound

How i can record video and play a sound at the same time? I am having trouble doing so. I am using AVFoundation
Set audio session category to AVAudioSessionCategoryPlayAndRecord?

ios - Is it possible to record audio and play video from network stream at the same time?

I'm doing research for a iPhone video chat app project.
I've tried this to capture image,
use AVCaptureVideoPreviewLayer to display camera view
and put a MPMoviePlayerController to play network stream video at the back.
They all work until I add an audio input to the AVCaptureSession.
The MPMoviePlayerController stop the AVCaptureSession if there is audio input.
I think of using AVAudioSession for both playing and recording audio and some other way to play video,
but the documentation of AVAudioPlayer said
"Apple recommends that you use this class for audio playback unless you are playing audio captured from a network stream or require very low I/O latency."
I found the Multimedia Programming Guide saying that
"To provide lowest latency audio, especially when doing simultaneous input and output (such as for a VoIP application), use the I/O unit or the Voice Processing I/O unit."
Is it the correct direction to implement video chat in iphone?

iPhone game audio and background music

Have a few questions related to adding sounds to my game, specifically intro music (for splash), background music (loop) and button event sounds. Hope you can share your knowledge on this.
1) Should I use compressed sounds or uncompressed sounds? Or perhaps a combination of the two? Are there any limitations on the iPhone hardware that I should be aware of -- for example, the ability to play multiple compressed sounds?
2) What's the best audio format for my purpose?
3) For background music, I am thinking of using AVAudioPlayer. For button event sounds, I am thinking of using AudioServicesPlaySystemSound, what do you think?
4) Any other issues I should be aware of?
Thank you!
1) According to the iPhone Application Programming Guide: "Starting in iPhone OS 3.0, nearly all supported audio formats can be used for simultaneous playback—namely, all those that can be played using software decoding, as described in Table 7-1. For the most processor-efficient multiple playback, use linear PCM (uncompressed) or IMA4 (compressed) audio."
But if you're going to be playing a lot of sounds at the same time, you should use either uncompressed or IMA4.
2) You should use the CAF file format because it gives you the most flexibility in what data format to use. You can put MP3, AAC, PCM, IMA4, and pretty much any compressed or uncompressed data in a CAF file (.caf). I typically use CAF files with IMA4 compression at mono, 16-bit, 44.1kHz.
3) That's how I do it in my apps: AVAudioPlayer for voice cues that cause the music levels to duck, and AudioServicesPlaySystemSound for buttons and other UI sound effects.
4) If you use uncompressed PCM data, the file sizes can be huge, but IMA4 is a fairly noisy compression scheme. You can use AAC but then you might be limited by how many AAC sounds you can play at once. Before iPhone OS 3.0, you could only play one AAC or MP3 sound at a time.

how can we play audio and video together in ipod/iphone?

HI all
i am playing a video(.mp4 format) without sound (i mean it doesn't have sound it is a mute video ) and in the background i am playing an audio file (.mp3 format) when i play my code through simulator it works fine as i want like when i tap on the video it is just mute but behind i am playing the audio so for user it seems that video has this sound but when i installed my code in device and play video than it doesn't work like so it play video but without sound than how can i play an audio and a video together in the above format ?
actually we are not just playing a single video or audio file it just comes from an array by choosing randomly and same for the audio file so we cann't do this i think so any other idea for it ??
Should we use another format for audio aur video for doing this thing ??
thanks for the help
Balraj verma
The problem is that the default Audio Session does not allow audio mixing.
In the Reference Library (Working with Movie Players) they say you should use a mixable category configuration for your audio session, for example the Ambient category. In the Application Delegate:
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
NSError *setCategoryError = nil;
[audioSession setCategory:AVAudioSessionCategoryAmbient error: &setCategoryError];
Apple's documentation states that some audio formats are not suited to be played back simultaneously because of hardware restrictions. See Playing Multiple Sounds Simultaneously for more details.
A solution for you would be to use PCM encoded audio which should allow simultaneous playback.
I would like to add that I managed to play two mp3 audio files at the same time on 3G and 3GS iPhones. Which shouldn't be possible according to documentation but worked for me.
You can rather use the an instance of AvAudioPlayer in a new thread. Use the following link to see how does this work
http://www.mobileorchard.com/easy-audio-playback-with-avaudioplayer/
create an instance of MPMoviePlayer to start playback of videos.
Hope this will work.
You should combine the audio and video using some video editing software like iMovie or Windows Movie Maker. Using the software to "composite" audio and video together is not a good idea and adds additional overhead, synchronization issues, etc.
As far as I know, you can't play AVAudioPlayer and MPMoviePlayer at the same time.