Android FFmpeg无法识别的选项

时间:2017-07-04 08:36:15

标签: android ffmpeg

我正在尝试使用ffmepg压缩android中的视频。这是我的代码:

  String[] cmd = {"-y -i" ,myVideo.getAbsolutePath().replaceAll(" ", "%20"),"-vf","-s 640x480","-threads 5","-preset ultrafast","-strict -2", (local_paths.getLocal_images() + File.separator + "test.mp4")};
            FFmpeg ffmpeg = FFmpeg.getInstance(context);
            try {
                //Load the binary
                ffmpeg.loadBinary(new LoadBinaryResponseHandler() {

                    @Override
                    public void onStart() {
                    }

                    @Override
                    public void onFailure() {
                    }

                    @Override
                    public void onSuccess() {
                    }

                    @Override
                    public void onFinish() {
                    }
                });
            } catch (FFmpegNotSupportedException e) {
                // Handle if FFmpeg is not supported by device
            }
            try {
                // to execute "ffmpeg -version" command you just need to pass "-version"
                ffmpeg.execute(cmd, new ExecuteBinaryResponseHandler() {

                    @Override
                    public void onStart() {
                        Log.e("FFmpeg", "onStart");
                    }

                    @Override
                    public void onProgress(String message) {
                        Log.e("FFmpeg", message);
                    }

                    @Override
                    public void onFailure(String message) {
                        Log.e("FFmpeg", message);
                    }

                    @Override
                    public void onSuccess(String message) {
                        Log.e("FFmpeg", message);
                    }


                    @Override
                    public void onFinish() {
                        Log.e("FFmpeg", "onFinish");
                    }
                });
            } catch (FFmpegCommandAlreadyRunningException e) {
                e.printStackTrace();
                // Handle if FFmpeg is already running
            } 

问题是我使用的几乎所有命令都会导致Unrecognized option错误:

> 07-04 11:31:21.471 24610-25450/com.network.imyth.network E/FFmpeg:
> onStart 07-04 11:31:22.091 24610-25460/com.network.imyth.network
> D/FFmpeg: Running publishing updates method 07-04 11:31:22.101
> 24610-24610/com.network.imyth.network E/FFmpeg: ffmpeg version n3.0.1
> Copyright (c) 2000-2016 the FFmpeg developers 07-04 11:31:22.101
> 24610-24610/com.network.imyth.network E/FFmpeg:   built with gcc 4.8
> (GCC) 07-04 11:31:22.101 24610-24610/com.network.imyth.network
> E/FFmpeg:   configuration: --target-os=linux
> --cross-prefix=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi-
> --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/sysroot
> --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/vagrant/SourceCode/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/vagrant/SourceCode/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/include
> -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/lib
> -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags= 07-04 11:31:22.101 24610-24610/com.network.imyth.network E/FFmpeg:   libavutil      55.
> 17.103 / 55. 17.103 07-04 11:31:22.101 24610-24610/com.network.imyth.network E/FFmpeg:   libavcodec     57.
> 24.102 / 57. 24.102 07-04 11:31:22.101 24610-24610/com.network.imyth.network E/FFmpeg:   libavformat    57.
> 25.100 / 57. 25.100 07-04 11:31:22.101 24610-24610/com.network.imyth.network E/FFmpeg:   libavdevice    57. 
> 0.101 / 57.  0.101 07-04 11:31:22.101 24610-24610/com.network.imyth.network E/FFmpeg:   libavfilter     6.
> 31.100 /  6. 31.100 07-04 11:31:22.101 24610-24610/com.network.imyth.network E/FFmpeg:   libswscale      4. 
> 0.100 /  4.  0.100 07-04 11:31:22.101 24610-24610/com.network.imyth.network E/FFmpeg:   libswresample   2. 
> 0.101 /  2.  0.101 07-04 11:31:22.101 24610-24610/com.network.imyth.network E/FFmpeg:   libpostproc    54. 
> 0.100 / 54.  0.100 07-04 11:31:22.101 24610-24610/com.network.imyth.network E/FFmpeg: Unrecognized option 'y
> -i'. 07-04 11:31:22.101 24610-24610/com.network.imyth.network E/FFmpeg: Error splitting the argument list: Option not found 07-04
> 11:31:22.101 24610-24610/com.network.imyth.network E/FFmpeg: ffmpeg
> version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
>                                                                      built with gcc 4.8 (GCC)
>                                                                      configuration: --target-os=linux
> --cross-prefix=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi-
> --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/sysroot
> --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/vagrant/SourceCode/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/vagrant/SourceCode/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/include
> -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/lib
> -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=
>                                                                      libavutil      55. 17.103 / 55. 17.103
>                                                                      libavcodec     57. 24.102 / 57. 24.102
>                                                                      libavformat    57. 25.100 / 57. 25.100
>                                                                      libavdevice    57.  0.101 / 57.  0.101
>                                                                      libavfilter     6. 31.100 /  6. 31.100
>                                                                      libswscale      4.  0.100 /  4.  0.100
>                                                                      libswresample   2.  0.101 /  2.  0.101
>                                                                      libpostproc    54.  0.100 / 54.  0.100
>                                                                    Unrecognized option 'y -i'.
>                                                                    Error splitting the argument list: Option not found 07-04 11:31:22.101
> 24610-24610/com.network.imyth.network E/FFmpeg: onFinish

那么问题是什么我得到这个无法识别的选项错误拆分参数列表:未找到选项

即时使用此LIB ffmpeg-android-java

1 个答案:

答案 0 :(得分:1)

尝试拆分你的参数。这应该有效:

String[] command = {"-y", "-i", "/path/to/your/video.mp4", "-vf", "-s", "640x480", "-threads", "5", "-preset", "ultrafast", "-strict", "-2", "/path/to/your/video_out.mp4"};