IOS - Detect Movie Aspect Ratio

I need to detect the aspect ratio of a movie (whether 4:3 or 16:9) in order to change the size of the UIImageView within which I display a movieController. I'm using the code below. However, i'm getting 'nan' returned from an NSLog call that displays the value of the variable 'ratio'. So, it seems 'ratio' is not in the format I need it to be. I can't work out what i'm doing wrong here.
CGSize size = moviePlayerController.naturalSize;
float width = size.width;
float height = size.height;
float ratio = width / height;
if (ratio == 1.33) {
//do stuff here if aspect is 4:3
} else {
//else it's 16:9 and do different stuff
}

Ok, I figured it out...
First, you need to register for the MPMovieNaturalSizeAvailableNotification. I put this in viewDidLoad.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieNaturalSizeAvailable:)
name:MPMovieNaturalSizeAvailableNotification
object:moviePlayerController];
Then, you create the @selector function:
- (void) movieNaturalSizeAvailable:(NSNotification *)movieNSNotification {
NSLog(@"MovieNaturalSizeAvaiable");
NSLog(@"Movie width is %f and movie height is %f", moviePlayerController.naturalSize.width, moviePlayerController.naturalSize.height);
//calculate the aspect ratio
float width = moviePlayerController.naturalSize.width;
float height = moviePlayerController.naturalSize.height;
float ratio = width / height;
NSLog(@"ratio is %f", ratio);
//if ratio < 1.4 then it must be 4:3 aspect ratio, else it is 16:9
if (ratio < 1.4) {
moviePlayerController.view.frame = CGRectMake(66, 29, 347, 260);
imageView.frame = CGRectMake(66, 29, 347, 260);
} else {
moviePlayerController.view.frame = imageFrame;
imageView.frame = CGRectMake(9, 29, 462, 260);
moviePlayerController = [movieNSNotification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMovieNaturalSizeAvailableNotification
object:moviePlayerController];
Message was edited by: Grant Abt1

Similar Messages

  • ATV3 Different subtitle size according movie aspect ratio

    Hi guys,
    im getting different soft subtitle size according the aspect ratio (lettered and non-lettered) the size must be the same independently of the movie aspect, take a look the following images there are a huge difference:
    Note: The subtitle configuration are the same for the two screenshots.
    Non-lettered:
    Lettered:
    Its any way to solve that, im currently running the version 7.2 of ATV
    thks !!!

    Ok, I figured it out...
    First, you need to register for the MPMovieNaturalSizeAvailableNotification. I put this in viewDidLoad.
    [[NSNotificationCenter defaultCenter] addObserver:self
    selector:@selector(movieNaturalSizeAvailable:)
    name:MPMovieNaturalSizeAvailableNotification
    object:moviePlayerController];
    Then, you create the @selector function:
    - (void) movieNaturalSizeAvailable:(NSNotification *)movieNSNotification {
    NSLog(@"MovieNaturalSizeAvaiable");
    NSLog(@"Movie width is %f and movie height is %f", moviePlayerController.naturalSize.width, moviePlayerController.naturalSize.height);
    //calculate the aspect ratio
    float width = moviePlayerController.naturalSize.width;
    float height = moviePlayerController.naturalSize.height;
    float ratio = width / height;
    NSLog(@"ratio is %f", ratio);
    //if ratio < 1.4 then it must be 4:3 aspect ratio, else it is 16:9
    if (ratio < 1.4) {
    moviePlayerController.view.frame = CGRectMake(66, 29, 347, 260);
    imageView.frame = CGRectMake(66, 29, 347, 260);
    } else {
    moviePlayerController.view.frame = imageFrame;
    imageView.frame = CGRectMake(9, 29, 462, 260);
    moviePlayerController = [movieNSNotification object];
    [[NSNotificationCenter defaultCenter] removeObserver:self
    name:MPMovieNaturalSizeAvailableNotification
    object:moviePlayerController];
    Message was edited by: Grant Abt1

  • Mpeg4 Movies Aspect Ratio Problems

    Hi everyone,
    I'm a fairly new Mac user (since March 07) and this is my first post on the forums.
    I recently upgraded to Leopard and after transferring all my mpeg4 movies back, which I originally encoded using VisualHub, playing them in Quicktime (even Finder) has stretched all the video aspect ratios (way too wide).
    However, when I play the same videos using VLC, the aspect ratio is correct.
    Is there a setting in Quicktime/Leopard that affects aspect ratio correction/playback?
    Thanks for any help!

    Is there a setting in Quicktime/Leopard that affects aspect ratio correction/playback?
    Are you referring to "player" or "Full Screen" playback here?
    AFAIK, the latest update still does not have such an independent a setting for "player" viewing and the only way to do this is by changing the "display" size in the "Properties" window. Basically. if the encoded, original, and current size stats in the "Inspector" window are all the same, you movie should be playing at the correct aspect ratio to which it was encoded.
    On the other hand, if you are viewing in the "full screen" mode with "Size" preference set to "Fill" rather than the default "fit," then playback will be "distorted" to fill your entire monitor no matter what its size and shape.

  • Setting movie aspect ratio in iMovie 10.0.4

    Im trying to set a specific aspect ratio of my new movie, but I cant find any way to do that. I see help docs that say you can choose the movie format when you create the project but the latest version of iMovie 10.0.4 seems not to offer that feature any more. Nor can I edit the movie format at all anywhere as far as I can see. When I export the movie I have only a very limited set of options all with 16:9 aspect ratio.
    Is this feature no longer supported?

    It is possible to change the aspect ratio and it doesn't need to be in widescreen. I found out how based on another forum. Here is the answer on how to do it:
    1) Select a clip in the timeline.
    2) Select the "Adjust" button at the top of the window.
    3) Select the "Cropping" adjustment (the two right angles that form a square)
    4) Select "Fit"
    http://www.mac-forums.com/forums/movies-video/313345-imovie-10-0-4-960p.html#pos t1594108
    I do find it annoying that when you drag a clip to the editor that it automatically changes the aspect ratio and you have to change it back.

  • QT Pro movie aspect ratio and masking

    Hello,
    This might be beyond the scope of Quicktime Pro. But I'm looking for a way to place a jpg/png with an alpha channel (cut out) into quicktime. Then be able to add a quicktime to be seen through the image. But the kicker is to change the aspect ratio of the movie instead of the still image.
    In Pro, I can add a masked image into the movie, but can't control the ratio of the movie and image separately.
    I can do this in Final Cut & Final Cut Express but would like to find a way for others to do this with a less expensive or free software.
    Any ideas how to change the movie's aspect ratio in QTPro while keeping the mask's ratio the same?
    Or is there another open-source software to do this?
    Thanks ahead of time,
    Adam

    A "mask" is just a black and white image file sized to the dimensions of the video.
    Adding a PNG (JPEG doesn't support alpha channels) file to the entire video would allow you to adjust both track dimensions independently via the Movie Properties window.

  • Exporting Movie: Aspect Ratio

    I've been editing a music video that was shot on the HVX camera. It was shot at 720p. I started my project as a 720p project and imported all the footage (MXF files) into bins and edited my video. I go to export it and it exports to an AVI in an aspect ratio that is NOT 960x720! I checked the export settings and they are as follows:
    File Type: MS AVI
    Compressor: None
    Color Depth: Million+
    Frame Size: 960h 720v (16:9)
    Frame rate: 23.976
    Pixel Aspect Ratio: HD Anamorphic 1080 (1.333)
    When I edit the video in premier it is the correct aspect ratio. I click on a clip in the time line and it says "Video: 23.976 fps, 960x720 (1.333)" so what am I doing wrong here?

    The strangeness continues. I played the file in BS player and SOME of the fades worked. NONE of the fades in/out to black, but I may be able to work around that issue. I have it set up where it fades in and out to a blank space on the timeline. If I insert a black video slug the fades might work. I say this because when fading with other video (I have a couple crossfades in the video) they work just fine!
    When I play the rendered video in CS3 the fades work. Why? I don't know.
    Project settings as follows (General Tab):
    Editing Mode: P2 720P 60Hz DVCPROHD
    Timebase: 23.976 fps
    Frame Size: 960 h 720 v
    Pixel Aspect Ratio: HD Anamorphic 1080 (1.333)
    Fields: None
    Display format: 24fps
    Video Tab:
    File Format: DVCpro 100 720p 60Hz
    Compressor: Same as above
    Color Depth: Million+
    I'm still getting the letterboxing problem too, when I use square pixels.
    EDIT: My workaround for my fading issue did not work. I have no clue why. So for some reason TWO fades work in this project, but none of the others. The two that work are a fade in and out on a set of titles on vid track 2 and a cross-fade in between two tracking shots in the middle of the project. The fades that do not work are at the beginning and end I have a series of quick fades in and out, in typical music video fashion, that do not work at all. Except when played back in CS3, but I need them to work in other media players too!
    Thanks for all the help so far :)
    EDIT #2:
    Now even when I have the project rendering in HD Anamorphic pixels I get the same problem with the fading! It used to work when I'd render in 4:3. But now it doesn't. ARGH.

  • Embedded Movie Aspect Ratio

    I'm rendering DV video (720x480x.909 pixel AR) to Quick Time 7 and embedding in ID CS3 targeting PDF files. When rendered to .909 AR QT, the normal QT display (via PDF) displays correctly with correct AR. Depending upon my render settings, I've sometimes seen an active "maximize" command when right clicking the title bar of the QT player. When it can be selected, the maximized display AR is grossly distorted. Is the maximize function supposed to be available and scale properly?

    The strangeness continues. I played the file in BS player and SOME of the fades worked. NONE of the fades in/out to black, but I may be able to work around that issue. I have it set up where it fades in and out to a blank space on the timeline. If I insert a black video slug the fades might work. I say this because when fading with other video (I have a couple crossfades in the video) they work just fine!
    When I play the rendered video in CS3 the fades work. Why? I don't know.
    Project settings as follows (General Tab):
    Editing Mode: P2 720P 60Hz DVCPROHD
    Timebase: 23.976 fps
    Frame Size: 960 h 720 v
    Pixel Aspect Ratio: HD Anamorphic 1080 (1.333)
    Fields: None
    Display format: 24fps
    Video Tab:
    File Format: DVCpro 100 720p 60Hz
    Compressor: Same as above
    Color Depth: Million+
    I'm still getting the letterboxing problem too, when I use square pixels.
    EDIT: My workaround for my fading issue did not work. I have no clue why. So for some reason TWO fades work in this project, but none of the others. The two that work are a fade in and out on a set of titles on vid track 2 and a cross-fade in between two tracking shots in the middle of the project. The fades that do not work are at the beginning and end I have a series of quick fades in and out, in typical music video fashion, that do not work at all. Except when played back in CS3, but I need them to work in other media players too!
    Thanks for all the help so far :)
    EDIT #2:
    Now even when I have the project rendering in HD Anamorphic pixels I get the same problem with the fading! It used to work when I'd render in 4:3. But now it doesn't. ARGH.

  • IPod movies aspect ratio

    I just downloaded Pirates from iTunes to try on my new 80gb iPod and it is in widescreen which with my eyes is a tad hard to see. Is there a setting to make it or any movie which is widescreen defaut to 4:3 to get the full screen?
    I turned widescreen off but it is still in widescreen.
    Thanks,
    Danny

    On your iPod head to Videos > Settings and adjust the Fit to Screen option.  Any luck there?
    B-rock

  • DVD movie aspect ratio on 22" ACD

    When I play DVD's on my 22" ACD (1600x1024, G4 400, OS 9.1 with included apple DVD player circa 2000), the DVD window refuses to use the entire screen. When I select full screen, it STRETCHES the window and distorts the DVD image.
    Solutions / experience with this? Alternative/better DVD
    player recommendations?
    Thanks all,
    rdavid

    Selecting full screen in QT doesn't necessarily mean the whole screen will be filled with the image without borders. If the DVD was formatted in 16:9 mode, then you will have a thin narrow black strip top and bottom when playing in full screen mode. Similarly, if the DVD is a "Full screen" DVD, which means it is 4:3, then there will be black strips left and right in QT full screen mode.
    You don't actually want such DVDs to truly fill the screen because that would cause distortion. An ACD is 16:10 format and no DVD made is formatted that way.

  • Using "One Step DVD from Movie" on my IMac 10.8.6 using Verbatim DVD-R ("Life Series") 4.7 GB 16X 120, I get a wide angle version of my two minute story rather than the 3X4 standard aspect ratio that I normally get and want.  Help!

    While using "One Step DVD from Movie"  using DVD-R Verbatim ("Life Series" 4.7  16 X  120 min) on my IMac 10.6.8 I get a wide angle aspect ratio on the DVD not the standard 3X4 aspect ratio.  The Quicktime Movie is is standard 3X4 aspect ratio and the video video footage is standard 3X4 aspect ratio?  Advice will be greatly appreciated.

    Try this basic troubleshooting fix :
    1 - delete the IDVD preference file, com.apple.iDVD.plist, that resides in your
         User/Home()/Library/ Preferences folder.
    2 - delete IDVD'S cache file, Cache.db, that is located in your
         User/Home()/Library/Caches/com.apple.iDVD folder. 
    Click to view full size
    3 -  reboot.
    4 - launch IDVD and try again.
    Personally I would not the the one step method but create the iDVD project  from scratch so you can make sure the widescreen option is not selected in the preferences and you can follow this workflow:
    Once you have the project as you want it save it as a disk image via the  File ➙ Save as Disk Image  menu option.  This will separate the encoding process from the burn process. 
    To check the encoding mount the disk image and launch DVD Player and play it.  If it plays OK with DVD Player the encoding was good.
    Then burn to disk with Disk Utility or Toast at the slowest speed available (2x-4x) to assure the best burn quality.  Always use top quality media:  Verbatim, Maxell or Taiyo Yuden DVD-R are the most recommended in these forums.
    OT

  • Dreadful handling of 3:2 aspect ratio photos by Photos App on 5S with IOS 7

    When you view photos that have 3:2 aspect ratio (a common standard from digital SLR cameras) in the Photos APP on the Iphone 5S with IOS 7, the software attempts to set each photo to fill the screen.  This in itself is extremely annoying, as the top and bottom of each photo is cropped, and there is no setting to stop this happening (i.e. to view the photo in its original aspect ratio with the black bars on the left and right).  However, there is a further irritating "bug" that means that each time you swipe to the next photo, it adjusts the position of the cropped photo giving a jump in the picture with every swipe.  This makes viewing multiple photos by swiping past them a completely negative experience, as there is a complete lack of smoothness to the visual experience.  By contrast, photos with aspect ratios that give wider black bars on each side are retained in their original aspect ratio (e.g. the ones from the phone's own camera) - but for some reason once the bars get smaller, the software chooses to resize the photo to fill the screen.  The fact that it does this for the standard SLR photo aspect ratio (not to mention a standard setting of many digital cameras) of 3:2 is really unfortunate.  A setting to stop any attempt to resice a picture (i.e. to view in the original aspect ratio no matter what that ratio) is clearly needed.  Additionally, a fix for the judder on each new photo is also required once it does fill the screen.
    Anyone else noticed this - and any suggestions until it is fixed?

    I've noticed it, too. It's very annoying. I am a "semi-professional" photographer (meaning every once in awhile someone pays me to take photos for them.) and I put many of my DSLR photos on my phone. It's a big pain to have to resize them on-screen each time. Wish there was a fix,

  • Aspect ratio issues in iDVD with mov files exported from FCE

    Please help. I believe this is an iDVD bug. I have found some relevant discussion of it on online forums - but have not found a solution that works for me. I am looking for a workaround.
    http://discussions.apple.com/thread.jspa?threadID=1356500&tstart=31
    PROBLEM STATEMENT:
    My 4:3 movies, exported from FCE in QT-with-conversion formats (any 4:3 format) - appear in iDVD with gray side-pillars (as expected for 4:3) AND with a black line (letter-boxing) at top and bottom - as would be for 16:9. It appears the aspect ratio is also distorted i.e. 16:9. (The iDVD project is set to 4:3.)
    1- A 4:3 mov file exported from FCE using Quicktime Movie format (no conversion) does not have the problem, but I cannot de-interlace the video using this export mode.
    2) A 4:3 mov file exported using QT-with-conversion mode (any 4:3 format) DOES have the problem. I need to use this mode in order to get de-interlace.
    (Exception: 640x480 VGA mode does not have the black lines, and it displays correctly in dvd player on my computer screen - but on the TV screen, it crops content from the top and bottom of the movie, so this is not an option.)
    3) In Finder, if you click on mov file exported QT-only (no conversion), it opens in the FCE viewer. If you click on mov file exported in any other 4:3 mode, it opens in Quicktime viewer (i.e. there is absolutely something different in the header/ID of these files.)
    4) All mov files, regardless of export mode, show correctly in Quicktime viewer - no black line, no distortion. The problem does not occur outside of iDvd.
    5) I tried passing the QT-with-conversion mov files through an Inverse-Anamorphicizer (per suggestion on forum - this apparently fixed the problem for some people) but the resulting output mov (i.e. the inverted product) still had the same problem.
    I am, so far, left with this trade-off: Give up the de-interlacing, or live with the letter-boxing/ distortion. Neither is acceptable.
    I am looking for a workaround:
    1) A way to export de-interlaced 4:3 mov from FCE that shows in correct ratio in iDVD
    2) A way to "convert" / re-head mov file after exported so that it displays corrrectly (inverse-anamorphicize) so that iDVD reads it correctly
    3) Can the mov be de-interlaced after the fact (so I could use QT export without conversion)?
    4) Something besides iDVD to put this together - that doesn't have this problem? (I like and want to use the iDVD menu/theme.)
    5) Other?????
    I also notice that all the QT-with-conversion mov files are 1/3 to 1/2 the size of the QT-only mov file, which is valuable and preferable to me. (I don't see any quality difference in the display...)

    In the Preview window > top frame > middle button
    do you have correct for pixel aspect ratio checked or not?
    !http://i533.photobucket.com/albums/ee340/gogiangigo/Picture1-4.png!

  • Aspect Ratio / Anamorphotic Movies

    Hi
    We have a number of movies that come from DigiBeta or DVD.
    They have non square pixel aspect rations. We've encoded them into
    MP4 Files. Players like QuickTime or VLC correctly recognize the
    aspect ratio and distort the display accoringly. But in our flash
    application the movie is always displayed with square pixels. How
    can we make Flash recognize this? No we do not want to reencode all
    the movies with square pixels!
    t.

    but then our customers would need flashplayer10, right? for
    compatibility reasons we want to support flash9. is there a
    possebility to find out about pixel aspect ratio (PAR) in flash9?
    t.

  • Wrong aspect ratio when space bar preview movies in finder

    any way to change finder so that it previews 16x9 movies in the right aspect ratio? it always squishes my 16x9 to 4x3. ugly.

    Yes, this seems to be a problem with Mac OS X 10.5 (or maybe some QT version) and 16:9 (PAL and NTSC) SD projects. 4:3 projects are OK.
    But I prefer to use Photo To Movie to compose iMovie slideshows anyway because its quality is and has been better.
    http://www.sjoki.uta.fi/~shmhav/iMovieHD_6_bugs.html#jaggystills

  • Export to Quicktime Movie Results in Aspect Ratio Distortion

    All of my original footage was shot in miniDV. I have created a sequence with the following settings:
    Frame size: 720 x 480
    Compressor: DV/DVCPRO - NTSC
    Pixel Aspect: NTSC - CCIR 601
    Vid rate: 29.97 fps
    Ultimately the sequence needs to go to DVD with a standard 4:3 aspect ratio. To export, I am using:
    File > Export > QuickTime Movie...
    I have tried using several different settings including:
    Apple Pro Res 422 NTSC 48 kHz
    Apple Pro Res 422 NTSC (HQ) 48 kHz
    Apple Pro Res 960x720 30p 48 kHz
    DV NTSC 48 kHz
    etc...
    All settings yield the same result: a slightly squeezed aspect ratio. At first, I thought that this might simply be the fact that I was playing back files in QuickTime which uses square pixels I believe. But in both DVD Studio Pro and iDVD, the simulation shows the same effect. (By the way, Finder's "Get Info" reads the resulting Final Cut Pro Movie File dimensions 720x486.)
    I'm fairly new to FCP so I'm hoping there is something obvious that I have missed. Can anyone explain what I need to do to get the video to DVD without a distorted aspect ratio?
    (Incidentally, I have managed to export using quicktime conversion with no problem. But I need the export to be a Final Cut Pro Movie File so as to maintain chapter markers, etc.)
    Advice welcome!!!

    Hi David, I know this was discussed in you posting already but I just wanted to make sure I had it clear. I have a 4:3 film and I've exported as a quicktime movie with current settings, which should be 4:3 and found that the image when played back in quicktime, looks horizontally stretched. Almost as if quicktime is trying to play it back as a 16:9 image. I think this is the same issue the other fellow was having but I just wanted to be clear. You're saying that the 4:3 image distortion is perfectly normal when played back in quicktime on a computer screen and that the export will look fine when put to DVD or sent to a monitor? I just wanted to make sure because this problem is freaking me out and I don't want to deliver a distorted image to my client. Could you also explain briefly why this happens with quicktime export and not quicktime conversion and what causes quicktime to distort the 4:3 image? Any advice or help would be greatly appreciated.
    Cheers,
    james.

Maybe you are looking for

  • Export of WebI reports to XML in BO4.1

    Hello, I've seen some of BO What's New presentation stating that export of WebI reports to XML is possible in BO 4.1. However, my standalone client (4.1 SP1) does not offer this function. My question thus is, whether export to XML is really possible,

  • Create a database field in Repetitive Area

    Hi, I generated a report from query, but I can't insert a database field in a Repetitive Area using PLD. I've tried inserted a Text Field and changed to Database field, but there is nothing shown. does anyone can help? Thanks Kim

  • Remove "quota overview" link from Portal ESS

    Hello, Is there a way to remove Quota overview link on ESS portal as we are not using it. Please advice. Thank you.

  • Guided edit

    in  photoshop 10 i cannot get to guided edit?

  • Urgent Help Needed Union Query

    Hello All I have a complex query (at least i think) which returns result set. Now i want to add to it the records that were not mached by the query i tried <Query1> Union all <Query2> where not in <query1> (hope i am able to express myself) but it ta