How can i detect CODEC in MPMoviePlayerController in iphone-sdk - iphone

When Video is made with the Sorenson CODEC... MPMoviePlayerController just plays Audio(and not the Video), Instead i want to show my custom error message at this point. How can i detect which CODEC is used by particular File programmatically ... ?
EDIT: I am not using Quick time in my code so that solution won't work
Thanks

Check this documentation to understand the Quicktime file format :
http://developer.apple.com/library/mac/documentation/QuickTime/QTFF/qtff.pdf
The field you are looking for is the "vfmt" code that is containing the video fourcc code (there is one for each video track in your file, so take care if your file is containing several video tracks). The fourcc codes for Sorenson codec are "SVQ1" and "SVQ3".
Now you'll have to write some code to parse the QT file to find the correct atom, extract the "vfmt" value and compare it to SVQ1/SVQ3 !
Apple is providing some classes to easily parse quicktime files, but it is only available on Mac OS, not on iOS !

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 .

How to display song lyric line by line while playing a song in iPhone? [duplicate]

I am currently creating an app that plays music. I would like to add a feature that shows the music lyrics while the music plays, with the current position of the text marked to match the current position in the song. The Bouncing Ball effect, just like you see on every Karaoke screen as the song plays.
I have been looking into extending my caf files, adding "string chunks" and then reading them out again. Is this the correct way to do this? Does anybody know of a better/easier/normal way to achieve my goal?
As I am not sure how I would synchronize everything, I would be happy for any suggestions, code examples or helpful comments. Maybe somebody has done this before and would be happy to advise me.
Thanks in advance for any information offered.
Alan
Most Karaoke apps these days use the .Kar file extension. It's a slightly butchered MIDI file with some annotations and it's pretty small in file size.
I have no idea where you'd start to read it though. You could ask these guys: http://www.ikaraokeapp.com/
Most little devs are happy to help others out.
The standard way to do this is using the kar file extension as suggested by the other answer. Here are some more details.
The .kar extension just signifies that a standard midi file contains lyric information. To build your karaoke player you need to do two things: play the instrument part of the midi file and display the lyrics.
This can be achieved in two ways. Either you could use the built in MusicPlayer to play the midi file and then access the lyric information from a virtual endpoint: here
You would need to access midi meta messages with codes 0x01 (text) or 0x05 (lyric). These messages store the lyric data as a series of hex numbers where each hex number represents an ascii character.
This approach allows you to play the MIDI file and access the lyrics. The problem is that you need to be able to display the lyrics ahead of time so the user can read them before they're played.
To do this you could parse the midi file manually: here
You would need to loop over the MIDI file and extract the text lyrics with their time stamps. Then you could display a section of lyrics ahead of time and change the colour or do a bouncing ball effect as the lyrics became due.
You should be able to do this through the MusicPlayer API, specifically the MusicTrack MIDIMetaEvent assuming midi type music is acceptable.
MIDIMetaEvent
Describes a MIDI metaevent such as lyric text, time signature, and so on.
typedef struct MIDIMetaEvent {
UInt8 metaEventType;
UInt8 unused1;
UInt8 unused2;
UInt8 unused3;
UInt32 dataLength;
UInt8 data[1];
} MIDIMetaEvent;
Alternately, you might also made some headway looking at iD3 metadata for storing lyrics and timing info.
Either way, there will be lots of file prep in getting the lyrics and timing into the music files.

Recording Audio and Video using AVFoundation frame by frame

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.

want to create an audio playlist dynamically by using ".plist" file an then want to play it in iphone in built audio player

I want to create an audio playlist dynamically by using ".plist" file an then want to play it in iphone in built audio player. But during creation of audio list in plist there is no option in "type" to select data type for audio file.
Plz guide any one what approach I should follow ?
I'm not sure if I understood your question correctly. Can you specify what APIs you are using and what you are trying to do with more detail?
As far as Property Lists go, they are very generic so there wouldn't be anything for audio files in particular. You could specify the data type as a string.
How to approach this: First of all, you need to read the list into an NSArray and use that to generate a table view with your track listing (use tableView:didDeselectRowAtIndexPath: to start playing a track upon the user selecting it). To play a track use AVAudioPlayer.

How do you display song lyrics in Karaoke style on the iPhone?

I am currently creating an app that plays music. I would like to add a feature that shows the music lyrics while the music plays, with the current position of the text marked to match the current position in the song. The Bouncing Ball effect, just like you see on every Karaoke screen as the song plays.
I have been looking into extending my caf files, adding "string chunks" and then reading them out again. Is this the correct way to do this? Does anybody know of a better/easier/normal way to achieve my goal?
As I am not sure how I would synchronize everything, I would be happy for any suggestions, code examples or helpful comments. Maybe somebody has done this before and would be happy to advise me.
Thanks in advance for any information offered.
Alan
Most Karaoke apps these days use the .Kar file extension. It's a slightly butchered MIDI file with some annotations and it's pretty small in file size.
I have no idea where you'd start to read it though. You could ask these guys: http://www.ikaraokeapp.com/
Most little devs are happy to help others out.
The standard way to do this is using the kar file extension as suggested by the other answer. Here are some more details.
The .kar extension just signifies that a standard midi file contains lyric information. To build your karaoke player you need to do two things: play the instrument part of the midi file and display the lyrics.
This can be achieved in two ways. Either you could use the built in MusicPlayer to play the midi file and then access the lyric information from a virtual endpoint: here
You would need to access midi meta messages with codes 0x01 (text) or 0x05 (lyric). These messages store the lyric data as a series of hex numbers where each hex number represents an ascii character.
This approach allows you to play the MIDI file and access the lyrics. The problem is that you need to be able to display the lyrics ahead of time so the user can read them before they're played.
To do this you could parse the midi file manually: here
You would need to loop over the MIDI file and extract the text lyrics with their time stamps. Then you could display a section of lyrics ahead of time and change the colour or do a bouncing ball effect as the lyrics became due.
You should be able to do this through the MusicPlayer API, specifically the MusicTrack MIDIMetaEvent assuming midi type music is acceptable.
MIDIMetaEvent
Describes a MIDI metaevent such as lyric text, time signature, and so on.
typedef struct MIDIMetaEvent {
UInt8 metaEventType;
UInt8 unused1;
UInt8 unused2;
UInt8 unused3;
UInt32 dataLength;
UInt8 data[1];
} MIDIMetaEvent;
Alternately, you might also made some headway looking at iD3 metadata for storing lyrics and timing info.
Either way, there will be lots of file prep in getting the lyrics and timing into the music files.