Android 中的 FFMPEG 问题
我已经使用 NDK 成功将 FFMPEG 库编译到 android。 (使用Rock Player FFMPEG实现)http://www.rockplayer.com/download/rockplayer_ffmpeg_git_20100418.zip
我知道FFMPEG支持.avi,divX,mov等。但我创建了一个媒体播放器并尝试运行它们,但无法播放它们。我这是使用 FFMPEG 库的正确方法。任何人都可以帮忙吗?我可以播放默认视频、mp4、3gp 等。这是媒体播放器的代码
public native String stringFromJNI();
static {
System.loadLibrary("ffmpeg");
System.loadLibrary("ffmpeg-test-jni");
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView tv =(TextView) findViewById(R.id.textView1);
tv.setText( stringFromJNI() );
System.gc();
Log.d("Video FFmpeg ", "**");
getWindow().setFormat(PixelFormat.TRANSLUCENT);
String filepath = Environment.getExternalStorageDirectory()+"/simple.avi";
Log.d("File path", filepath);
MediaController mc = new MediaController(this);
VideoView video=(VideoView) findViewById(R.id.video);
mc.setMediaPlayer(video);
video.setVideoPath(filepath);
video.setMediaController(mc);
mc.show();
//video.setVideoPath("/mnt/sdcard/Movies/Ishq-Hothon-Se.3gp");
video.start();
View nextButton = findViewById(R.id.button1);
nextButton.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i=new Intent(this,NextVideo.class);
startActivity(i);
}
}
I have successfully compiled the FFMPEG library to android using NDK.
(using Rock Player FFMPEG implementation)http://www.rockplayer.com/download/rockplayer_ffmpeg_git_20100418.zip
I know that FFMPEG supports .avi, divX, mov ect. But I created a mediaplayer and tried to run them but I was not able to play them. I is this the right way to use the FFMPEG library. Can Any one Help.I am able to play defaut video, mp4, 3gp etc. Here is the code for mediaplayer
public native String stringFromJNI();
static {
System.loadLibrary("ffmpeg");
System.loadLibrary("ffmpeg-test-jni");
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView tv =(TextView) findViewById(R.id.textView1);
tv.setText( stringFromJNI() );
System.gc();
Log.d("Video FFmpeg ", "**");
getWindow().setFormat(PixelFormat.TRANSLUCENT);
String filepath = Environment.getExternalStorageDirectory()+"/simple.avi";
Log.d("File path", filepath);
MediaController mc = new MediaController(this);
VideoView video=(VideoView) findViewById(R.id.video);
mc.setMediaPlayer(video);
video.setVideoPath(filepath);
video.setMediaController(mc);
mc.show();
//video.setVideoPath("/mnt/sdcard/Movies/Ishq-Hothon-Se.3gp");
video.start();
View nextButton = findViewById(R.id.button1);
nextButton.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i=new Intent(this,NextVideo.class);
startActivity(i);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论