First off, in the long run I want to implement a speedometer for a MP4 file using Android. I did some research and apparently the best way to do that is through FFmpeg. I decided on using this library: https://github.com/WritingMinds/ffmpeg-android-java . It implements FFmpeg for Android. It was quite simple to include into my project. (Instructions: http://writingminds.github.io/ffmpeg-android-java/)
I use the following method. As cmd I am using a String in Quotations marks
ffmpeg.execute(cmd, new ExecuteBinaryResponseHandler() {
...
};
Now I was trying to overlay some dynamic text over an MP4 file. I thought I would start trying it with a timestamp. For a timestamp something like this is needed: ... timecode='02:36:17\;00' ...
My Problem is I am getting this error " Unable to find a suitable output format for '''. It doesn't matter if i try to use "\" (escaping) or if i try to use regular quotes. Whenever I use some kind of quotation mark I am getting an error. That makes it impossible to use an dynamic timestamp. I think.
Does anyone have an idea as to how I can fix this? Keep in mind the timecode is within a String in an Android(Java) class.
Thanks in advance for your help
EDIT:
Can someone provide me with a working command? The cmd 1-3 work, but 4 and 5 don't work (even as String[]).
String cmd1 = "-i /storage/emulated/0/dir1/dir2/TestVideo.MP4 -i /storage/emulated/0/dir1/dir2/logo.png -preset ultrafast -filter_complex overlay=10:main_h-overlay_h-10 -acodec: copy /storage/emulated/0/dir1/dir2/LogoOverlay1.mp4";// working PNG overlay
String cmd2 = "-i /storage/emulated/0/dir1/dir2/TestVideo.MP4 -i /storage/emulated/0/dir1/dir2/logo.png -preset ultrafast -filter_complex overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2 -acodec: copy /storage/emulated/0/dir1/dir2/LogoOverlay2.mp4";// working PNG overlay
String cmd3 = "-i /storage/emulated/0/dir1/dir2/TestVideo.MP4 -i /storage/emulated/0/dir1/dir2/logo.png -preset ultrafast -filter_complex [0:v][1:v]overlay=main_w-overlay_w-10:main_h-overlay_h-10[out] -map [out] -map 0:a -acodec: copy /storage/emulated/0/dir1/dir2/LogoOverlay3.mp4";// working PNG overlay
String cmd4 = "-i /storage/emulated/0/dir1/dir2/TestVideo2.MP4 -vf drawtext=fontfile=/usr/share/fonts/TTF/Vera.ttf: text=\'Stack Overflow\': fontcolor=white: fontsize=24: box=1: boxcolor=black: x=(w-text_w)/2: y=(h-text_h-line_h)/2\" -acodec: copy /storage/emulated/0/dir1/dir2/TextOverlay.mp4";
String cmd5 = "-i /storage/emulated/0/dir1/dir2/TestVideo2.MP4 -vf \'transpose=1\' /storage/emulated/0/dir1/dir2/rotated.mp4"; //rotate video
String[] cmd4arr = new String[]{"-i", "/storage/emulated/0/dir1/dir2/TestVideo.MP4", "-vf", "drawtext=fontfile=/usr/share/fonts/TTF/Vera.ttf: text='Stack Overflow': fontcolor=white: fontsize=24: box=1: boxcolor=black: x=(w-text_w)/2: y=(h-text_h-line_h)/2", "-acodec:", "copy /storage/emulated/0/dir1/dir2/TextOverlay.mp4"};
String[] cmd5arr = new String[]{"-i", "/storage/emulated/0/dir1/dir2/TestVideo2.MP4","-preset","ultrafast", "-vf", "\'transpose=1\'", "/storage/emulated/0/dir1/dir2/rotated.mp4"};
String[] cmd4ArrAlt = new String[]{"-i", "/storage/extSdCard/DCIM/Camera/Test.MP4", "-vf", "drawtext=fontfile=/usr/share/fonts/TTF/Vera.ttf:", "text=\'Stack Overflow\':", "fontcolor=white:", "fontsize=24:", "box=1:", "boxcolor=black:", "x=(w-text_w)/2:", "y=(h-text_h-line_h)/2", "-acodec:", "copy", "/storage/emulated/0/dir/TextOverlay.mp4"};
cmd4arr produces this Log:
.../MainActivity﹕ onProgress ffmpeg version n2.4.2 Copyright (c) 2000-2014 the FFmpeg developers
.../MainActivity﹕ onProgress built on Oct 7 2014 15:08:46 with gcc 4.8 (GCC)
.../MainActivity﹕ onProgress 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=
.../MainActivity﹕ onProgress libavutil 54. 7.100 / 54. 7.100
.../MainActivity﹕ onProgress libavcodec 56. 1.100 / 56. 1.100
.../MainActivity﹕ onProgress libavformat 56. 4.101 / 56. 4.101
.../MainActivity﹕ onProgress libavdevice 56. 0.100 / 56. 0.100
.../MainActivity﹕ onProgress libavfilter 5. 1.100 / 5. 1.100
.../MainActivity﹕ onProgress libswscale 3. 0.100 / 3. 0.100
.../MainActivity﹕ onProgress libswresample 1. 1.100 / 1. 1.100
.../MainActivity﹕ onProgress libpostproc 53. 0.100 / 53. 0.100
.../MainActivity﹕ onProgress Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/dir1/dir2/TestVideo2.MP4':
.../MainActivity﹕ onProgress Metadata:
.../MainActivity﹕ onProgress major_brand : isom
.../MainActivity﹕ onProgress minor_version : 512
.../MainActivity﹕ onProgress compatible_brands: isomiso2mp41
.../MainActivity﹕ onProgress creation_time : 1970-01-01 00:00:00
.../MainActivity﹕ onProgress encoder : Lavf53.24.2
.../MainActivity﹕ onProgress Duration: 00:00:06.40, start: 0.000000, bitrate: 1321 kb/s
.../MainActivity﹕ onProgress Stream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 640x368 [SAR 1:1 DAR 40:23], 932 kb/s, 25 fps, 25 tbr, 12800 tbn, 25 tbc (default)
.../MainActivity﹕ onProgress Metadata:
.../MainActivity﹕ onProgress creation_time : 1970-01-01 00:00:00
.../MainActivity﹕ onProgress handler_name : VideoHandler
.../MainActivity﹕ onProgress Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 383 kb/s (default)
.../MainActivity﹕ onProgress Metadata:
.../MainActivity﹕ onProgress creation_time : 1970-01-01 00:00:00
.../MainActivity﹕ onProgress handler_name : SoundHandler
cmd4ArrAlt produces this Log:
.
.
.
/MainA: onProgress: handler_name : SoundHandle
/MainA: onProgress: [NULL @ 0xb5ec4a00] Unable to find a suitable output format for 'text='Stack Overflow':'
/MainA: onProgress: text='Stack Overflow':: Invalid argument
cmd4arr and cmd5arr create an new MP4 file. But it has a size of 0KB. The commands seem not to process the frames at all. It always stops with this last line of the Log posted above.
Edit:
Answered question: "What how can I use a String [ ] with this Library? Information on that might fix the other issues."
Answer: I imported the project as arr before. When it is imported as a regular library you can't use a normal String anymore but it is implemented as an String[].