I'm using the FFmpeg library in Android.
I'm able to generate a .ts file which i can play later using VLC player. But now i want my app to overlay a .png image over the whole video.
The .ts file i want to overlay an image in is called "out.ts". The name might seem confusing, but it is called that way because it is the output of my camera.
This is the line i'm using:
ffmpeg -i /storage/emulated/0/out.ts -i /storage/emulated/0/mustache.png -filter_complex "overlay=10:10" /storage/emulated/0/newout.ts
This is the output i'm receiving:
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, mpegts, from '/storage/emulated/0/out.ts':
Duration: 00:00:02.79, start: 0.000000, bitrate: 1118 kb/s
Program 1
Stream #0:0[0x1e1]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p, 640x480, 32 tbr, 90k tbn, 180k tbc
Input #1, png_pipe, from '/storage/emulated/0/mustache.png':
Duration: N/A, bitrate: N/A
Stream #1:0: Video: png, ya8, 1848x580 [SAR 2835:2835 DAR 462:145], 25 tbr, 25 tbn, 25 tbc
[AVFilterGraph @ 0x2b411ec0] No such filter: '"overlay'
Error configuring filters.
Some explaination on how to tell ffmpeg where to position the .png image would be appreciated.
You can use something like this.
Here you can use
filter_complex
withmap
so that you can manipulate each input stream in thefilter_complex
and map the corresponding stream to the output file.0:v
refers to the input video and1:v
refers to the input image. Above command will position the image to the centre of the video. Overlay will position the relevant source accordingly.-map [outv]
will get the manipulated video stream and-map 0:a
will get the original audio stream from the video and map it to the output.If you need to change the image scale, then use scale against the input image in the
filter_complex
like[1:v]scale...
Hope this will help you!