How to obtain m4v metadata using iOS SDK - iphone

Is there a way to access the metadata (such as width and height of the video) via iOS SDK for m4v inside the resource bundle? I would like to use this info to center the video around the screen bounds.

On a mac this would be easy, because you can utilise the spotlight metadata, but on iOS it's slightly more complicated. A couple of suggestions:
The easiest way to do this is just to load your movie into an MPMoviePlayerController and check the naturalSize property. There are a number of other properties including playableDuration. The downside to this is you have to load the movie into an MPMoviePlayerController, which may be fine for you if you're going to play the file straight away.
The harder but more efficient way is to use the open source libmediainfo library, but it's obviously more complex to integrate than using an MPMoviePlayerController 'out of the box'.

Related

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.

Does the SDK support #2x files for video

We are using the MPMoviePlayerController to control video playback, I just wanted to know (as I couldnt find any mention online) whether it took advantage of #2x files when displayed on iPod4/iPhone4, like the UIImage does
No, #2X it's only for UIimages.
It doesn't do it automatically like UIImage will. But you could always implement a system your self. Using a subclass, category or just in your current code before set what file is played by the movie player. So the code would be something like. If it has a retina display append #2x to the file path.

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

iPhone. Is it possible to load a video file and select a specific frame?

Is it possible to load a short video file and - once loaded - select a specific frame and display that frame in a view? If there is no native support for this, how about an open source alternative?
Thanks in advance.
-Doug
I think that in iphone programming you're stuck with the fullscreen video solution proposed by apple. You could write your own controller to do it differently, but i think it could be difficult to achieve good performances and you're cut out of the app-store for sure.
edit:
looks like in iphone sdk 3.2 apple added something for you:
The MPMoviePlayerController class
defines an interface for managing the
playback of a movie. Playback occurs
either in full-screen mode or in a
custom view that is vended by the
movie player controller. You can
incorporate the view into your own
view hierarchies or use a
MPMoviePlayerViewController object to
manage the presentation for you.
and again
Behavior in iPhone OS 3.1 and Earlier
In iPhone OS 3.1 and earlier, this
class implemented a full-screen movie
player only. After creating the movie
player and initializing it with a
single movie file, you called the play
method to present the movie. (The
definition of the play method has
since moved out of this class and into
the MPMediaPlayback protocol.) The
movie player object itself handled the
actual presentation of the movie
content.
i haven't tested it yet but have a look at the official documentation under MPMoviePlayerController Class Reference, it may help.

Is it possible to play a movie file in a UIView layer?

If yes, what movie format has best performance? And how would a simple setup look like? I have some views, and I want to play a short movie inside a view (not fullscreen). The movie is about 5 seconds long.
Looks like the system frameworks only support playing video full screen with the MPMoviePlayerController. Supported formats are basically flavors of H.264 and MPEG-4; more in the documentation.
Theoretically, you might be able to roll your own decoding and playback code, but I doubt you'd get acceptable performance. (And most of the Open Source media player examples I can think of are GPL. Not that I imagine they'd fare much better.)
If it's only 5 seconds long, you can fake it by playing the audio file in the background, and an animated UIImageView at the same time. Lots of apps do this like the ~50 or so baby sign language ones.