android - 从 android 运行 ffmpeg 命令 ffmpeg 语法错误在 logcat 中

标签 android ffmpeg ubuntu-11.10

我已经成功编译了android版的ffmpeg并移植了它。

我放置

  1. /system/lib目录下的libffmpeg.so
  2. ffmpeg 可执行文件位于 /system/bin/system/xbin 目录中(我不确定将其放置在哪里)。我直接从源目录复制了 ffmpeg 可执行文件(不确定这是否是正确的方法)

现在我正在使用以下代码从 android 执行命令!!

imports *
public class LatestActivity extends Activity {

    private Process process;
    String command,text;

    static { 
        System.loadLibrary("ffmpeg");
    }

  @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_latest);

          //Execute Command !!  
          try {
               Execute();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (InterruptedException e) {
               // TODO Auto-generated catch block
                e.printStackTrace();
          }
     }




public void Execute() throws IOException, InterruptedException{
        try {
            File dir=new File("/system/bin");
            String[] cmd= {"ffmpeg","-codecs"};

            process=Runtime.getRuntime().exec(cmd,null,dir);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            Log.d("Process IOException starts:",e.getMessage());
            e.printStackTrace();
            Log.d("System Manual exit !!",e.getMessage());
            System.exit(MODE_PRIVATE);
        }

        BufferedReader stdInput = new BufferedReader(new InputStreamReader(process.getInputStream()),16384);

         BufferedReader stdError = new BufferedReader(new InputStreamReader(process.getErrorStream()));

           // read the output from the command
           Log.d("Application output: ","Output if any !"); 
            while ((text = stdInput.readLine()) != null) {
                Log.d("Output: ",text); //$NON-NLS-1$
               }


        text="";
           // read any errors from the attempted command
        Log.d("Application output: ","Errors if any !");  //$NON-NLS-1$
           while ((text = stdError.readLine()) != null) {

               Log.d("Error: ",text);  //$NON-NLS-1$
           }



           stdInput.close();
           stdError.close();

           process.waitFor();
           process.getOutputStream().close();
           process.getInputStream().close();
           process.getErrorStream().close(); 
           destroyProcess(process);
           //process.destroy();

    }

    private static void destroyProcess(Process process) {
        try {
            if (process != null) {
                // use exitValue() to determine if process is still running.
                process.exitValue();
            }
        } catch (IllegalThreadStateException e) {
            // process is still running, kill it.
            process.destroy();
        }
    }

  }

这是 logcat 输出:

09-05 15:29:13.287: D/dalvikvm(2670): No JNI_OnLoad found in /system/lib/libffmpeg.so 0x44e7e910, skipping init
09-05 15:29:29.117: I/global(2670): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
09-05 15:29:29.117: D/Application output:(2670): Output if any !
09-05 15:29:29.117: D/Application output:(2670): Errors if any !
09-05 15:29:29.127: D/Error:(2670): /system/bin/ffmpeg: 1: Syntax error: "(" unexpected

我既没有收到任何错误,也没有命令输出。
最后显示语法错误。
我想知道它是什么类型的语法错误。如何应对?

我做错了什么吗?

最佳答案

如果 ffmpeg 文件未针对您的 CPU 架构进行编译,则会出现此错误。 您的命令可能是正确的,但您需要找到正确的 ffmpeg 文件。

关于android - 从 android 运行 ffmpeg 命令 ffmpeg 语法错误在 logcat 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12279262/

相关文章:

amazon-ec2 - 当停止 ebs 支持的实例时,交换会消失。

android - Play 商店中应用的不同开发者名称

audio - 未找到输出流 #0 :1 的编码器(编解码器无)

FFmpeg 导出特定像素

OpenCV VideoWriter 不写入 Output.avi

ruby - Nokogiri 1.5.2 未安装在 Ubuntu 11.10 上

ruby-on-rails-3 - 无法让 "rails console"在 ubuntu 11.10 上工作

java - 使用VS代码的Gradle错误: “Could not run build action using Gradle distribution”

java - Android SQLite 搜索结果出错

android - 什么 Intent 会从 url 打开 pdf?