我正在使用https://github.com/WritingMinds/ffmpeg-android-java使用以下命令裁剪视频:
execFFmpegCommand(" -i " + in + " -filter:v " + "crop=" + 240 + ":" + 120 + ":" + 100 + ":" + 100 + " -c:a copy " + out);
我遇到了很多相同的问题,却找不到所需的解决方案.我还尝试了以下通过搜索发现的命令:
execFFmpegCommand(" -i " + in + " -filter:v " + "crop=" + 240 + ":" + 120 + ":" + 100 + ":" + 100 + " -c:a copy " + out);
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
}
}
LogCat是:
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
解决方法:
我终于想通了
该命令应作为数组传递.
String[] cmd = {"-i", in, "-filter:v", "crop=" + 240 + ":" + 120 + ":" + 100 + ":" + 100, "-c:a", "copy", out};
execFFmpegCommand(cmd);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。