为什么FFMPEG命令在android Pie(版本9)中不起作用,而在次版本中却不能正常工作?

时间:2019-06-01 20:55:28

标签: android mobile ffmpeg

我正在使用一个应用程序在其中使用REST API将图像和视频上传到服务器,在上传之前先压缩这些文件,为此,我正在使用FFMPEG库。问题是FFMPEG命令在android版本8和更低版本中可以正常运行,但在android版本9中不能正常运行。 它总是在版本9中触发onFailure(String message)。当我运行fFmpeg.execute(cmd,new ExecuteBinaryResponseHandler()

时,总是会收到此错误。
ffmpeg version n4.0-39-gda39990 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 4.9.x (GCC) 20150123 (prerelease)
  configuration: --target-os=linux --cross-prefix=/root/bravobit/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/root/bravobit/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-ffprobe --enable-libopus --enable-libvorbis --enable-libfdk-aac --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-libvpx --enable-libass --enable-yasm --enable-pthreads --disable-debug --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-linux-perf --disable-doc --disable-shared --enable-static --enable-runtime-cpudetect --enable-nonfree --enable-network --enable-avresample --enable-avformat --enable-avcodec --enable-indev=lavfi --enable-hwaccels --enable-ffmpeg --enable-zlib --enable-gpl --enable-small --enable-nonfree --pkg-config=pkg-config --pkg-config-flags=--static --prefix=/root/bravobit/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/root/bravobit/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/root/bravobit/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-cxxflags=
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100
[mjpeg @ 0xf1562380] unable to decode APP fields: Invalid data found when processing input
Input #0, image2, from '/storage/EAE5-B041/DCIM/Camera/20190601_195456.jpg':
  Duration: 00:00:00.04, start: 0.000000, bitrate: 1034124 kb/s
    Stream #0:0: Video: mjpeg, yuvj422p(pc, bt470bg/unknown/unknown), 4128x3096, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (mjpeg (native) -> mjpeg (native))
Press [q] to stop, [?] for help
[mjpeg @ 0xf1562700] unable to decode APP fields: Invalid data found when processing input
[swscaler @ 0xf08c3000] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to '/storage/emulated/0/Movies/scene_machine_pic.jpg':
  Metadata:
    encoder         : Lavf58.12.100
    Stream #0:0: Video: mjpeg, yuvj422p(pc), 800x600, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.18.100 mjpeg
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
[image2 @ 0xf1524600] Could not open file : /storage/emulated/0/Movies/scene_machine_pic.jpg
av_interleaved_write_frame(): I/O error
frame=    1 fps=0.0 q=5.8 Lsize=N/A time=00:00:00.04 bitrate=N/A speed=0.0495x    
video:37kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!

我从堆栈溢出和github搜索了很多东西,但是没有找到合适的解决方案。

对于图像压缩,我使用此命令。

String[] complexCommand = {"-i", path, "-vf", "scale=w=800:h=600:force_original_aspect_ratio=decrease", filePath,};

对于视频压缩,我使用此命令。

String[] complexCommand = {"-ss", "" + startMs / 1000, "-y", "-i", path, "-t", "" + (endMs - startMs) / 1000, "-vcodec", "libx264", "-preset", "ultrafast", "-s", "640x360", filePath};

我希望在fFmpeg.execute(cmd,new ExecuteBinaryResponseHandler()中触发onSuccess(String message)方法并获取正确的生成输出。

0 个答案:

没有答案