NUブログ 自作Webアプリで一発当てたいプログラマ

DVDからiPhoneに動画をおとす

タグ:iPhone, DVD, 雑記

「Heroes」やら「プリズンブレイク」やら、アメリカのドラマを見たい!と思って楽天レンタルの会員登録を行いました。

で、せっかくiPhoneがあるので、出勤時に電車で見たいよね。ということでやり方を調べていたところ、Linuxで「HandBrake」という簡単に変換できるツールがあるようで、GUI版の「HandBrakeGtk」をインストールしようとしたら、なにやら依存関係でインストールできず…

もう少し調べていると、コマンドライン版のマニュアルを見つけました。

その中で、iPhone用に最適化されたオプションがありました。なんてご親切な。

取り合えずDVDドライブのパスだけ変更してそのままコマンドを実行してみる。

./HandBrakeCLI -i /cdrom -o ~/Movies/movie.mp4  -e x264 -b 960 -E faac -B 128 -R 48 -f mp4 -I -w 480 -m -x level=30:cabac=0:ref=1:analyse=all:me=umh:subme=6:no-fast-pskip=1:trellis=1

結構時間はかかりましたが、上記コマンド一発で変換できました!が、字幕が入ってない…
ヘルプを見てみると、

### Picture Settings---------------------------------------------------------
   :
   :
   -s, --subtitle <number> Select subtitle (default: none)
   -U, --subtitle-scan     Scan for subtitles in an extra 1st pass, and choose
                           the one that's only used 10 percent of the time
                           or less. This should locate subtitles for short
                           foreign language segments. Best used in conjunction
                           with --subtitle-forced.
   -F, --subtitle-forced   Only display subtitles from the selected stream if
                           the subtitle has the forced flag set. May be used in
                           conjunction with --subtitle-scan to auto-select
                           a stream if it contains forced subtitles.
   :
   :

このあたりかなぁ。とりあえず -s 1 を追加して再度実行。

./HandBrakeCLI -i /cdrom -o ~/Movies/movie.mp4  -e x264 -b 960 -E faac -B 128 -R 48 -f mp4 -I -w 480 -s 1 -m -x level=30:cabac=0:ref=1:analyse=all:me=umh:subme=6:no-fast-pskip=1:trellis=1

字幕付きにできました〜。
チャプターリストまで付いてました。これは快適。


追記
ubuntu に HandBrakeGtkをインストールするために monofix をインストールしないといけないらしい。で、以下の順番でインストール。

sudo apt-get install mono-mcs mono-2.0-devel gtk-sharp2
sudo dpkg -i monofix_1.0_all.deb
sudo dpkg -i handbrakegtk_1.0.1_i386.deb

参考
これでGUI版も動きました。