kokorin / Jaffree

______ Stop the War in Ukraine! _______ Java ffmpeg and ffprobe command-line wrapper
Apache License 2.0
475 stars 80 forks source link

CreateProcess error=2, The system cannot find the file specified #203

Closed ahmedrayf closed 3 years ago

ahmedrayf commented 3 years ago

I want to try cut example with source and target path for my video and I am getting exception here,s the code ------------>>>>

Path pathToSrc = Paths.get("F:\VideoProcess\islam sobhi.mp4"); Path pathToDst = Paths.get("F:\VideoProcess\islam sobhi cut.mp4");

    FFmpeg.atPath()
            .addInput(
                    UrlInput.fromPath(pathToSrc)
                            .setPosition(10, TimeUnit.SECONDS)
                            .setDuration(15, TimeUnit.SECONDS)
            )
            .setFilter(StreamType.VIDEO, "scale=160:-2")
            .setOverwriteOutput(true)
            .addArguments("-movflags", "faststart")
            .addOutput(
                    UrlOutput.toPath(pathToDst)
                            .setPosition(10, TimeUnit.SECONDS)
            )
            .execute();

------------------------------------------Exception-----------------------

"C:\Program Files (x86)\Java\jdk1.8.0_92\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.1\lib\idea_rt.jar=62042:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.1\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files (x86)\Java\jdk1.8.0_92\jre\lib\charsets.jar;C:\Program Files (x86)\Java\jdk1.8.0_92\jre\lib\deploy.jar;C:\Program Files (x86)\Java\jdk1.8.0_92\jre\lib\ext\access-bridge-32.jar;C:\Program Files (x86)\Java\jdk1.8.0_92\jre\lib\ext\cldrdata.jar;C:\Program Files (x86)\Java\jdk1.8.0_92\jre\lib\ext\dnsns.jar;C:\Program Files (x86)\Java\jdk1.8.0_92\jre\lib\ext\jaccess.jar;C:\Program Files (x86)\Java\jdk1.8.0_92\jre\lib\ext\jfxrt.jar;C:\Program Files (x86)\Java\jdk1.8.0_92\jre\lib\ext\localedata.jar;C:\Program Files (x86)\Java\jdk1.8.0_92\jre\lib\ext\nashorn.jar;C:\Program Files (x86)\Java\jdk1.8.0_92\jre\lib\ext\sunec.jar;C:\Program Files (x86)\Java\jdk1.8.0_92\jre\lib\ext\sunjce_provider.jar;C:\Program Files (x86)\Java\jdk1.8.0_92\jre\lib\ext\sunmscapi.jar;C:\Program Files (x86)\Java\jdk1.8.0_92\jre\lib\ext\sunpkcs11.jar;C:\Program Files (x86)\Java\jdk1.8.0_92\jre\lib\ext\zipfs.jar;C:\Program Files (x86)\Java\jdk1.8.0_92\jre\lib\javaws.jar;C:\Program Files (x86)\Java\jdk1.8.0_92\jre\lib\jce.jar;C:\Program Files (x86)\Java\jdk1.8.0_92\jre\lib\jfr.jar;C:\Program Files (x86)\Java\jdk1.8.0_92\jre\lib\jfxswt.jar;C:\Program Files (x86)\Java\jdk1.8.0_92\jre\lib\jsse.jar;C:\Program Files (x86)\Java\jdk1.8.0_92\jre\lib\management-agent.jar;C:\Program Files (x86)\Java\jdk1.8.0_92\jre\lib\plugin.jar;C:\Program Files (x86)\Java\jdk1.8.0_92\jre\lib\resources.jar;C:\Program Files (x86)\Java\jdk1.8.0_92\jre\lib\rt.jar;F:\Programmer\Spring Projects\video-trim\target\classes;C:\Users\ADMIN.m2\repository\ws\schild\jave-all-deps\3.1.1\jave-all-deps-3.1.1.jar;C:\Users\ADMIN.m2\repository\ws\schild\jave-core\3.1.1\jave-core-3.1.1.jar;C:\Users\ADMIN.m2\repository\ws\schild\jave-nativebin-win32\3.1.1\jave-nativebin-win32-3.1.1.jar;C:\Users\ADMIN.m2\repository\ws\schild\jave-nativebin-win64\3.1.1\jave-nativebin-win64-3.1.1.jar;C:\Users\ADMIN.m2\repository\ws\schild\jave-nativebin-linux32\3.1.1\jave-nativebin-linux32-3.1.1.jar;C:\Users\ADMIN.m2\repository\ws\schild\jave-nativebin-linux64\3.1.1\jave-nativebin-linux64-3.1.1.jar;C:\Users\ADMIN.m2\repository\ws\schild\jave-nativebin-osx64\3.1.1\jave-nativebin-osx64-3.1.1.jar;C:\Users\ADMIN.m2\repository\ws\schild\jave-nativebin-linux-arm32\3.1.1\jave-nativebin-linux-arm32-3.1.1.jar;C:\Users\ADMIN.m2\repository\ws\schild\jave-nativebin-linux-arm64\3.1.1\jave-nativebin-linux-arm64-3.1.1.jar;C:\Users\ADMIN.m2\repository\org\slf4j\slf4j-api\1.7.32\slf4j-api-1.7.32.jar;C:\Users\ADMIN.m2\repository\org\slf4j\slf4j-simple\1.7.32\slf4j-simple-1.7.32.jar;C:\Users\ADMIN.m2\repository\org\bytedeco\ffmpeg\4.1.3-1.5\ffmpeg-4.1.3-1.5.jar;C:\Users\ADMIN.m2\repository\org\bytedeco\javacpp\1.5\javacpp-1.5.jar;C:\Users\ADMIN.m2\repository\net\bramp\ffmpeg\ffmpeg\0.6.2\ffmpeg-0.6.2.jar;C:\Users\ADMIN.m2\repository\com\google\guava\guava\20.0\guava-20.0.jar;C:\Users\ADMIN.m2\repository\commons-io\commons-io\2.5\commons-io-2.5.jar;C:\Users\ADMIN.m2\repository\org\apache\commons\commons-lang3\3.5\commons-lang3-3.5.jar;C:\Users\ADMIN.m2\repository\com\google\code\gson\gson\2.8.0\gson-2.8.0.jar;C:\Users\ADMIN.m2\repository\org\modelmapper\modelmapper\0.7.7\modelmapper-0.7.7.jar;C:\Users\ADMIN.m2\repository\com\github\kokorin\jaffree\jaffree\2021.05.31\jaffree-2021.05.31.jar;C:\Users\ADMIN.m2\repository\com\grack\nanojson\1.7\nanojson-1.7.jar" trim [main] WARN com.github.kokorin.jaffree.ffmpeg.FFmpeg - ProgressListener isn't set, progress won't be reported [main] INFO com.github.kokorin.jaffree.process.ProcessHandler - Command constructed: ffmpeg -loglevel level+info -t 15.000 -ss 10.000 -i "F:\VideoProcess\islam sobhi.mp4" -y -filter:v scale=160:-2 -movflags faststart -ss 10.000 "F:\VideoProcess\islam sobhi cut.mp4" [main] INFO com.github.kokorin.jaffree.process.ProcessHandler - Starting process: ffmpeg Exception in thread "main" com.github.kokorin.jaffree.JaffreeException: Failed to start process. at com.github.kokorin.jaffree.process.ProcessHandler.execute(ProcessHandler.java:148) at com.github.kokorin.jaffree.ffmpeg.FFmpeg.execute(FFmpeg.java:400) at trim.main(trim.java:36) Caused by: java.io.IOException: Cannot run program "ffmpeg": CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at com.github.kokorin.jaffree.process.ProcessHandler.execute(ProcessHandler.java:141) ... 2 more Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessImpl.create(Native Method) at java.lang.ProcessImpl.(ProcessImpl.java:386) at java.lang.ProcessImpl.start(ProcessImpl.java:137) at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) ... 3 more

Process finished with exit code 1

kokorin commented 3 years ago

Caused by: java.io.IOException: Cannot run program "ffmpeg": CreateProcess error=2, The system cannot find the file specified

You have no ffmpeg in PATH env.

ahmedrayf commented 3 years ago

Is there's another way or library to trim or cut videos or audios in my java application without installing ffmpeg

kokorin commented 3 years ago

You can find pure java media solutions. But they don't support all functionality and/or abandoned. There a lot of site with pre-build ffmpeg for all platforms. Closing as not related to Jaffree.

ahmedrayf commented 3 years ago

for Jaffree i installed ffmpeg and still getting same error

kokorin commented 3 years ago

As I said you have no ffmpeg in PATH env. Try to run ffmpeg from console from the same Work directory.

ahmedrayf commented 3 years ago

C:\Users\ADMIN>ffmpeg ffmpeg version 2021-08-01-git-1f58503013-full_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers built with gcc 10.3.0 (Rev5, 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-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libglslang --enable-vulkan --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 57. 3.100 / 57. 3.100 libavcodec 59. 3.102 / 59. 3.102 libavformat 59. 4.101 / 59. 4.101 libavdevice 59. 0.100 / 59. 0.100 libavfilter 8. 1.103 / 8. 1.103 libswscale 6. 0.100 / 6. 0.100 libswresample 4. 0.100 / 4. 0.100 libpostproc 56. 0.100 / 56. 0.100 Hyper fast Audio and Video encoder usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'

kokorin commented 3 years ago

And I'm still 100% sure that ffmpeg is absent in PATH. If you really installed it and added to PATH, close all consoles and all IDEAs instances and launch again. This is not a problem in Jaffree.