Android 中的 FFMPEG 问题

发布于 2024-12-25 19:06:22 字数 1483 浏览 4 评论 0原文

我已经使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文