Meu código é:
private void startTransformVideo() {
String cmd = new String("-y -i {filepath}{filenameRaw}.mp4 -vf crop={width}:{height}:0:0 -acodec copy -threads 5 {filepath}{filenameCropped}.mp4");
int relWidth = ActivityCamera.videoSize.height;
int relHeight = relWidth;
cmd = cmd.replace("{width}", String.valueOf(relHeight));
cmd = cmd.replace("{height}", String.valueOf(relWidth));
cmd = cmd.replace("{filepath}", filePath); //sdcard/
cmd = cmd.replace("{filenameRaw1}", fileNameNormal); //fileNameExample
cmd = cmd.replace("{filenameCropped}", fileNameCropped); //fileName after Crop
executeFFmpegCmd(cmd);
mTransformStatus = 1;
}
private void executeFFmpegCmd(String cmd) {
try {
ffmpeg.execute(cmd, new ExecuteBinaryResponseHandler() {
@Override
public void onStart() {
System.out.println("onStart");
}
@Override
public void onProgress(String message) {
System.out.println("onProgress : " + message);
}
@Override
public void onFailure(String message) {
System.out.println("onFailure : " + message);
}
@Override
public void onSuccess(String message) {
System.out.println("onSuccess : " + message);
}
@Override
public void onFinish() {
System.out.println("onFinish");
}
});
} catch (FFmpegCommandAlreadyRunningException e) {
e.printStackTrace();
}
}
Este código recebe e recorta o arquivo de vídeo
E fazendo um bom trabalho
Agora minha pergunta:
Como pode este código:
String cmd = new String("-y -i {filepath}{filenameRaw}.mp4 -vf crop={width}:{height}:0:0 -acodec copy -threads 5 {filepath}{filenameCropped}.mp4");
Substituído por:
ffmpeg -i input0 -i input1 -i input2 -i input3 -filter_complex \
"[0:v][1:v]hstack[top]; \
[2:v][3:v]hstack[bottom]; \
[top][bottom]vstack" \
output
Eu tentei os seguintes métodos:
String cmd = new String("-i {filepath}{filenameRaw}.mp4 -i {filepath}{filenameRaw}.mp4 -i {filepath}{filenameRaw}.mp4 -i {filepath}{filenameRaw}.mp4 -filter_complex [0:v][1:v]hstack[top]; [2:v][3:v]hstack[bottom]; [top][bottom]vstack {filenameCropped}.mp4");
Este código não respondeu e realmente não sabia quem deveria ser semicolons ou não
E sem ponto e vírgula:
String cmd = new String("-i {filepath}{filenameRaw}.mp4 -i {filepath}{filenameRaw}.mp4 -i {filepath}{filenameRaw}.mp4 -i {filepath}{filenameRaw}.mp4 -filter_complex [0:v][1:v]hstack[top] [2:v][3:v]hstack[bottom] [top][bottom]vstack {filenameCropped}.mp4");
E eu tentei vários métodos, nenhum deles não funcionou.
EDITAR
Código @Ouroborus:
String cmd = new String("-i {filepath}{filenameRaw}.mp4 -i {filepath}{filenameRaw}.mp4 -i {filepath}{filenameRaw}.mp4 -i {filepath}{filenameRaw}.mp4 -filter_complex \"[0:v][1:v]hstack[top]; [2:v][3:v]hstack[bottom]; [top][bottom]vstack\" {filenameCropped}.mp4");
Erro:
On FailureWARNING: linker: /data/data/com.parksangha.videorecorder/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
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/sdcard/testffmpeg/1465937355161.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2016-06-14 20:49:17
Duration: 00:00:00.96, start: 0.000000, bitrate: 2710 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 2706 kb/s, 30.02 fps, 30 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 90
creation_time : 2016-06-14 20:49:17
handler_name : VideoHandle
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 150 kb/s (default)
Metadata:
creation_time : 2016-06-14 20:49:17
handler_name : SoundHandle
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/sdcard/testffmpeg/1465937359014.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2016-06-14 20:49:21
Duration: 00:00:01.11, start: 0.000000, bitrate: 2463 kb/s
Stream #1:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 2615 kb/s, 29.83 fps, 30 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 90
creation_time : 2016-06-14 20:49:21
handler_name : VideoHandle
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #1:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 159 kb/s (default)
Metadata:
creation_time : 2016-06-14 20:49:21
handler_name : SoundHandle
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from '/sdcard/testffmpeg/1465937355161.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2016-06-14 20:49:17
Duration: 00:00:00.96, start: 0.000000, bitrate: 2710 kb/s
Stream #2:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 2706 kb/s, 30.02 fps, 30 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 90
creation_time : 2016-06-14 20:49:17
handler_name : VideoHandle
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #2:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 150 kb/s (default)
Metadata:
creation_time : 2016-06-14 20:49:17
handler_name : SoundHandle
Input #3, mov,mp4,m4a,3gp,3g2,mj2, fro