Home > Tags > FFmpeg

FFmpeg

FFmpegで携帯動画をキャリア間相互変換する2

【変換スクリプト】

[root@centos ~]# vi conv_3gp.sh
#
# docomo
#
/usr/local/bin/ffmpeg -y -i $1 -fs 2000000 -vcodec mpeg4 -s 176x144 -r 14.985 -b $3k -asyn
c 1 -acodec libamr_nb -ac 1 -ar 8000 -ab 12.2k -f 3gp $2.tmp
/usr/local/bin/MP4Box -add $2.tmp -brand mmp4:1 -new $2
rm -f $2.tmp
chmod 644 $2
#
# au
#
/usr/local/bin/ffmpeg -y -i $1 -fs 1500000 -vcodec mpeg4 -s 176x144 -r 14.985 -b $5k -asyn
c 1 -acodec libamr_nb -ac 1 -ar 8000 -ab 12.2k -f 3g2 $4.tmp
ruby /usr/bin/atomChange.rb $4.tmp $4
rm -f $4.tmp
chmod 644 $4
#
# SoftBank
#
/usr/local/bin/ffmpeg -y -i $1 -fs 300000 -vcodec mpeg4 -s 176x144 -r 14.985 -b $7k -async
 1 -acodec libamr_nb -ac 1 -ar 8000 -ab 12.2k -f 3gp $6.tmp
/usr/local/bin/MP4Box -add $6.tmp -brand mmp4:1 -new $6
rm -f $6.tmp
chmod 644 $6
#
# PC
#
/usr/local/bin/ffmpeg -y -i $1 -vcodec wmv2 -s 176x144 -r 14.985 -b 64k -async 1 -acodec w
mav2 -ac 1 -ar 22050 -ab 32k $8
chmod 644 $8

rm -f $1

【実行権限付加】

[root@centos ~]# chown hoge conv_3gp.sh
[root@centos ~]# chmod a+x conv_3gp.sh

【使い方】

[root@centos ~] # conv_3gp.sh inputfile.3gp docomo.3gp 64 au.3g2 64 softbank.3gp 64 pc.wmv

inputfile.3gp - 入力ファイル
docomo.3gp - docomo用出力ファイル名
64 - docomo用ビデオビットレート
au.3g2 - au用出力ファイル名
64 - au用ビデオビットレート
softbank.3gp - SoftBank用出力ファイル名
64 - SoftBank用ビデオビットレート
pc.wmv - PC用出力ファイル名
(変換後のファイルサイズを各キャリアで再生可能なサイズにするため、ビデオビットレートを可変にしている)

※「FFmpegで携帯動画をキャリア間相互変換する」記事はオリジナルの手法ではなく、参考サイトを元に実際に成功した手順を覚書しただけのものです。

@参考サイト(覚えている範囲で・・)@
WEB2MEMO =PHP、Ajax、JAVA、AIR、Flex2/3、Ruby、Rails等のメモ=
SE奮闘記
携帯なんて大嫌いっ!!!
同梱ffmpegのlameエンコードの不具合
etc…

FFmpegで携帯動画をキャリア間相互変換する

【準備】

[root@centos ~]# yum install gcc gcc-c++ automake libtool

【FAAC】

[root@centos ~]# tar xzvf faac-1.26.tar.gz
[root@centos ~]# cd faac
[root@centos ~]# sh bootstrap
[root@centos ~]# ./configure
[root@centos ~]# make
[root@centos ~]# make install

【FAAD2】

[root@centos ~]# tar xzvf faad2-2.7.tar.gz
[root@centos ~]# cd faad2-2.7
[root@centos ~]# sh bootstrap
[root@centos ~]# ./configure
[root@centos ~]# make
[root@centos ~]# make install

【AMR-NB】

[root@centos ~]# tar jxvf amrnb-7.0.0.2.tar.bz2
[root@centos ~]# cd amrnb-7.0.0.2
[root@centos ~]# ./configure
[root@centos ~]# make
[root@centos ~]# make install

【AMR-WB】

[root@centos ~]# tar jxvf amrwb-7.0.0.3.tar.bz2
[root@centos ~]# cd amrwb-7.0.0.3
[root@centos ~]# ./configure
[root@centos ~]# make
[root@centos ~]# make install

【A-52】

[root@centos ~]# tar xzvf a52dec-0.7.4.tar.gz
[root@centos ~]# cd a52dec-0.7.4
[root@centos ~]# ./configure
[root@centos ~]# make
[root@centos ~]# make install

【LAME】

[root@centos ~]# tar xzvf lame-398-2.tar.gz
[root@centos ~]# cd lame-398-2
[root@centos ~]# ./configure
[root@centos ~]# make
[root@centos ~]# make install

【Xvid】

[root@centos ~]# tar xzvf xvidcore-1.2.1.tar.gz
[root@centos ~]# cd xvidcore/build/generic
[root@centos ~]# ./configure
[root@centos ~]# make
[root@centos ~]# make install

【x264】

[root@centos ~]# yum -y install nasm yasm
(x264をコンパイルするための準備)

[root@centos ~]# tar jxvf x264-snapshot-20090226-2245.tar.bz2
[root@centos ~]# cd x264-snapshot-20090226-2245
[root@centos ~]# ./configure  --enable-pthread --enable-shared
[root@centos ~]# make
[root@centos ~]# make install

【FFmpeg】

[root@centos ~]# svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
[root@centos ~]# cd ffmpeg
[root@centos ~]# ./configure --enable-libamr-nb --enable-libamr-wb --enable-libxvid --disable-ffplay --disable-ffserver --enable-libmp3lame --enable-libfaad --enable-libfaac --enable-libx264 --enable-gpl --enable-nonfree --enable-shared
[root@centos ~]# make
[root@centos ~]# make install

【AMR系のライブラリをロードするように設定】

[root@centos ~]# vi /etc/ld.so.conf.d/ffmpeg.conf
/usr/local/lib
[root@centos ~]# ldconfig

【MP4Box】

[root@centos ~]# yum install zlib-devel libX11-devel libXt-devel
[root@centos ~]# tar xzvf gpac-0.4.5.tar.gz
[root@centos ~]# cd gpac
[root@centos ~]# chmod 544 configure
[root@centos ~]# ./configure --disable-wx
[root@centos ~]# make lib
[root@centos ~]# make apps
[root@centos ~]# make install

【Ruby】

[root@centos ~]# yum install ruby ruby-devel ruby-irb ruby-libs ruby-rdoc ruby-ri

[root@centos ~]# cp atomChange.rb /usr/bin/

【ffmpeg-php】*1

[root@centos ~]# yum install php-devel
(ffmpeg-phpをコンパイルするための準備)

[root@centos ~]# tar jxvf ffmpeg-php-0.6.0.tbz2
[root@centos ~]# cd ffmpeg-php-0.6.0
[root@centos ~]# phpize
[root@centos ~]# ./configure
[root@centos ~]# make
[root@centos ~]# make install

※上記の方法でもバージョン違いにより上手く行かない事があるかもしれません。私は成功時のファイルを全て保存しているので、再構築時にはそれらを使用しています。コーデックのバージョンによりffmpegのmakeに失敗したり、正しくコーデックが使用できなかったりしたため苦肉の策なのです。本当はヘタレなだけ・・・

*1)09/03/24現在、上記の方法でffmpeg-phpをインストールするとmakeでerrorが出ます。原因はffmpegのリビジョン違いによるものと思われ、個人的な解決策としては・・・上記の方法で成功した時のffmpegが保存してあるので、それを再使用して回避しています^^;

Home > Tags > FFmpeg

Ads
Tag Cloud
Feeds
Counter

Return to page top