Eric Chu

How to add text watermark on video stream

Discussion created by Eric Chu Employee on Jan 6, 2013
Latest reply on Sep 24, 2013 by Fabien Delafontaine

Some products, such as surveillance system, need add text watermark or time, clock info on video stream when recording by camera, pango plugin can be installed in ltib for this purpose. I tried on i.mx6q SDB board with over5642 camera, linux release is L3.0.35_12.09.01_GA.

Here are the steps:

1. Edit ltib/dist/lfs-5.1/gst-plugins-base/gst-plugins-base.spec and remove the following line:

--disable-pango

then execute below sequence to compile and install the libs:

./ltib –m prep –p freetype

./ltib –m scbuild –p freetype

./ltib –m scdeploy –p freetype

./ltib –m prep –p fontconfig

./ltib –m scbuild –p fontconfig

./ltib –m scdeploy –p fontconfig

./ltib –m prep –p pixman

./ltib –m scbuild –p pixman

./ltib –m scdeploy –p pixman

./ltib –m prep –p libpng

./ltib –m scbuild –p libpng

./ltib –m scdeploy –p libpng

./ltib –m prep –p cairo

./ltib –m scbuild –p cairo

./ltib –m scdeploy –p cairo

./ltib –m prep –p pango

./ltib –m scbuild –p pango

./ltib –m scdeploy –p pango

./ltib –m prep –p gst-plugins-base

./ltib –m scbuild –p gst-plugins-base

./ltib –m scdeploy –p gst-plugins-base

2. Run command to create config file:

./rootfs/etc/rc.d/init.d/pango start

3. Copy /usr/share/fonts of host machine to rootfs/usr/share/

4. On target board, run below command:

modprobe ov5642_camera

modprobe mxc_v4l2_capture

gst-launch mfw_v4lsrc capture-mode=4 device=/dev/video0 num-buffers=1000 ! tee name=t ! queue max-size-buffers=3 ! textoverlay text="1234567890" ! vpuenc codec=avc quant=23 ! queue ! matroskamux ! filesink location=/dev/shm/720P.mkv t. ! queue max-size-buffers=3 ! mfw_ipucsc ! 'video/x-raw-yuv, format=(fourcc)NV12, width=720, height=576' ! queue max-size-buffers=3 ! vpuenc codec=avc quant=23 ! queue ! matroskamux ! filesink location=/dev/shm/D1.mkv

 

Then text "1234567890" can be seen on recorded 720P.mkv video stream, text’s position, size, font.. can be set by specifying some parameters (please check with command “gst-inspect textoverlay”), here is an example:
gst-launch mfw_v4lsrc capture-mode=4 device=/dev/video0 num-buffers=1000 ! tee name=t ! queue max-size-buffers=3 ! textoverlay font-desc="Sans 20" text="1234567890" valign=top halign=left shaded-background=false ! vpuenc codec=avc quant=23 ! queue ! matroskamux ! filesink location=/dev/shm/720P.mkv t. ! queue max-size-buffers=3 ! mfw_ipucsc ! 'video/x-raw-yuv, format=(fourcc)NV12, width=720, height=576' ! queue max-size-buffers=3 ! vpuenc codec=avc quant=23 ! queue ! matroskamux ! filesink location=/dev/shm/D1.mkv

Time and clock info can also be added by timeoverlay and clockoverlay:
gst-launch mfw_v4lsrc capture-mode=4 ! textoverlay font-desc="Sans 20" text="1234567890" valign=top halign=left shaded-background=false ! timeoverlay halign=right valign=bottom ! clockoverlay halign=left valign=bottom time-format="%Y/%m/%d %H:%M:%S" ! ..

Outcomes