How to play video using FFMPEG library in Android?

Macchiato picture Macchiato · Feb 14, 2012 · Viewed 16.2k times · Source

I was able to build ffmpeg library by using rock player build script.

Now I have this .so file, how do I play video? And I want to display this video inside a small LinearLayout in my Activity.

Is it possible?

Update: I know that it's easy to play video using VideoView or MediaPlayer + SurfaceView. I just wanted to understand more about ffmpeg library and how to display the frames inside an Android Activity.

Answer

Andrew picture Andrew · Apr 2, 2015

Have a look at this player: https://github.com/bbcallen/ijkplayer

Basically what you need to do is build a JNI interface through to the MediaPlayer class (or possibly ExoPlayer in newer Android though I haven't done this yet).

If you look at the repo link you will see that this needs to be done on top of ffplay more than ffmpeg as the former is the player and the latter the decode/encode/package tool.