I am using https://github.com/WritingMinds/ffmpeg-android-java for cropping a video using this command :
execFFmpegCommand(" -i " + in + " -filter:v " + "crop=" + 240 + ":" + 120 + ":" + 100 + ":" + 100 + " -c:a copy " + out);
where "in" is inputfile and "out" is outputfile.
I went through a lot of same questions and couldn't find required solution for this. I also tried the following command which i found going through the search:
execFFmpegCommand(" -i " + in + " -filter:v " + "crop=" + 240 + ":" + 120 + ":" + 100 + ":" + 100 + " -c:a copy " + out);
The main error that I'm getting here is : Output file #0 does not contain any stream
private void execFFmpegCommand(final String command) {
try {
ffmpeg.execute(new String[]{command}, new ExecuteBinaryResponseHandler() {
@Override
public void onFailure(String s) {
Log.d(TAG, "FAILED with output : " + s);
progressDialog.dismiss();
}
@Override
public void onSuccess(String s) {
Log.d(TAG, "SUCCESS with output : " + s);
}
@Override
public void onProgress(String s) {
Log.d(TAG, "Started command : ffmpeg " + command);
Log.d(TAG, "progress : " + s);
}
@Override
public void onStart() {
Log.d(TAG, "Started command : ffmpeg " + command);
progressDialog.show();
}
@Override
public void onFinish() {
Log.d(TAG, "Finished command : ffmpeg " + command);
progressDialog.dismiss();
}
});
} catch (FFmpegCommandAlreadyRunningException e) {
// do nothing for now
}
}
The LogCat is :
D/ffmpeg: Started command : ffmpeg -i /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980754658.mp4 -vf crop=240:120:100:100 -c:a copy /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980763106_vid.mp4
08-12 11:16:03.209 17283-17866/com.myapp D/FFmpeg: Running publishing updates method
08-12 11:16:03.231 17283-17283/com.myapp W/MediaRecorder: mediarecorder went away with unhandled events
08-12 11:16:03.232 17283-17283/com.myapp W/MediaRecorder: mediarecorder went away with unhandled events
08-12 11:16:03.355 17283-17283/com.myapp D/ffmpeg: Started command : ffmpeg -i /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980754658.mp4 -vf crop=240:120:100:100 -c:a copy /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980763106_vid.mp4
08-12 11:16:03.355 17283-17283/com.myapp D/ffmpeg: progress : ffmpeg version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
08-12 11:16:03.355 17283-17283/com.myapp D/ffmpeg: Started command : ffmpeg -i /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980754658.mp4 -vf crop=240:120:100:100 -c:a copy /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980763106_vid.mp4
08-12 11:16:03.355 17283-17283/com.myapp D/ffmpeg: progress : built with gcc 4.8 (GCC)
08-12 11:16:03.355 17283-17283/com.myapp D/ffmpeg: Started command : ffmpeg -i /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980754658.mp4 -vf crop=240:120:100:100 -c:a copy /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980763106_vid.mp4
08-12 11:16:03.355 17283-17283/com.myapp D/ffmpeg: progress : 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=
08-12 11:16:03.355 17283-17283/com.myapp D/ffmpeg: Started command : ffmpeg -i /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980754658.mp4 -vf crop=240:120:100:100 -c:a copy /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980763106_vid.mp4
08-12 11:16:03.356 17283-17283/com.myapp D/ffmpeg: progress : libavutil 55. 17.103 / 55. 17.103
08-12 11:16:03.356 17283-17283/com.myapp D/ffmpeg: Started command : ffmpeg -i /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980754658.mp4 -vf crop=240:120:100:100 -c:a copy /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980763106_vid.mp4
08-12 11:16:03.356 17283-17283/com.myapp D/ffmpeg: progress : libavcodec 57. 24.102 / 57. 24.102
08-12 11:16:03.356 17283-17283/com.myapp D/ffmpeg: Started command : ffmpeg -i /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980754658.mp4 -vf crop=240:120:100:100 -c:a copy /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980763106_vid.mp4
08-12 11:16:03.356 17283-17283/com.myapp D/ffmpeg: progress : libavformat 57. 25.100 / 57. 25.100
08-12 11:16:03.356 17283-17283/com.myapp D/ffmpeg: Started command : ffmpeg -i /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980754658.mp4 -vf crop=240:120:100:100 -c:a copy /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980763106_vid.mp4
08-12 11:16:03.356 17283-17283/com.myapp D/ffmpeg: progress : libavdevice 57. 0.101 / 57. 0.101
08-12 11:16:03.356 17283-17283/com.myapp D/ffmpeg: Started command : ffmpeg -i /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980754658.mp4 -vf crop=240:120:100:100 -c:a copy /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980763106_vid.mp4
08-12 11:16:03.356 17283-17283/com.myapp D/ffmpeg: progress : libavfilter 6. 31.100 / 6. 31.100
08-12 11:16:03.356 17283-17283/com.myapp D/ffmpeg: Started command : ffmpeg -i /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980754658.mp4 -vf crop=240:120:100:100 -c:a copy /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980763106_vid.mp4
08-12 11:16:03.356 17283-17283/com.myapp D/ffmpeg: progress : libswscale 4. 0.100 / 4. 0.100
08-12 11:16:03.356 17283-17283/com.myapp D/ffmpeg: Started command : ffmpeg -i /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980754658.mp4 -vf crop=240:120:100:100 -c:a copy /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980763106_vid.mp4
08-12 11:16:03.356 17283-17283/com.myapp D/ffmpeg: progress : libswresample 2. 0.101 / 2. 0.101
08-12 11:16:03.356 17283-17283/com.myapp D/ffmpeg: Started command : ffmpeg -i /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980754658.mp4 -vf crop=240:120:100:100 -c:a copy /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980763106_vid.mp4
08-12 11:16:03.356 17283-17283/com.myapp D/ffmpeg: progress : libpostproc 54. 0.100 / 54. 0.100
08-12 11:16:03.356 17283-17283/com.myapp D/ffmpeg: Started command : ffmpeg -i /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980754658.mp4 -vf crop=240:120:100:100 -c:a copy /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980763106_vid.mp4
08-12 11:16:03.356 17283-17283/com.myapp D/ffmpeg: progress : Output #0, mp4, to ' -i /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980754658.mp4 -vf crop=240:120:100:100 -c:a copy /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980763106_vid.mp4':
08-12 11:16:03.356 17283-17283/com.myapp D/ffmpeg: Started command : ffmpeg -i /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980754658.mp4 -vf crop=240:120:100:100 -c:a copy /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980763106_vid.mp4
08-12 11:16:03.356 17283-17283/com.myapp D/ffmpeg: progress : Output file #0 does not contain any stream
08-12 11:16:03.357 17283-17283/com.myapp D/ffmpeg: FAILED with output : 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
Output #0, mp4, to ' -i /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980754658.mp4 -vf crop=240:120:100:100 -c:a copy /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980763106_vid.mp4':
Output file #0 does not contain any stream
08-12 11:16:03.370 17283-17283/com.myapp D/ffmpeg: Finished command : ffmpeg -i /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980754658.mp4 -vf crop=240:120:100:100 -c:a copy /storage/emulated/0/Android/data/com.myapp/Files/Video/myapp1470980763106_vid.mp4