我需要使用ffmpeg转换音频文件,但出现错误

时间:2020-05-19 08:20:11

标签: java android ffmpeg

我想将mp3文件转换为wav文件,但不能。 我也尝试将mp3文件转换为其他格式,但总是收到错误消息。 如果您如何导入FFmpeg库,也可能在注释中告诉我,我的FFmpeg实现可能会出现问题。 我搜索了很多,但找不到解决方案,也许我的FFmpeg命令代码有问题。如果您知道如何处理白衣,请帮助我。 这是我的代码。

String s = " -i " + musicDbs.get(0).musicPath +" -vn -ar 44100 -b:a 192k "+ dir.getPath();
// s =  -i /storage/emulated/0/Doto30/FX/Pishro_Ft_Hichkas_Divoone.mp3 -vn -ar 44100 -b:a 192k /storage/emulated/0/Doto30/.final_audio.wav
String[]cmd = s.split(" ");
    FFmpeg ffmpeg = FFmpeg.getInstance(context);
    try {
        ffmpeg.loadBinary(new LoadBinaryResponseHandler() {
            @Override
            public void onStart() {
            }

            @Override
            public void onFailure() {
            }

            @Override
            public void onSuccess() {
            }

            @Override
            public void onFinish() {
            }
        });
    } catch (Exception e) {
        Toast.makeText(context, e.getMessage(), Toast.LENGTH_SHORT).show();
    }

    try {
        ffmpeg.execute(cmd, new ExecuteBinaryResponseHandler() {
            @Override
            public void onStart() {
                dialog.show();
            }

            @Override
            public void onProgress(String message) {

            }

            @Override
            public void onFailure(String message) {
                String s1 = message;
                Toast.makeText(context, s1, Toast.LENGTH_SHORT).show();
                dialog.dismiss();

            }

            @Override
            public void onSuccess(String message) {
                Toast.makeText(context, "Build has been successful", Toast.LENGTH_SHORT).show();
                dialog.dismiss();
            }

            @Override
            public void onFinish() {

            }
        });
    } catch (Exception e) {
        Toast.makeText(context, e.getMessage(), Toast.LENGTH_SHORT).show();
    } finally {
        if (ffmpeg.isFFmpegCommandRunning()) {
            ffmpeg.killRunningProcesses();
        }
    }

但是我遇到了这个错误

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
[mp3 @ 0xf6829000] Skipping 0 bytes of junk at 116058.   
[mjpeg @ 0xf687e400] Changing bps to 8
[mp3 @ 0xf6829000] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from '/storage/emulated/0/Doto30/FX/Pishro_Ft_Hichkas_Divoone.mp3':
Metadata:
  album_artist    : [3DaMusic.Ir]
  album           : [3DaMusic.Ir]
  artist          : [3DaMusic.Ir]
  composer        : [3DaMusic.Ir]
  disc            : [3DaMusic.Ir]
  genre           : [3DaMusic.Ir]
  title           : [3DaMusic.Ir]
  lyrics-eng      : [3DaMusic.Ir]
  track           : 1865
  encoded_by      : [3DaMusic.Ir]
  TOPE            : [3DaMusic.Ir]
  copyright       : [3DaMusic.Ir]
  TIT1            : [3DaMusic.Ir]
  date            : 2014
Duration: 00:03:48.08, start: 0.000000, bitrate: 132 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 128 kb/s
Stream #0:1: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 530x533, 90k tbr, 90k tbn, 90k tbc
Metadata:
  title           : [www.shiraz-song.ir]
  comment         : Cover (front)
[NULL @ 0xf6829600] Unable to find a suitable output format for ''
: Invalid argument

如果可以帮助我。

0 个答案:

没有答案