FFmpeg file not found exception

2019-08-21 12:10发布

问题:

I am getting following exception on video trimming.

video path : /storage/emulated/0/Pictures/Instagram/Fast & Furious 7 - Get Low Extended Version Video.mp4

file name : Fast & Furious 7 - Get Low Extended Version Video.mp4

and ffmpeg searching for only Fast in/storage/emulated/0/Pictures/Instagram/Fast: No such file or directory

I have found the issue ,it is causing due to the file name having spaces in between them you can check in above mentioned path and in exception.

after changing file name its working but changing name of every file from device its not the right way so how can I solve this exception

FAILED with output : WARNING: linker: /data/user/0/com.example.SeekBarActivity/files/ffmpeg 
has text relocations. This is wasting memory and prevents security hardening.
Please fix. ffmpeg version n2.4.2 Copyright (c) 2000-2014 the FFmpeg developers

built on Oct  7 2014 15:08:46 with gcc 4.8 (GCC)
configuration: --target-os=linux --cross-prefix=/home/sb/Source-Code/ffmpeg-
android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --
cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/sb/Source-
Code/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 
--enable-libass --enable-libfreetype --enable-libfribidi --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/sb/Source-Code/ffmpeg-android/ffmpeg-pkg-config --
prefix=/home/sb/Source-Code/ffmpeg-android/build/armeabi-v7a-neon --extra-
cflags='-I/home/sb/Source-Code/ffmpeg-android/toolchain-android/include -
U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-
all -mfpu=neon' --extra-ldflags='-L/home/sb/Source-Code/ffmpeg-
 android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-
 lpng -lexpat -lm' --extra-cxxflags=
  libavutil      54.  7.100 / 54.  7.100
  libavcodec     56.  1.100 / 56.  1.100
  libavformat    56.  4.101 / 56.  4.101
  libavdevice    56.  0.100 / 56.  0.100
  libavfilter     5.  1.100 /  5.  1.100
  libswscale      3.  0.100 /  3.  0.100
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  0.100 / 53.  0.100
  /storage/emulated/0/Pictures/Instagram/Fast: No such file or directory

回答1:

Try to replace

execFFmpegBinary("-i " + path + " -ss " + startMs / 1000 + 
       " -to " + endMs / 1000 + " -c copy " + destPath);

with

execFFmpegBinary(new String[] {"-i", path, "-ss", "" + startMs / 1000,           
       "-to", "" + endMs / 1000, "-c", "copy", destPath});

The fix to ffmpeg-android-java dates back to 2015.



回答2:

Try to escape the spaces with \

execFFmpegBinary("-i '/storage/emulated/0/Pictures/Instagram/Fast\ &\ Furious\ 7\ -\ Get\ Low\ Extended\ Version\ Video.mp4'"  + "-ss " + startMs / 1000 +
       " -to " + endMs / 1000 + " -c copy " + destPath);


回答3:

Replying late to this question, but I thought I would add it anyway.. This is how I execute commands:

String[] s = {"-i" ,sourcePath,"-crf","18","-c:v","libx264","-preset","ultrafast",directoryToStore+"/"+outputName};
s.execFFmpegBinary();

I've tested using files with name spaces and it works fine.