-3

I am trying to execute ffmpeg on android. I have successfully executed 2-3 commands also. But i am stuck at one point where i am adding text to the video.

Here is the command i am executing.

NOT WORKING : because the text argument has a space between two words.

"-i "+path+"out.mp4 -vf drawtext=fontfile="+path+"f1.ttf:text='Stack OverFlow' -y -c:v libx264 -c:a copy -movflags +faststart "+path+"output.mp4"

WORKING : just removed space.

"-i "+path+"out.mp4 -vf drawtext=fontfile="+path+"f1.ttf:text='StackOverFlow' -y -c:v libx264 -c:a copy -movflags +faststart "+path+"output.mp4"

Here path contains my external Sd card's path. out.mp4 and f1.ttf exists in my folder.

My Question is why it is not working with space.

Here is the stack trace i am getting.

FAILED with output : WARNING: linker: /data/data/com.github.hiteshsondhi88.sampleffmpeg/files/ffmpeg has text relocations. This is wasting memory and prevents security hardening. Please fix.
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/i686-linux-android- --arch=x86 --cpu=i686 --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/x86 --extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all -march=i686' --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
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/Testing/out.mp4':
Metadata:
major_brand     : isom
minor_version   : 512
compatible_brands: isomiso2avc1mp41
encoder         : Lavf57.25.100
Duration: 00:00:05.00, start: 0.000000, bitrate: 117 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 300x300 [SAR 40:33 DAR 40:33], 113 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name    : VideoHandler
[NULL @ 0xb585f000] Unable to find a suitable output format for 'text='Stack'
text='Stack: Invalid argument

Why it is saying invalid argument. It will be great if any ffmpeg expert can guide me in what i am doing wrong here.

I have refered this Question of SO : Text on video ffmpeg

Community
  • 1
  • 1
Janki Gadhiya
  • 4,492
  • 2
  • 29
  • 59
  • I am not familiar with Android, but I've noticed a trend of issues with quoting. – llogan May 24 '16 at 05:08
  • quoting issues means ?? i need to remove quote from some where?? But notice that it is working **without space**. i have updated my question. @LordNeckbeard – Janki Gadhiya May 24 '16 at 05:11
  • 1
    You have failed to state how you are invoking ffmpeg, but it would probably be best if you switched to a mechanism which lets you split up the arguments into an array yourself, rather than counting on some automated capability which may have trouble with the attempt at a quoted space. – Chris Stratton May 31 '16 at 04:23
  • thnx @ChrisStratton. I will try and let you know..!! – Janki Gadhiya May 31 '16 at 04:24
  • @jankigadhiya how you are passing command to ffmpeg ? and your ffmpeg library is executable binary or shared library ? – user1140237 Dec 28 '16 at 07:41

2 Answers2

2

SOLVED

I used text file for inserting space between characters in ffmpeg command. As the direct space was not working as i said in question.

So build a text file text.txt. The contents will be the text you want on your video.

Then build the command like this :

"-i "+path+"out.mp4 -vf drawtext=fontfile="+path+"f1.ttf:textfile="+path+"text.ttf -y -c:v libx264 -c:a copy -movflags +faststart "+path+"output.mp4"

It will get run successfully.

Janki Gadhiya
  • 4,492
  • 2
  • 29
  • 59
  • Well,i just tried same thing and it works perfectly,but i need little help if u can - I want to add space between characters just like adding space in textview characters using `setLetterSpacing()` if u know anything then please help me.. – Vivek Thummar Aug 07 '20 at 14:45
0

i did this but with a different logic a put the text in editext and then take its screen shot--> saved that btmap of edittext screen shot on sd card and then use that image as a watermark on video using this command
String[] complexCommand = {"ffmpeg", "-y", "-i", filePath, "-strict", "experimental", "-vf", "movie=" + editTextScreenShotFliePath + " [watermark]; [in][watermark] overlay=main_w-overlay_w-10:10 [out]", "-s", "640x480", "-r", "30", "-b", "15496k", "-vcodec", "mpeg4", "-ab", "48000", "-ac", "2", "-ar", "22050", mCurrentVideoFile.getAbsolutePath()};

Adeel Turk
  • 897
  • 8
  • 23
  • As i said i used a different logic for this purpose and i took text as a watermark . well it was just a suggestion so chillax – Adeel Turk May 25 '16 at 09:10