Convert 3GP and 3G2 movies for iPhone with QuickTime 7 Pro

This FAQ discusses creating an Automator application to convert 3GP and 3G2 movies — via QuickTime® 7 Pro — to MP4 (.mp4) format for use on an iPhone® 5. The instructions and sample code were executed on a Mac Pro® (Late 2010) running OS X® 10.8.2. The resulting MP4 videos were transferred to an iPhone 5 via iTunes® Sync and play flawlessly in the Photos app.

One of the challenges of moving from an older mobile phone to an iPhone is the iPhone does not support the 3GP and 3G2 video recording formats of older phones. On my Mac Pro, I have 90 movies recorded with my Motorola® Krzr™ and Blackberry® Curve™ 8330 phones, all in 3GP format. I also have movies recoded by others whose phones used the 3G2 format. Putting these precious memories on my new iPhone 5 meant converting these movies to a supported video format, such as MP4.

While third-party software is available to convert these older formats to iPhone-compatible formats, the conversion can be accomplished with a bit of AppleScript® and Automator magic if you have a QuickTIme® 7 Pro key.

QuickTime Player 7 is an optional install for Mac OS X 10.6 and a free download for OS X 10.7 and 10.8. A QuickTime 7 Pro key is a registration code that unlocks a variety of media editing and exporting options in QuickTime Player 7. At the time of this writing, a Pro key is available from the Apple Store for US$ 29.99 . If you have QuickTime 7 Player installed and a Pro key, then the instructions in this FAQ will permit you to convert 3GP and 3G2 video formats to MP4 without additional software. If you do not have a Pro key, you may be able to find third-party conversion software that is free or less expensive, but I have never regretted paying for a Pro key: it has proved its worth to me many times in video format conversions.

One might be tempted to use the iPod touch and iPhone 3GS Export option of QuickTime Player, aka QuickTime X, to convert 3GP and 3G2 videos for use on an iPhone. QuickTime Player played the old videos, but those recoded with the Krzr played with distorted audio. Exporting these videos with QuickTime X likewise proved problematic: exported Krzr videos resulted in .m4v files without audio; exported Blackberry videos had both sound and video. These issues are due to the audio codecs used in the Krzr videos vs. those supported by QuickTime X.

QuickTime 7 Pro played Blackberry and Krzr videos perfectly, without audio distortion. Exporting these movies with the Movie to MPEG-4 output format produced perfect copies in MP4 (.mp4) format that also played flawlessly in QuickTime X. Therefore, my next task was creating a program for batch-converting the old movies to MP4 via QuickTime 7 Pro.

While QuickTime 7 Pro supports AppleScript, it does not provide Automator Actions. A combination of Automator and AppleScript is required. I have written many AppleScripts, primarily for text processing, but had not scripted QuickTime 7 Pro. Rather than start from scratch, I searched the Web for sample QuickTime 7 Pro scripts. My search uncovered a 28 March 2012 blog post by freelancer Peter Bartz entitled "Batch convert animated GIFs to videos using AppleScript/Automator/QuickTime 7 on OS X." Peter's excellent post was just the thing I needed. I modified Peter's sample code to create the following AppleScript to perform the conversion:

-- Determine if input was provided, otherwise prompt for files to process:
on run {inputFiles}
	if inputFiles is equal to {} then
		set inputFiles to (choose file with prompt "Select the file(s) to convert:" with multiple selections allowed without invisibles)
	end if
	open inputFiles
end run

-- Set default output folder, then prompt for an output folder:
on open droppedItems
	tell application "Finder" to set inputFolder to (container of first item of droppedItems) as Unicode text
	set outputFolder to (choose folder with prompt "Select output folder:" default location (inputFolder as alias)) as Unicode text

  -- Notify the user that existing output files with the same names as input files will be overwritten and moved to the Trash:
	display dialog "Note: Existing output files will be overwritten/moved to Trash!"
	tell application "QuickTime Player 7"
		close every window
	end tell
	-- Begin processing the dropped files in a loop until all have been converted:
	-- Strip ".3GP" or ".3G2" extension from input file names.
	-- Note: File names cannot contain "." characters before the extension

	repeat with currentItem in droppedItems
		tell application "Finder" to set fileName to name of currentItem as Unicode text
		set dotOffset to offset of "." in fileName
		set fileName to text 1 thru (dotOffset - 1) of fileName
		-- Open the current file in QuickTime Player 7.		
		tell application "QuickTime Player 7"
			open currentItem
		end tell
		-- Set the name of the output file:
		set outputFileName to (outputFolder & fileName & ".mp4")
		-- If the output file already exists in the output folder, move it to the Trash:
		tell application "Finder"
			if exists file outputFileName then
				delete file outputFileName
			end if
		end tell
		-- Perform the conversion:
		tell application "QuickTime Player 7"
			export front document to outputFileName as MPEG4 using default settings
			close front document
		end tell
	end repeat
	-- When all input files have been converted, Quit QuickTime Player 7:
	quit application "QuickTime Player 7"
end open

This AppleScript performs five tasks, as seen from the inline comments (lines beginning with "--" in the code above):

  1. Assures that one or more input files have been provided, otherwise it prompts the user to select files for conversion.
  2. Prompts the user for an output folder for saving the converted files; the default output folder is the folder containing the input files.
  3. Alerts the user that files in the output folder whose names match newly converted files will be moved to the Trash and replaced by the new files.
  4. Strips the input file name of its extension (.3GP or .3G2) and sets an output file name with the .mp4 extension.
  5. Converts the input files to MP4 format using the default settings in QuickTime 7 Pro and saves the output files to the output folder.

To create an Automator application that employs this AppleScript:

  • Open Automator, located in the Macintosh HD > Applications folder.
  • In the resulting sheet, choose Application, then click Choose.
  • Click Actions.
  • Under Library, click Utilities.
  • Double-click Run AppleScript or drag it to the right pane of the workflow.
  • Select all of the boilerplate AppleScript code in the Run AppleScript action and press Delete to remove this code.
  • Copy and paste the sample code above into the Run AppleScript action.
  • Click Compile — the hammer icon — in the toolbar of the Run AppleScript action.
  • Save the Application: press the Command-S keyboard shortcut, type a name for the application (e.g. Convert 3GP to MP4), chose a location for saving the application (e.g. Desktop), then click Save.

The following screen shot illustrates the process:

To use the resulting Automator application:

  1. Drag and drop 3GP or 3G2 movies onto its icon.
  2. Choose an output folder for the converted movies. e.g. a Converted Movies folder on the Desktop.
  3. Read the prompt — seen in the screen shot at right — advising that existing output files with names matching the input files will be overwritten and moved to the Trash, then click OK.

QuickTime 7 Pro will open and the conversions are performed.

There are three important usage notes for the Automator application:

  1. Drop individual movie files — not folders of movies — on the application icon.
  2. The input file names should not contain periods (".") ahead of the file extension. For example, if the input file name is Filmed on 2005.01.01.3gp the output file would be truncated to Filmed on 2005.mp4. I could have written more sophisticated code to drop the .3GP or .3G2 extensions to avoid this issue, but took the a quick-and-dirty approach.
  3. I found it best to convert small groups of movies — 10-15 or so — at a time. When I dropped 20 or more movies on the application icon, it would repeat the prompt for the output folder midway through the conversion. This may have been a timing issue: Peter's original code had a timeout parameter that I removed after it caused the Automator application to hang and then quit unexpectedly. I have no plans to perform further troubleshooting on this issue as I was able to successfully convert all of my old mobile phone movies for use on my iPhone 5.

My thanks to Peter Bartz for permission to use the modified version of his sample code in this FAQ.

Did you find this FAQ helpful? You will find a wealth of additional advice for preventing or resolving Mac OS X problems in Dr. Smoke's book, Troubleshooting Mac® OS X.
Use of this site signifies your agreement to the terms of use.