在Android中使用的FFmpeg没有NDK [英] Using FFmpeg without NDK in android

查看:220
本文介绍了在Android中使用的FFmpeg没有NDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我走了就尽管许多网站和搜索 FFMPEG 实施的Andr​​oid项目。

I go though many site and search regarding "FFMPEG" implementation for android project.

目前正在使用NDK的大多数解决方案。

Most solution founded are using NDK.

但我想用而不使用NDK FFmpeg的,因为我发现的这个链接

but i want to use FFmpeg without using NDK as i found in This Link

推荐答案

我已经使用这个项目 https://github.com/guardianproject/android-ffmpeg-java

I have used this project https://github.com/guardianproject/android-ffmpeg-java

这已经编译FFMPEG库的Andr​​oid版本,这个文件将在RES /原始文件夹(如果你需要更新的版本,你可以更新该文件)。您需要将这个项目添加为一个库到你的。而THST后,你可以写你自己的函数在Java中,例如像这样的:

It has already compiled for android version of FFMPEG library and this file will be in res/raw folder (you can update this file if you need newer version). You need to add this project as a library to your's. And after thst you can write your own function in java for example like this:

public Clip convert (Clip mediaIn, String outPath, ShellCallback sc) throws Exception
{
    ArrayList<String> cmd = new ArrayList<String>();

    cmd.add(mFfmpegBin);
    cmd.add("-y");
    cmd.add("-i");
    cmd.add(new File(mediaIn.path).getCanonicalPath());

    if (mediaIn.startTime != null)
    {
        cmd.add("-ss");
        cmd.add(mediaIn.startTime);
    }
    if (mediaIn.duration != -1)
    {
        cmd.add("-t");
        cmd.add(String.format(Locale.US,"%f",mediaIn.duration));

    }
    Clip mediaOut = new Clip();
    File fileOut = new File(outPath);
    mediaOut.path = fileOut.getCanonicalPath();
    cmd.add(mediaOut.path);
    execFFMPEG(cmd, sc);
    return mediaOut;
}

和使用FfmpegController对象执行它。 请注意我,如果你有任何问题,或者如果这是你想要的。

and execute it using FfmpegController Object. Please notice me if you have any questions or if this is what you want.

编辑: 我希望你把这github上code为您的项目库。 有<一个href="https://github.com/guardianproject/android-ffmpeg-java/blob/master/src/org/ffmpeg/android/FfmpegController.java"相对=nofollow> FfmpegController.java 在src文件夹类。这是一个包装使用命令行的ffmpeg exe文件。如果你想例如执行命令像这样的

I hope you connect this github code as a library for your project. There is FfmpegController.java class in src folder. It's a wrapper for using command line ffmpeg exe file. If you want for example execute command like this one

ffmpeg -i source.wav -b:a 128k output.mp3

您需要添加功能FfmpegController.java类。事情是这样的:

you need to add function to FfmpegController.java class. Something like this:

    public Clip convert(Clip mediaIn, String outPath, ShellCallback sc) throws Exception
    {
    ArrayList<String> cmd = new ArrayList<String>();

    Clip mediaOut = new Clip();

    String mediaPath = mediaIn.path;

    cmd = new ArrayList<String>();

    cmd.add(mFfmpegBin);
    cmd.add("-i");
    cmd.add(mediaPath);

    cmd.add("-b:a");
    cmd.add("128k");

    mediaOut.path = outPath;

    cmd.add(mediaOut.path);

    execFFMPEG(cmd, sc);

    return mediaOut; // this is not importatnt because file will be put in outPath
    }

现在您的项目初始化FfmpegController对象,并运行你的函数。

Now in your project initialize FfmpegController object and run your function.

这篇关于在Android中使用的FFmpeg没有NDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆