FFmpeg for Android

开发Make Face,需要合成视频。iOS有官方例子而Android没有,至少4.1以前肯定没有。花了2个礼拜研究,最后找到最捷径的办法:直接FFmpeg命令。

官网:http://ffmpeg.org/index.html

二进制下载:https://bitbucket.org/trovao/ffmpeg-android

参考:https://github.com/guardianproject/android-ffmpeg-java

 

具体步骤:

1.把生成好的二进制可运行的ffmpeg放入res/raw中

2.通过getResources().openRawResource(R.raw.ffmpeg)得到ffmpeg并通过openFileOutput("/data/data/com.couldhll.makeface/files/ffmpeg", Context.MODE_PRIVATE);复制进有权限执行文件的目录
PS:input.mp4和img001.png...img999.png资源文件通过相同方式复制到该目录

3.运行chmod 777 /data/data/com.couldhll.makeface/files/ffmpeg赋予ffmpeg最高权限

4.执行命令
/data/data/com.couldhll.makeface/files/ffmpeg -y -i /data/data/com.couldhll.makeface/files/input.mp4 -vf \"movie=/data/data/com.couldhll.makeface/files/img%03d.png [watermark]; [in][watermark] overlay=10:10 [out]\" /data/data/com.couldhll.makeface/files/output.mp4
把img001.png到img999.png每一帧叠在input.mp4上生成output.mp4

最后,需要注意是生成的时间可能有些久,一般2-3分钟的视频需要40-50秒。因为Android机型性能相差巨大,生成时间不可控。建议把生成视频这部分移到服务器端。
 

How to install FFmpeg on Mac OS X(转)

FFmpeg-Logo.svg

This post is going to be to show you how to install FFmpeg on Mac OS X as easy as possible. For that, i will use a software called “Homebrew”. It is a linux like package manager with a lot of useful tools easy to install from it. It is quite similar to MacPorts, but in this special case you will get a more recent FFmpeg using Homebrew thanMacPorts. Once you are familiar with Homebrew, i am sure you will use it a lot more afterwards if you are not using already.

Install/Update Xcode

To be able to use Homebrew you need the Xcode Command Line Tools. Follow these steps to install it:

1. Open “Mac App Store” and install Xcode. If you have XCode already installed, update to the latest version available if necesary.

2. After Xcode has been successfully installed, open the Xcode Preferences-Pane.

3. Select the “Downloads”-Tab and click on “Install” next to the “Command Line Tools” entry.

XCode Downloads-Pane

 

The time i am writing this Tutorial i have already installed the Xcode Command Line Tools, even if not in the latest version, which i will correct later on my system. But, this is also good for you as you can see what to install if i tell you that on your system will be an “Install”-Button where is an “Update”-Button on the provided screenshot.

 

Install Homebrew

Installing Homebrew is quite simple. Everything you need to do is to open up a Terminal window, paste and execute the following command and follow the instructions during the installation process.

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

After successful installation you should execute:

brew doctor

This checks if your Homebrew installation was successful and installation of Formulas (Packages) will work. If you have any trouble please drop me a note in the comments section.

Install FFmpeg

Now we are nearly done as all prerequisites are now installed and we can start installing FFmpeg. As there are many options when installing FFmpeg, a command you should know about is brew options <Formula> . This will show you all available options for the fromula you are going to install which will be in this case “ffmpeg”. So in our case, brew options ffmpeg will print the following information to your screen:

1
2
3
4
5
6
7
8
reneVolution$ brew options ffmpeg
--with-fdk-aac
    Enable the Fraunhofer FDK AAC library
--with-ffplay
    Enable FFplay media player
--with-freetype
    Build with freetype support

To finally install FFmpeg on your system you should follow these steps:

1. Check if your Homebrew installation is up to date and working with brew doctor

2. Check all available options for ffmpeg with brew options ffmpeg

3. Install ffmpeg with all desired options with brew install ffmpeg [all youroptions]

Example:

To install FFmpeg with all available options without disabling anything execute:

1
brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-frei0r --with-libass --with-libvo-aacenc --with-libvorbis --with-libvpx --with-opencore-amr --with-openjpeg --with-opus --with-rtmpdump --with-schroedinger --with-speex --with-theora --with-tools

If you are running into any troubles during installation please leave a message in the comments section.

Afterwards FFmpeg should be installed and you can start enjoy to use it.

If you prefer to work with FFmpeg on your Windows machine, read my article How to get the latest FFmpeg binaries for Windows.

美驻华大使骆家辉对国人的评价(转)

1﹑非常聪明,但非常相信传言;
2﹑凡事喜欢抢,从出生抢床位,到临终抢坟地,从头抢到尾;
3﹑在大事上能忍气吞声,在小事上却斤斤计较;
4﹑能通过关系办的事,绝不通过正当途径解决;
5﹑计较的不是不公平,而是自己不是受益者;
6﹑动辄批判外界,却很少反思自己;
7﹑自己爽不爽没关系,反正不能让别人爽;
8﹑不为朋友的成功鼓掌,愿为陌生人的悲惨捐助;
9﹑不为强者的坚持伸手,愿为弱者的妥协流泪;
10﹑不愿为执行规则所累,宁愿为适应潜规则受罪;
11﹑不为大家的利益奋斗,愿为大家的不幸怒骂;
12﹑不为长远未来谋福,愿为眼前的小利冒险。