User Tools

Site Tools


software:mts2flv

This is an old revision of the document!


Convert mts2flv with applescript and ffmpeg

This applescript below will per drag and drop convert mts files to flv using ffmpeg

Download

The scripts can be downloaded here: http://www.auditeon.com/xyz/mts2flv.app.zip. ffmpeg is already stored in the following directory:

mts2flv.app/Contents/Resources/

Manual installation

  1. Save the applescript, named mts2flv, from below to a directory. In Applescript editor save as Application
  2. Copy ffmpeg into the following subdirectory of the applescript directory: mts2flv.app/Contents/Resources/
  3. If not, make ffmpeg executable with:
    chmod +x ffmpeg
-- This droplet processes both files or folders of files dropped onto the applet
 
on open (these_items)
	repeat with i from 1 to the count of these_items
		set this_item to (item i of these_items)
		set the item_info to info for this_item
		if folder of the item_info is true then
			process_folder(this_item)
			--		else if (alias of the item_info is false) and (the name extension of the item_info is "mts") then
		else if (alias of the item_info is false) then
			process_item(this_item)
		end if
	end repeat
end open
 
-- this sub-routine processes folders
on process_folder(this_folder)
	set these_items to list folder this_folder without invisibles
	repeat with i from 1 to the count of these_items
		set this_item to alias ((this_folder as text) & (item i of these_items))
		set the item_info to info for this_item
		if folder of the item_info is true then
			process_folder(this_item)
			--		else if (alias of the item_info is false) and (the name extension of the item_info is "pdf") then
		else if (alias of the item_info is false) then
			process_item(this_item)
		end if
	end repeat
end process_folder
 
-- this sub-routine processes files
on process_item(this_item)
	-- NOTE that the variable this_item is a file reference in alias format
	set full_path to the POSIX path of this_item
	try
		set ffmpeg_location to quoted form of POSIX path of (path to resource "ffmpeg") -- ffmpeg binary location
		tell application "Finder"
			set x to path to me
			set y to name of file x as text
		end tell
		-- from http://www.petercarrero.com/content/2009/10/11/converting-mts-avchd-flv-ffmpeg
		display alert "Processing ..." message "Processing file " & this_item giving up after 1
		with timeout of 27000 seconds
			do shell script ffmpeg_location & " -i " & quoted form of full_path & " -vcodec flv -f flv -r 25 -s 800x450 -aspect 16:9 -b:v 2000k -g 160 -cmp 2 -subcmp 2 -mbd 2 -trellis 2 -acodec libmp3lame -ac 2 -ar 44100 -ab 256k " & quoted form of full_path & ".flv"
		end timeout
	on error the error_message number the error_number
		display dialog "Error: " & the error_number & ". " & the error_message
	end try
end process_item
 
 
on getFileName(thefile)
	set {oldDelims, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {":"}}
	set mytextfilename to last text item of (thefile as text)
	set AppleScript's text item delimiters to oldDelims
	return mytextfilename
end getFileName
software/mts2flv.1381841417.txt.gz · Last modified: 2013/10/15 14:50 by admin