Je ne pense pas qu'il soit possible de transformer facilement un avi quelconque en mp4 (le mp4 impose le codec, non ? ), mais je me suis dit que ça devrait être faisable de convertir un avi en mov...
J'ai modifié un peu un script d'Apple pour ça :
(il faut enregistrer le script en tant qu'application, et dropper un film ou un dossier de films dessus)
property type_list : {"MooV", "MPG3", "MPEG", "DivX"}
property extension_list : {"mov", "mpg", "mpeg", "avi", "divx", "wmv"}
on run
set AppleScript's text item delimiters to ", "
set the formats_list to type_list as string
set AppleScript's text item delimiters to ""
display dialog "Save in QuickTime Format
This script will save a copy of dragged-on media files in the following formats as self-contained QuickTime movies." & ¬
return & return & formats_list buttons {"OK"} default button 1
end run
on open these_items
set the target_folder to choose folder with prompt "Destination folder for the converted files:"
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, target_folder)
else if (alias of the item_info is false) and ¬
((the file type of the item_info is in the type_list) or ¬
the name extension of the item_info is in the extension_list) then
process_item(this_item, target_folder)
end if
end repeat
end open
-- this sub-routine processes folders
on process_folder(this_folder, target_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, target_folder)
else if (alias of the item_info is false) and ¬
((the file type of the item_info is in the type_list) or ¬
the name extension of the item_info is in the extension_list) then
process_item(this_item, target_folder)
end if
end repeat
end process_folder
-- this sub-routine processes files
on process_item(this_item, target_folder)
-- NOTE that the variable this_item is a file reference in alias format
-- FILE PROCESSING STATEMENTS GOES HERE
with timeout of 3600 seconds -- one hour per movie time limit
tell application "QuickTime Player"
launch -- bypasses promo movie
activate
my toggle_suppress(true)
stop every document
close every document saving no
try
open this_item
if saveable of document 1 is false then
error "This movie has previously been set so that it cannot be copied, edited, or saved."
end if
set this_file to the original file of document 1
set this_name to the name of document 1
display dialog this_name
tell application "Finder"
set the file_name to this_name as string
set the new_file to ((the target_folder as text) & the file_name) as string
if (exists file new_file) then delete file new_file
end tell
save self contained document 1 in new_file
on error error_msg
try
beep
display dialog error_msg buttons {"Cancel", "Continue"} default button 2 with icon 1
on error
my toggle_suppress(false)
error number -128
end try
end try
close document 1 saving no
my toggle_suppress(false)
end tell
end timeout
end process_item
on toggle_suppress(status_flag)
tell application "QuickTime Player"
set ignore auto play to the status_flag
set ignore auto present to the status_flag
end tell
end toggle_suppress
Mais je n'arrive pas à enregistrer le film
new_fileLa ligne save self contained document 1 in ne veut pas marcher :/ (pourtant, new_file faut bien "Mac HD:Users:flanker:Music:Movies:mon_film.mov", et document 1 est a priori correct :/)
Le but, c'est de continuer le script après pour faire une recherche sur allocine pour récupérer l'affiche et les infos (titre VO, année, synopsis) - tout ça, je sais déjà faire mais en php - et le mettre dans la bibliothèque iTunes (il apparaît alors dans la section films avec la pochette, et dans frontrow il n'a pas la pochette mais il y a quand même le reste des infos)