電子竹林:Blog

はてなダイアリーより引っ越し済み、主に映画

「Mac OS XユーザーのためのExilim Pro EX-P505」

(追記:カシオから公式コンポーネント出てます↓、でもemonkid氏の方が優れているかもよ→id:zom-1:20050618#p1)

https://secure.casio.co.jp/dc/members/download/casio_avi/

● 現状のまとめ

1) Exilim Pro EX-P505は動画を強化したデジカメ→(http://www.exilim.jp/ex_p505/)

2) EX-P505の記録する動画は動画コーデックはMPEG4、ファイル形式はAVI

3) 記録される動画はQuickTime Playerで再生出来ない

4) 再生するだけならVLC(http://www.videolan.org/vlc/)で出来る(MPlayerは不安定な気がする?)

5) コーデックとして、FFusion(http://aldorandenet.free.fr/codecs/)を入れるとQuickTime Playerで扱える…しかし、カメラで編集していたり、ショートムービーではNG

6) 色々、他のコーデックを探してみたが対応出来るのは無い(追記:M4S2用コンポーネントを作成した方登場→id:zom-1:20050618#p1)

カシオが適当なコーデックを出してくれるのを期待して待っている訳にはいかないので(追記:公式のQuickTimeコンポーネント出ました)、結局、トランスコードするしかないなと決断。エンコにはffmpegを使う事にする。撮影した多量のAVIファイルは手軽に、一括で変換したいが適切なアプリケーションが無い。という事で、久々にAppleScriptを引っ張りだしてきて、コードを書く(別に難しい事は無い)。

このスクリプトをアプリケーション形式で保存してdrag&dropしてやる。別にffmpegが/sw/binに必要。

● インストール方法

a) ffmpegがインストールされている場合はe)に飛ぶ。但しパスは注意。

b) ffmpegは自分でコンパイルするのが筋だが、コンパイル済みのを取り出す事に…(http://ipsp.kaisakura.com/)からOS X用のiPSPをダウンロードする

c) b)のiPSPのアプリケーションアイコン上でControl+Clic、コンテクストメニューから「パッケージの内容を表示」を選択

d) ../Contents/Resouces/ffmpeg のファイルを、/sw/bin にコピーする。/sw/binが嫌な場合は、AppleScriptの"/sw/bin/ffmpeg"の部分も変更する事。(do shell scriptはフルパスを書くのが無難…詳しくは→http://developer.apple.com/ja/technotes/tn2065.html)

e) AppleScriptのソースをアプリケーション形式で保存する

● 使い方

変換したい動画ファイルを、e)のアプリケーションにドロップする。foo.aviは、foo_re.mp4に変換される。

AppleScriptソース (追記:ケアレスミスしてました、quoted form of ..を追加)

on open selectItem
     repeat with eachItem in selectItem
          reencode(eachItem) of me
     end repeat
end open 
  -- re-encode by ffmpeg
on reencode(inFile)
     -- ext check
     if ((inFile as text) does not end with ".avi") or ((inFile as text) does not end with ".AVI") then
          display dialog "ext. error : " & (inFile as Unicode text)
          return
     end if
     
     -- make outFile name
     set len to length of (inFile as text)
     set str1 to text from (1) to (len - 4) of (inFile as text) -- remove ext   
     set outFile to str1 & "_re.mp4"
     -- display dialog (outFile as Unicode text) -- for debug
     
     -- params
     set params to "-t 30 -s 640x480 -r 29.97 -b 3000"
     
     -- exec
     set inFile to POSIX path of inFile
     set outFile to POSIX path of file outFile
     -- display dialog (outFile as Unicode text) -- for debug
	set cmd to "/sw/bin/ffmpeg  -i  " & quoted form of inFile & " " & params & " " & quoted form of outFile
     -- display dialog "shell cmd :" & cmd -- for debug
     do shell script cmd
end reencode

↓ 参考:ショートムービーのAVIファイルを、FFusionを入れた状態のQuickTime Playerで再生した時のコンソール表示の一部

Error at MB: 2
concealing errors
Error, header damaged or not MPEG4 header (f_code=0)
header damaged
FFusion Codec: Error while decoding frame
vop not coded
header damaged
FFusion Codec: Error while decoding frame
Marker bit missing before vop_coded
Error, header damaged or not MPEG4 header (f_code=0)
header damaged
FFusion Codec: Error while decoding frame
Marker bit missing before vop_coded
vop not coded
header damaged
   ...