how can I using code in Android ffmpeg library
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
My Code is:
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();
}
}
This code receive and crop the video file
And doing a good job
Now My Question:
How can this code:
String cmd = new String("-y -i {filepath}{filenameRaw}.mp4 -vf crop={width}:{height}:0:0 -acodec copy -threads 5 {filepath}{filenameCropped}.mp4");
Replaced with:
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
I tried the following methods:
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");
This code did not answer and did not really know who should be semicolons or not
And no semicolons:
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");
And I tried a lot of methods, none of which did not work.
EDIT
Code @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");
Error:
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
command-line ffmpeg android
add a comment |
My Code is:
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();
}
}
This code receive and crop the video file
And doing a good job
Now My Question:
How can this code:
String cmd = new String("-y -i {filepath}{filenameRaw}.mp4 -vf crop={width}:{height}:0:0 -acodec copy -threads 5 {filepath}{filenameCropped}.mp4");
Replaced with:
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
I tried the following methods:
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");
This code did not answer and did not really know who should be semicolons or not
And no semicolons:
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");
And I tried a lot of methods, none of which did not work.
EDIT
Code @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");
Error:
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
command-line ffmpeg android
1
You are asking an off-topic question. Please read On-Topic, How do I ask a good question? and What types of questions should I avoid asking?.
– DavidPostill♦
Jun 14 '16 at 15:24
That error output doesn't look complete.
– Ouroborus
Jun 14 '16 at 22:13
This is the whole error
– Omid Naji
Jun 14 '16 at 22:46
Is not solution?
– Omid Naji
Jun 15 '16 at 20:49
@OmidNaji You can see the data coming after "Input #0", "Input #1", and "Input #2", but not after "Input #3". This is why I say it's not complete. Also, does your version offfmpeg
supporthstack
andvstack
? Mine from 2014 didn't support those.
– Ouroborus
Jun 17 '16 at 8:15
add a comment |
My Code is:
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();
}
}
This code receive and crop the video file
And doing a good job
Now My Question:
How can this code:
String cmd = new String("-y -i {filepath}{filenameRaw}.mp4 -vf crop={width}:{height}:0:0 -acodec copy -threads 5 {filepath}{filenameCropped}.mp4");
Replaced with:
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
I tried the following methods:
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");
This code did not answer and did not really know who should be semicolons or not
And no semicolons:
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");
And I tried a lot of methods, none of which did not work.
EDIT
Code @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");
Error:
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
command-line ffmpeg android
My Code is:
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();
}
}
This code receive and crop the video file
And doing a good job
Now My Question:
How can this code:
String cmd = new String("-y -i {filepath}{filenameRaw}.mp4 -vf crop={width}:{height}:0:0 -acodec copy -threads 5 {filepath}{filenameCropped}.mp4");
Replaced with:
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
I tried the following methods:
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");
This code did not answer and did not really know who should be semicolons or not
And no semicolons:
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");
And I tried a lot of methods, none of which did not work.
EDIT
Code @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");
Error:
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
command-line ffmpeg android
command-line ffmpeg android
edited Jun 14 '16 at 20:56
Omid Naji
asked Jun 14 '16 at 15:11
Omid NajiOmid Naji
36
36
1
You are asking an off-topic question. Please read On-Topic, How do I ask a good question? and What types of questions should I avoid asking?.
– DavidPostill♦
Jun 14 '16 at 15:24
That error output doesn't look complete.
– Ouroborus
Jun 14 '16 at 22:13
This is the whole error
– Omid Naji
Jun 14 '16 at 22:46
Is not solution?
– Omid Naji
Jun 15 '16 at 20:49
@OmidNaji You can see the data coming after "Input #0", "Input #1", and "Input #2", but not after "Input #3". This is why I say it's not complete. Also, does your version offfmpeg
supporthstack
andvstack
? Mine from 2014 didn't support those.
– Ouroborus
Jun 17 '16 at 8:15
add a comment |
1
You are asking an off-topic question. Please read On-Topic, How do I ask a good question? and What types of questions should I avoid asking?.
– DavidPostill♦
Jun 14 '16 at 15:24
That error output doesn't look complete.
– Ouroborus
Jun 14 '16 at 22:13
This is the whole error
– Omid Naji
Jun 14 '16 at 22:46
Is not solution?
– Omid Naji
Jun 15 '16 at 20:49
@OmidNaji You can see the data coming after "Input #0", "Input #1", and "Input #2", but not after "Input #3". This is why I say it's not complete. Also, does your version offfmpeg
supporthstack
andvstack
? Mine from 2014 didn't support those.
– Ouroborus
Jun 17 '16 at 8:15
1
1
You are asking an off-topic question. Please read On-Topic, How do I ask a good question? and What types of questions should I avoid asking?.
– DavidPostill♦
Jun 14 '16 at 15:24
You are asking an off-topic question. Please read On-Topic, How do I ask a good question? and What types of questions should I avoid asking?.
– DavidPostill♦
Jun 14 '16 at 15:24
That error output doesn't look complete.
– Ouroborus
Jun 14 '16 at 22:13
That error output doesn't look complete.
– Ouroborus
Jun 14 '16 at 22:13
This is the whole error
– Omid Naji
Jun 14 '16 at 22:46
This is the whole error
– Omid Naji
Jun 14 '16 at 22:46
Is not solution?
– Omid Naji
Jun 15 '16 at 20:49
Is not solution?
– Omid Naji
Jun 15 '16 at 20:49
@OmidNaji You can see the data coming after "Input #0", "Input #1", and "Input #2", but not after "Input #3". This is why I say it's not complete. Also, does your version of
ffmpeg
support hstack
and vstack
? Mine from 2014 didn't support those.– Ouroborus
Jun 17 '16 at 8:15
@OmidNaji You can see the data coming after "Input #0", "Input #1", and "Input #2", but not after "Input #3". This is why I say it's not complete. Also, does your version of
ffmpeg
support hstack
and vstack
? Mine from 2014 didn't support those.– Ouroborus
Jun 17 '16 at 8:15
add a comment |
2 Answers
2
active
oldest
votes
In your code, you didn't quote the complex filter even though it is quoted in the raw command. It should be something like:
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");
Note the escaped quotes.
tnx for your answer. I've tried whit you cod, But did not respond. The other solution do you have?
– Omid Naji
Jun 14 '16 at 20:46
add a comment |
Convert your code as following if you want to run a command in android app:
Command line:
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
Android:
String command = {"-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"}
Good luck..!
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1089184%2fhow-can-i-using-code-in-android-ffmpeg-library%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
In your code, you didn't quote the complex filter even though it is quoted in the raw command. It should be something like:
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");
Note the escaped quotes.
tnx for your answer. I've tried whit you cod, But did not respond. The other solution do you have?
– Omid Naji
Jun 14 '16 at 20:46
add a comment |
In your code, you didn't quote the complex filter even though it is quoted in the raw command. It should be something like:
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");
Note the escaped quotes.
tnx for your answer. I've tried whit you cod, But did not respond. The other solution do you have?
– Omid Naji
Jun 14 '16 at 20:46
add a comment |
In your code, you didn't quote the complex filter even though it is quoted in the raw command. It should be something like:
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");
Note the escaped quotes.
In your code, you didn't quote the complex filter even though it is quoted in the raw command. It should be something like:
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");
Note the escaped quotes.
answered Jun 14 '16 at 15:45
OuroborusOuroborus
2,47221024
2,47221024
tnx for your answer. I've tried whit you cod, But did not respond. The other solution do you have?
– Omid Naji
Jun 14 '16 at 20:46
add a comment |
tnx for your answer. I've tried whit you cod, But did not respond. The other solution do you have?
– Omid Naji
Jun 14 '16 at 20:46
tnx for your answer. I've tried whit you cod, But did not respond. The other solution do you have?
– Omid Naji
Jun 14 '16 at 20:46
tnx for your answer. I've tried whit you cod, But did not respond. The other solution do you have?
– Omid Naji
Jun 14 '16 at 20:46
add a comment |
Convert your code as following if you want to run a command in android app:
Command line:
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
Android:
String command = {"-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"}
Good luck..!
add a comment |
Convert your code as following if you want to run a command in android app:
Command line:
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
Android:
String command = {"-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"}
Good luck..!
add a comment |
Convert your code as following if you want to run a command in android app:
Command line:
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
Android:
String command = {"-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"}
Good luck..!
Convert your code as following if you want to run a command in android app:
Command line:
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
Android:
String command = {"-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"}
Good luck..!
answered Mar 5 at 6:25
Saiful Islam SajibSaiful Islam Sajib
11
11
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1089184%2fhow-can-i-using-code-in-android-ffmpeg-library%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You are asking an off-topic question. Please read On-Topic, How do I ask a good question? and What types of questions should I avoid asking?.
– DavidPostill♦
Jun 14 '16 at 15:24
That error output doesn't look complete.
– Ouroborus
Jun 14 '16 at 22:13
This is the whole error
– Omid Naji
Jun 14 '16 at 22:46
Is not solution?
– Omid Naji
Jun 15 '16 at 20:49
@OmidNaji You can see the data coming after "Input #0", "Input #1", and "Input #2", but not after "Input #3". This is why I say it's not complete. Also, does your version of
ffmpeg
supporthstack
andvstack
? Mine from 2014 didn't support those.– Ouroborus
Jun 17 '16 at 8:15