bravobit / FFmpeg-Android

FFMpeg/FFprobe compiled for Android
https://bravobit.nl/
MIT License
733 stars 172 forks source link

text on video #151

Open MohamadAldawood opened 4 years ago

MohamadAldawood commented 4 years ago

hy i am trying to write text above frame using your library put when i trying it i give this error ergv and this is the command i used it: -i black.mp4 -ss 00:00:00 -t 00:00:20 -an -vcodec libx264 -profile:v baseline -level 13 -b:v 2000k -vf "drawtext=fontcolor=white:fontsize=16:box=1:boxcolor=black@0.3:x=10:y=10:timecode='00\:00\:00\:00':text='TCR\:'" output.mp4 i search in google i find some said that the i have to enable the libfreetype ,put i dont know i find --enable-libfreetype shown when try to use any ffmpeg command is this mean that the libfreetype is exist or what?? bwlow the full image rtgrtg and this is the configuration: --target-os=linux --cross-prefix=/root/bravobit/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/root/bravobit/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libfreetype --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libopus --enable-yasm --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-linux-perf --disable-doc --disable-shared --enable-static --enable-runtime-cpudetect --enable-nonfree --enable-network --enable-avresample --enable-avformat --enable-avcodec --enable-indev=lavfi --enable-hwaccels --enable-ffmpeg --enable-zlib --enable-gpl --enable-small --pkg-config=/root/bravobit/ffmpeg-android/ffmpeg-pkg-config --prefix=/root/bravobit/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/root/bravobit/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/root/bravobit/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-cxxflags= --extra-libs='-lpng -lx264 -lm -logg' as you see the enable-libfreetype exist

rennovale commented 4 years ago

Hi, It seems to me that you are giving the wrong command. I'm using the method below to draw texts in mp4 files. Maybe will help.

Input - The directory + filename.mp4 as /path/path/file.mp4 In font, you need to give a .ttf file as /path/path/font.ttf Time_start and time_end the time in seconds x_s and y_s the position in the video. output the path of output video with text.

private String[] drawTextCommand(String input, String font, String text, int time_start, int time_end, int x_s, int y_s, String output){ return new String[]{ "-i", input, "-vf", "drawtext=fontfile="+font+":text=" + text + ":fontcolor=black:fontsize=70:x="+x_s+ ":y="+y_s+"):enable='between(t,"+time_start+","+time_end+")'", "-codec:a", "copy", output}; }