gpt4 book ai didi

android - ffmpeg 库不工作

转载 作者:行者123 更新时间:2023-12-04 23:15:37 25 4
gpt4 key购买 nike

我有 FFmpeg在 Android 上编译 (libffmpeg.so)。现在我必须构建一个像 RockPlayer 这样的应用程序,或者使用现有的 Android 多媒体框架来调用 FFmpeg随着视频播放。

有没有集成的步骤/程序/代码/示例FFmpeg在 Android/StageFright 上?

Can you please guide me on how can I use this library for multimedia playback?



我已经做了渲染、混合。

最佳答案

  • 编译'com.writingminds:FFmpegAndroid:0.3.2'将此添加到gradle
  • 在 onCreate 中添加:

    ffmpeg = FFmpeg.getInstance(this.getApplicationContext());

    (先声明FFmpeg ffmpeg;)
  • 加载库:loadFFMpegBinary();
  • 使用 ffmpeg 向视频添加音频的代码:

  • 使用 execFFmpegBinaryShortest(null); 调用函数

    **
    private void execFFmpegBinaryShortest(final String[] command) {
    final File outputFile = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/videoaudiomerger/"+"Vid"+"output"+i1+".mp4");

    String[] cmd = new String[]{"-i", selectedVideoPath,"-i",audiopath,"-map","1:a","-map","0:v","-codec","copy","-shortest",outputFile.getPath()};


    try {

    ffmpeg.execute(cmd, new ExecuteBinaryResponseHandler() {
    @Override
    public void onFailure(String s) {
    System.out.println("on failure----"+s);
    }

    @Override
    public void onSuccess(String s) {
    System.out.println("on success-----"+s);
    }

    @Override
    public void onProgress(String s) {
    //Log.d(TAG, "Started command : ffmpeg "+command);
    System.out.println("Started---"+s);

    }

    @Override
    public void onStart() {


    //Log.d(TAG, "Started command : ffmpeg " + command);
    System.out.println("Start----");

    }

    @Override
    public void onFinish() {
    System.out.println("Finish-----");


    }
    });
    } catch (FFmpegCommandAlreadyRunningException e) {
    // do nothing for now
    System.out.println("exceptio :::"+e.getMessage());
    }


    }

    **

    关于android - ffmpeg 库不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43133158/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com