[APPLESCRIPT] Change QuickTime movie aspect ratio

Mikuro

Crotchety UI Nitpicker
This is a script I've made to easily change the aspect ratio of a movie in QuickTime Player. It presents the user with a dialog box with common ratios, like 4:3 and 16:9, with an option for the user to enter any arbitrary ratio.

I find this very useful for video podcasts from iTunes and movies downloaded from sites like YouTube. For some reason they often have the wrong aspect ratio, resulting in stretched (or smooshed) video. This script lets me fix it easily.

The zip includes both .scpt and .app versions. Personally, I recommend enabling the Script Menu (which you can do from AppleScript Utility, located in /Applications/AppleScript/) and putting it in there. You can even set it up so it only appears in the menu when QuickTime Player is the frontmost application.

This script has been tested with QuickTime 7 in Tiger and Leopard.
 

Attachments

  • Change aspect ratio.zip
    31 KB · Views: 1,415
Thanks a bunch - Compressor has been outputting a bunch of mov files that were natively 4:3 and making the people look fat. This fixed it. Quicktime asks if you want to save the file when exiting. When you reopen the saved file it then keeps the correct aspect ratio that you set with your script.

I would like to set this in compressor on the h.264 export but until then at least I can view the real output.

Thanks for your work

I joined just to download and thank you.
 
Please help. I applied the script to one of my videos to 4:3 and saved it. Final Cut Pro now shows it as square pixel and 720 x 540.

I need the original footage back to the way it was.

Thanks
 
How can I manually go into a video file and change a dimension?

Final Cut is showing me it as square pixel when it isn't and also dominant field shows none - it should be lower field.
 
I am sorry to ask a stupid question like this, but I am a new iMac userand I can't figure out how to install the script. It works fine when I execute it, but I would like to have it available on the menu whenever I run QuickTime. What do I do?

TIA
 
Please help. I applied the script to one of my videos to 4:3 and saved it. Final Cut Pro now shows it as square pixel and 720 x 540.

I need the original footage back to the way it was.

Hi. Sorry for the delayed reply; I must have missed your post originally.

You can use the script to change the ratio back to its original ratio. Or, if you have QuickTime Pro, you can also do it manually like this:

- Open the movie
- Sselect "Show Movie Properties" from the Window menu
- Select the video track
- Go to "Visual Settings"
- Un-check the "preserve aspect ratio box"
- Enter the numbers from the "normal size" boxes into the "Scaled Size" boxes and hit Return.
- Save.
 
I am sorry to ask a stupid question like this, but I am a new iMac userand I can't figure out how to install the script. It works fine when I execute it, but I would like to have it available on the menu whenever I run QuickTime. What do I do?

TIA

I recommend using the AppleScript menu. You can enable this menu by using the "/Applications/AppleScript/AppleScript Utility" program.

Once you have it enabled, go into QuickTime Player, and select from the Script menu "Open Scripts Folder > QuickTime Player Scripts Folder". Drop the script files into that folder, and they will now appear in the menu whenever QuickTime Player is active.
 
Thanks! Have been looking forever to get a simple thing like this to convert my skinny files into regular aspect ratio files. Thanks so much. Just used the script "Change QuickTime movie aspect ratio script.scpt" and it worked like a charm.
=) oslodude
 
I was having a problem using iDVD 08 to encode a dvd from a quicktime reference output from Avid. Even though the movie displays fine when played in Quicktime, after I specify 16:9 square pixels on the QT reference settings in Avid, when iDVD imports the movie, it creates a 4:3 DVD. Your little script application solved the problem immediately. I also joined to download and thank you. Good work.

Now can someone tell Apple to put just one more option into iDVD, so we don't have to go through this rigmarole?!
 
when I try to download the script all I get is a page saying that I am not a member of the forums! I joined to download this and it doesn't come through. Is it no longer on the server?
 
I don't know why it says that. I can still download it.

A few people have had issues with the download (usually saying it won't unzip), so for anyone else having problems, you can copy and paste this into Script Editor and save it yourself:
Code:
--first define a sub-script which actually sets the ratio to a given value. You can just say "tell applyScript to setRatio to 1.33" to change the ratio to 4:3. Making this a sub-script makes it easier to reuse and modify it, like if you wanted to bypass or replace the dialog.
script applyScript
	to setRatio to x
		
		tell application "QuickTime Player"
			--find the video track
			set the_track to every track of document 1
			repeat with t in the_track
				if the natural dimensions of t is not {0, 0} then
					set the_track to t
					exit repeat
				end if
			end repeat
			--get the natural (unscaled) dimensions of the movie, and adjust that to match the new ratio, always increasing one (and only one) dimension
			set d to the natural dimensions of the_track
			set w to (item 1 of d)
			set h to (item 2 of d)
			if w / x > h then
				set h to w / x
			else
				set w to h * x
			end if
			
			--apply the new dimensions
			set the dimensions of the_track to {w, h}
			return {w, h}
		end tell
	end setRatio
end script


--now create and present a ratio-selection dialog


--Create a list of choices for the user. The last item will always allow the user to enter a custom ratio, but you can add or remove any entries above that
set ratios to {¬
	"2.39:1", ¬
	"1.85:1", ¬
	"16:9 (1.78:1)", ¬
	"16:10 (1.6:1)", ¬
	"4:3 (1.33:1)", ¬
	"Other..."}

tell application "QuickTime Player"
	--get the current dimensions of the movie
	set d to the dimensions of document 1
	set w to (item 1 of d)
	set h to (item 2 of d)
	
	--create a prompt for the user to select a new ratio
	set prompt to ("Change ratio from " & (((item 1 of d) / (item 2 of d) * 100 as integer) / 100) as text) & ":1 to:"
	choose from list ratios with prompt prompt
	set x to item 1 of the result
	
	--if the user selected "Other", allow them to enter a ratio manually
	if x is the last item of ratios then
		set x to the text returned of (display dialog prompt default answer (w / h))
	end if
	
	--remove any unnecessary parts from the result
	set AppleScript's text item delimiters to "("
	set x to text item 1 of x
	
	--calculate the new x:1 ratio
	set AppleScript's text item delimiters to ":"
	set x to (text item 1 of x as number) / (text item 2 of x as number)
	
	--set the ratio using the previously-defined script
	tell applyScript to setRatio to x
end tell
 
thank you for your reply and your script! I am new at using scripts but I was successful after 5 minutes by following your instructions. I tried it out on 2 QT movies and successfully changed them from 1.33:1 to 1.78:1 as they were intended to be seen.
Thanks again,
roberto schaefer, asc
 
I'd like to join the ranks of those thanking you for your script and app. It works easily and well with QT 7 Pro. My problem arises when I try to save the change to the video itself, so that iDVD will use the new aspect ratio.

When I try to save, I get the message, "The movie '(Movie title)' could not be saved. You do not have sufficient permissions for this operation."

I am using my Administrator account, the OS is Snow Leopard, the machine a Quad Core Mac Pro. Do I need to use Terminal to flip a bit somewhere?

I will greatly appreciate any help you can provide.
 
Not sure about that. Where is the file stored? Select the file in the Finder and choose Get Info from the File menu. See what it says under Permissions. You might need to change it to be sure you have read/write privileges.

Alternatively, try choosing Save As instead of Save. When the Save dialog appears you'll have the option to save it as a "reference movie". That will give you a new .mov file that references the data from the original (so it will be very small), but will have the new aspect ratio settings.
 
When I try to run this I get an error message thus -- error "QuickTime Player got an error: Can’t get «class pdim» of document 1." number -1728 from «class pdim» of document 1.

Any ideas?
 
Have now managed to run the script, but I now have an error that reads:

error "Can’t get natural dimensions of {last track of document \"file name here\" of application \"QuickTime Player\", last track of document \"file name here\" of application \"QuickTime Player\"}." number -1728 from «class ndim» of {last «class trak» of document "file name here", last «class trak» of document "file name here"}

Please help!
 
Back
Top