首页 > Linux > ffmpeg安装

ffmpeg安装

2013年3月14日 发表评论 阅读评论

ffmpeg x264 2-pass转码
1、先安装yasm,编译x264所需

http://yasm.tortall.net/Download.html

tar xzf yasm-1.1.0.tar.gz
cd yasm-1.1.0
./configure
make
make install

2、安装x264

http://www.videolan.org/developers/x264.html

tar xjf last_x264.tar.bz2
cd x264-snapshot-20110912-2245
./configure –enable-shared –prefix=/usr
make
make install

3、安装ffmpeg

http://ffmpeg.org/download.html

./configure –enable-libx264 –enable-gpl –enable-shared –prefix=/usr
make
make install

4、转码
新一些版本的ffmpeg应该是
ffmpeg -i av.mov -threads 0 -pass 1 -vcodec libx264 -preset medium_firstpass -s 400×240 -b 200k -an 1.mp4
ffmpeg -i av.mov -threads 0 -pass 2 -vcodec libx264 -preset medium -s 400×240 -b 200k -an 1.mp4
因为preset是x264内建的

旧的
4、加入libx264的preset
新的ffmpeg之中不知道为什么把x264的几个preset拿掉了,可以参考

http://trac.perian.org/browser/ffmpeg/ffpresets

把拿掉的几个preset补充进去。preset的存放目录在/usr/share/ffmpeg
ffmpeg -i av.mov -threads 0 -pass 1 -vcodec libx264 -vpre medium_firstpass -s 400×240 -b 200k -an 1.mp4
ffmpeg -i av.mov -threads 0 -pass 2 -vcodec libx264 -vpre medium -s 400×240 -b 200k -an 1.mp4

transcode.sh脚本

## Transcode shell

# Uncomment this and the last two lines to put results to S3 bucket (Requires configures s3cmd)
#bucket=”

transcode=$(date +”%d-%m-%Y-transcode-$1″)
threads=’4′

mkdir $transcode

# iPhone 480×272

ffmpeg -i “$1″ -s 480×272 -aspect 480:272 -r 30000/1001 -b 360k -bt 416k -vcodec libx264 -threads $threads -pass 1 -vpre medium_firstpass -an “$transcode/$1″-480×272.mp4 && ffmpeg -y -i “$1″ -s 480×272 -aspect 480:272 -r 30000/1001 -b 360k -bt 416k -vcodec libx264 -threads $threads -pass 2 -vpre medium -acodec libmp3lame -ab 64k “$transcode/$1″-480×272.mp4

## MP4 Web

ffmpeg -i “$1″ -s 640×352 -aspect 640:352 -r 30000/1001 -b 360k -bt 416k -vcodec libx264 -threads $threads -pass 1 -vpre medium_firstpass -an “$transcode/$1″-640×352.mp4 && ffmpeg -y -i “$1″ -s 640×352 -aspect 640:352 -r 30000/1001 -b 360k -bt 416k -vcodec libx264 -threads $threads -pass 2 -vpre medium -acodec libmp3lame -ac 2 -ar 44100 -ab 64k “$transcode/$1″-640×352.mp4

ffmpeg -i “$1″ -s 864×480 -aspect 864:480 -r 30000/1001 -b 360k -bt 416k -vcodec libx264 -threads $threads -pass 1 -vpre medium_firstpass -an “$transcode/$1″-864×480.mp4 && ffmpeg -y -i “$1″ -s 864×480 -aspect 864:480 -r 30000/1001 -b 360k -bt 416k -vcodec libx264 -threads $threads -pass 2 -vpre medium -acodec libmp3lame -ac 2 -ar 44100 -ab 96k “$transcode/$1″-864×480.mp4

ffmpeg -i “$1″ -s 1280×720 -aspect 1280:720 -r 30000/1001 -b 360k -bt 416k -vcodec libx264 -threads $threads -pass 1 -vpre medium_firstpass -an “$transcode/$1″-1280×720.mp4 && ffmpeg -y -i “$1″ -s 1280×720 -aspect 1280:720 -r 30000/1001 -b 360k -bt 416k -vcodec libx264 -threads $threads -pass 2 -vpre medium -acodec libmp3lame -ac 2 -ar 44100 -ab 128k “$transcode/$1″-1280×720.mp4

ffmpeg -i “$1″ -s 1920×1072 -aspect 1920:1072 -r 30000/1001 -b 360k -bt 416k -vcodec libx264 -threads $threads -pass 1 -vpre medium_firstpass -an “$transcode/$1″-1920×1072.mp4 && ffmpeg -y -i “$1″ -s 1920×1072 -aspect 1920:1072 -r 30000/1001 -b 360k -bt 416k -vcodec libx264 -threads $threads -pass 2 -vpre medium -acodec libmp3lame -ac 2 -ar 44100 -ab 256k “$transcode/$1″-1920×1072.mp4

## OGG

ffmpeg -y -i “$1″ -s 640×352 -aspect 640:352 -r 30000/1001 -b 360k -bt 416k -vcodec libtheora -threads $threads -acodec libvorbis -ac 2 -ar 44100 -ab 64k “$transcode/$1″-640×352.ogg

ffmpeg -y -i “$1″ -s 864×480 -aspect 864:480 -r 30000/1001 -b 360k -bt 416k -vcodec libtheora -threads $threads -acodec libvorbis -ac 2 -ar 44100 -ab 96k “$transcode/$1″-864×480.ogg

ffmpeg -y -i “$1″ -s 1280×720 -aspect 1280:720 -r 30000/1001 -b 360k -bt 416k -vcodec libtheora -threads $threads -acodec libvorbis -ac 2 -ar 44100 -ab 128k “$transcode/$1″-1280×720.ogg

ffmpeg -y -i “$1″ -s 1920×1072 -aspect 1920:1072 -r 30000/1001 -b 360k -bt 416k -vcodec libtheora -threads $threads -acodec libvorbis -ac 2 -ar 44100 -ab 256k “$transcode/$1″-1920×1072.ogg

## FLV (Fallback) Formats

ffmpeg -i “$1″ -s 640×352 -aspect 640:352 -r 30000/1001 -b 360k -bt 416k -vcodec libx264 -threads $threads -pass 1 -vpre medium_firstpass -an “$transcode/$1″-640×352.flv && ffmpeg -y -i “$1″ -s 640×352 -aspect 640:352 -r 30000/1001 -b 360k -bt 416k -vcodec libx264 -threads $threads -pass 2 -vpre medium -acodec libmp3lame -ac 2 -ar 44100 -ab 64k “$transcode/$1″-640×352.flv

ffmpeg -i “$1″ -s 864×480 -aspect 864:480 -r 30000/1001 -b 360k -bt 416k -vcodec libx264 -threads $threads -pass 1 -vpre medium_firstpass -an “$transcode/$1″-864×480.flv && ffmpeg -y -i “$1″ -s 864×480 -aspect 864:480 -r 30000/1001 -b 360k -bt 416k -vcodec libx264 -threads $threads -pass 2 -vpre medium -acodec libmp3lame -ac 2 -ar 44100 -ab 96k “$transcode/$1″-864×480.flv

ffmpeg -i “$1″ -s 1280×720 -aspect 1280:720 -r 30000/1001 -b 360k -bt 416k -vcodec libx264 -threads $threads -pass 1 -vpre medium_firstpass -an “$transcode/$1″-1280×720.flv && ffmpeg -y -i “$1″ -s 1280×720 -aspect 1280:720 -r 30000/1001 -b 360k -bt 416k -vcodec libx264 -threads $threads -pass 2 -vpre medium -acodec libmp3lame -ac 2 -ar 44100 -ab 128k “$transcode/$1″-1280×720.flv

ffmpeg -i “$1″ -s 1920×1072 -aspect 1920:1072 -r 30000/1001 -b 360k -bt 416k -vcodec libx264 -threads $threads -pass 1 -vpre medium_firstpass -an “$transcode/$1″-1920×1072.flv && ffmpeg -y -i “$1″ -s 1920×1072 -aspect 1920:1072 -r 30000/1001 -b 360k -bt 416k -vcodec libx264 -threads $threads -pass 2 -vpre medium -acodec libmp3lame -ac 2 -ar 44100 -ab 256k “$transcode/$1″-1920×1072.flv

## MP3

ffmpeg -i “$1″ -acodec libmp3lame -threads $threads -ac 2 -ab 128k -vn -y “$transcode/$1″-128k.mp3

ffmpeg -i “$1″ -acodec libmp3lame -threads $threads -ac 2 -ab 256k -vn -y “$transcode/$1″-256k.mp3

# Cleanup

mv $1 “$transcode/original-$1″

#s3cmd put -r $transcode $bucket
#rm -r $transcode

分类: Linux 标签:
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.