在windows环境下通过java调用命令行执行ffmpeg视频编辑命令报错,但是直接使用系统命令行执行相同命令能执行成功。请问是哪里出了问题?

环境:
java1.8
mvn:
javacv.version: 1.5.7
javacpp-platform.version: 1.5.7
ffmpeg:5.0-1.5.7
ffmpeg版本:
6.0-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers

源代码:

@PostMapping("/uploadVideo")
@Transactional(rollbackFor = {RuntimeException.class})
public BaseResult uploadVideo(@RequestPart MultipartFile file) throws IOException, InterruptedException {
    long startTime = System.currentTimeMillis();
    log.info("视频压缩开始");
    File   sourceVideo   = videoCompressionUtils.multipartFile2File(file,"C:\\Users\\HUANGMINGHUA\\Desktop\\test");
    String canonicalPath = sourceVideo.getCanonicalPath();
    String concat        = canonicalPath.substring(0, canonicalPath.lastIndexOf("\\") + 1).concat("output.mp4");
    String ffmpeg        = Loader.load(org.bytedeco.ffmpeg.ffmpeg.class);
    ProcessBuilder pb = new ProcessBuilder().inheritIO().command(ffmpeg,"ffmpeg -i " + canonicalPath + " -r 50 -b:v 2000k  -s 1080x1920 " + concat);
    pb.inheritIO().start().waitFor();
    log.info("视频压缩结束,耗时:{}", (System.currentTimeMillis() - startTime));
    return null;
}

控制台报错信息:

ffmpeg version 5.0 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 10.2.0 (Rev5, Built by MSYS2 project)
  configuration: --prefix=.. --disable-iconv --disable-opencl --disable-sdl2 --disable-bzlib --disable-lzma --disable-linux-perf --disable-xlib --enable-shared --enable-version3 --enable-runtime-cpudetect --enable-zlib --enable-libmp3lame --enable-libspeex --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-openssl --enable-libopenh264 --enable-libvpx --enable-libfreetype --enable-libopus --enable-libxml2 --enable-libsrt --enable-libwebp --enable-cuda --enable-cuvid --enable-nvenc --enable-libmfx --enable-w32threads --enable-indev=dshow --target-os=mingw32 --cc='gcc -m64' --extra-cflags='-DLIBXML_STATIC -I../include/ -I../include/libxml2/' --extra-ldflags=-L../lib/ --extra-libs='-static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lgcc_eh -lWs2_32 -lcrypt32 -lpthread -lz -lm -Wl,-Bdynamic -lole32 -luuid'
  libavutil      57. 17.100 / 57. 17.100
  libavcodec     59. 18.100 / 59. 18.100
  libavformat    59. 16.100 / 59. 16.100
  libavdevice    59.  4.100 / 59.  4.100
  libavfilter     8. 24.100 /  8. 24.100
  libswscale      6.  4.100 /  6.  4.100
  libswresample   4.  3.100 /  4.  3.100
Output #0, mp4, to 'ffmpeg -i C:\Users\HUANGMINGHUA\Desktop\test\be40a86d-fdc5-4190-bf1c-ab1a424f8666.mp4 -r 50 -b:v 2000k  -s 1080x1920 C:\Users\HUANGMINGHUA\Desktop\test\output.mp4':
Output file #0 does not contain any stream

系统命令行执行结果

C:\Users\HUANGMINGHUA>ffmpeg -i C:\Users\HUANGMINGHUA\Desktop\test\be40a86d-fdc5-4190-bf1c-ab1a424f8666.mp4 -r 50 -b:v 2000k  -s 1080x1920 C:\Users\HUANGMINGHUA\Desktop\test\output.mp4
ffmpeg version 6.0-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 12.2.0 (Rev10, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      58.  2.100 / 58.  2.100
  libavcodec     60.  3.100 / 60.  3.100
  libavformat    60.  3.100 / 60.  3.100
  libavdevice    60.  1.100 / 60.  1.100
  libavfilter     9.  3.100 /  9.  3.100
  libswscale      7.  1.100 /  7.  1.100
  libswresample   4. 10.100 /  4. 10.100
  libpostproc    57.  1.100 / 57.  1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\HUANGMINGHUA\Desktop\test\be40a86d-fdc5-4190-bf1c-ab1a424f8666.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2023-04-09T12:08:54.000000Z
    com.android.version: 13
    com.android.capture.fps: 60.000000
  Duration: 00:00:02.72, start: 0.000000, bitrate: 72825 kb/s
  Stream #0:0[0x1](eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 3840x2160, 73456 kb/s, 60.02 fps, 60 tbr, 90k tbn (default)
    Metadata:
      creation_time   : 2023-04-09T12:08:54.000000Z
      handler_name    : VideoHandle
      vendor_id       : [0][0][0][0]
    Side data:
      displaymatrix: rotation of -90.00 degrees
  Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default)
    Metadata:
      creation_time   : 2023-04-09T12:08:54.000000Z
      handler_name    : SoundHandle
      vendor_id       : [0][0][0][0]
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 000001abb9c5b6c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 AVX512
[libx264 @ 000001abb9c5b6c0] profile High, level 4.2, 4:2:0, 8-bit
[libx264 @ 000001abb9c5b6c0] 264 - core 164 r3106 eaa68fa - H.264/MPEG-4 AVC codec - Copyleft 2003-2023 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=2000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'C:\Users\HUANGMINGHUA\Desktop\test\output.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    com.android.capture.fps: 60.000000
    com.android.version: 13
    encoder         : Lavf60.3.100
  Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1080x1920, q=2-31, 2000 kb/s, 50 fps, 12800 tbn (default)
    Metadata:
      creation_time   : 2023-04-09T12:08:54.000000Z
      handler_name    : VideoHandle
      vendor_id       : [0][0][0][0]
      encoder         : Lavc60.3.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 0 vbv_delay: N/A
      displaymatrix: rotation of -0.00 degrees
  Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      creation_time   : 2023-04-09T12:08:54.000000Z
      handler_name    : SoundHandle
      vendor_id       : [0][0][0][0]
      encoder         : Lavc60.3.100 aac
frame=  138 fps= 31 q=-1.0 Lsize=     610kB time=00:00:02.70 bitrate=1851.8kbits/s dup=2 drop=25 speed=0.608x
video:564kB audio:41kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.786296%
[libx264 @ 000001abb9c5b6c0] frame I:1     Avg QP:34.63  size: 42695
[libx264 @ 000001abb9c5b6c0] frame P:35    Avg QP:33.01  size:  8007
[libx264 @ 000001abb9c5b6c0] frame B:102   Avg QP:36.28  size:  2491
[libx264 @ 000001abb9c5b6c0] consecutive B-frames:  1.4%  0.0%  0.0% 98.6%
[libx264 @ 000001abb9c5b6c0] mb I  I16..4: 25.3% 58.0% 16.8%
[libx264 @ 000001abb9c5b6c0] mb P  I16..4:  0.3%  1.1%  0.2%  P16..4: 21.2%  2.6%  1.8%  0.0%  0.0%    skip:72.7%
[libx264 @ 000001abb9c5b6c0] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8: 32.7%  0.5%  0.1%  direct: 0.1%  skip:66.7%  L0:40.9% L1:58.7% BI: 0.4%
[libx264 @ 000001abb9c5b6c0] final ratefactor: 28.53
[libx264 @ 000001abb9c5b6c0] 8x8 transform intra:61.6% inter:85.4%
[libx264 @ 000001abb9c5b6c0] coded y,uvDC,uvAC intra: 43.6% 32.3% 5.2% inter: 2.0% 1.5% 0.0%
[libx264 @ 000001abb9c5b6c0] i16 v,h,dc,p: 35% 26%  9% 29%
[libx264 @ 000001abb9c5b6c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 15% 24%  6%  8% 10%  8%  5%  6%
[libx264 @ 000001abb9c5b6c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 22% 18%  4%  7%  6%  7%  3%  3%
[libx264 @ 000001abb9c5b6c0] i8c dc,h,v,p: 77% 12% 10%  1%
[libx264 @ 000001abb9c5b6c0] Weighted P-Frames: Y:34.3% UV:14.3%
[libx264 @ 000001abb9c5b6c0] ref P L0: 58.0% 18.8% 16.9%  5.0%  1.3%
[libx264 @ 000001abb9c5b6c0] ref B L0: 93.0%  6.2%  0.8%
[libx264 @ 000001abb9c5b6c0] ref B L1: 97.5%  2.5%
[libx264 @ 000001abb9c5b6c0] kb/s:1672.66
[aac @ 000001abb9b3afc0] Qavg: 4860.938
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!