How to add text watermark on video stream

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to add text watermark on video stream

4,470件の閲覧回数
hongdong_chu
NXP Employee
NXP Employee

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" ! ..

ラベル(3)
4 返答(返信)

2,243件の閲覧回数
zhangjay
Contributor II

Hi HongdongChu

When build the pango I got some problem, failed message below:

creating libharfbuzz-1.la

(cd .libs && rm -f libharfbuzz-1.la && ln -s ../libharfbuzz-1.la libharfbuzz-1.la)

gcc -DHAVE_CONFIG_H -I. -I../.. -I/home/jay/Projects/mx27ads/ltib-imx27ads-20070522/rootfs/usr/include/freetype2 -I/home/jay/Projects/mx27ads/ltib-imx27ads-20070522/rootfs/usr/include   -I/home/jay/Projects/mx27ads/ltib-imx27ads-20070522/rootfs/usr/include   -I .    -g -O2 -Wall -MT harfbuzz-dump.o -MD -MP -MF .deps/harfbuzz-dump.Tpo -c -o harfbuzz-dump.o harfbuzz-dump.c

mv -f .deps/harfbuzz-dump.Tpo .deps/harfbuzz-dump.Po

gcc -DHAVE_CONFIG_H -I. -I../.. -I/home/jay/Projects/mx27ads/ltib-imx27ads-20070522/rootfs/usr/include/freetype2 -I/home/jay/Projects/mx27ads/ltib-imx27ads-20070522/rootfs/usr/include   -I/home/jay/Projects/mx27ads/ltib-imx27ads-20070522/rootfs/usr/include   -I .    -g -O2 -Wall -MT harfbuzz-dump-main.o -MD -MP -MF .deps/harfbuzz-dump-main.Tpo -c -o harfbuzz-dump-main.o harfbuzz-dump-main.c

mv -f .deps/harfbuzz-dump-main.Tpo .deps/harfbuzz-dump-main.Po

/bin/bash ../../libtool --tag=CC   --mode=link gcc  -g -O2 -Wall   -o harfbuzz-dump harfbuzz-dump.o harfbuzz-dump-main.o -L/home/jay/Projects/mx27ads/ltib-imx27ads-20070522/rootfs/usr/lib -lfreetype   -L/home/jay/Projects/mx27ads/ltib-imx27ads-20070522/rootfs/usr/lib -lfontconfig   libharfbuzz-1.la

libtool: link: warning: library `/home/jay/Projects/mx27ads/ltib-imx27ads-20070522/rootfs/usr/lib/libfontconfig.la' was moved.

libtool: link: warning: library `/home/jay/Projects/mx27ads/ltib-imx27ads-20070522/rootfs/usr/lib/libfontconfig.la' was moved.

gcc -g -O2 -Wall -o harfbuzz-dump harfbuzz-dump.o harfbuzz-dump-main.o  -L/home/jay/Projects/mx27ads/ltib-imx27ads-20070522/rootfs/usr/lib ./.libs/libharfbuzz-1.a -lfreetype /home/jay/Projects/mx27ads/ltib-imx27ads-20070522/rootfs/usr/lib/libfontconfig.so /usr/lib/libfreetype.so -lz /usr/lib/libexpat.so   -Wl,--rpath -Wl,/home/jay/Projects/mx27ads/ltib-imx27ads-20070522/rootfs/usr/lib -Wl,--rpath -Wl,/home/jay/Projects/mx27ads/ltib-imx27ads-20070522/rootfs/usr/lib

/usr/lib/libfreetype.so: could not read symbols: File in wrong format

collect2: ld returned 1 exit status

make[4]: *** [harfbuzz-dump] Error 1

make[4]: Leaving directory `/home/jay/Projects/mx27ads/ltib-imx27ads-20070522/rpm/BUILD/pango-1.20.5/pango/opentype'

make[3]: *** [all-recursive] Error 1

make[3]: Leaving directory `/home/jay/Projects/mx27ads/ltib-imx27ads-20070522/rpm/BUILD/pango-1.20.5/pango'

make[2]: *** [all] Error 2

make[2]: Leaving directory `/home/jay/Projects/mx27ads/ltib-imx27ads-20070522/rpm/BUILD/pango-1.20.5/pango'

make[1]: *** [all-recursive] Error 1

make[1]: Leaving directory `/home/jay/Projects/mx27ads/ltib-imx27ads-20070522/rpm/BUILD/pango-1.20.5'

make: *** [all] Error 2

error: Bad exit status from /home/jay/Projects/mx27ads/ltib-imx27ads-20070522/tmp/rpm-tmp.22189 (%build)

RPM build errors:

    Bad exit status from /home/jay/Projects/mx27ads/ltib-imx27ads-20070522/tmp/rpm-tmp.22189 (%build)

Build time for pango: 12 seconds

Failed building pango

Can you tell me how to fix the problem?

0 件の賞賛
返信

2,243件の閲覧回数
fabiendelafonta
Contributor I

Hi,

I have a sabrelite with a linux release L3.0.35_4.0.0_130424 and i have a problem with gstreamer and textoverlay. When I launch this pipeline :

gst-launch mfw_v4lsrc capture-mode=5 fps-n=30 ! clockoverlay ! queue max-size-buffers=3 ! vpuenc codec=6 bitrate=10000000 ! matroskamux ! filesink location=/mnt/HDD/test.mkv , I have a segmentation fault after a few minute.

When I try this pipeline without plugin queue, it's work for long time but I have a jerky video.

do you have a solution ?

Thanks

Fabien.

0 件の賞賛
返信

2,243件の閲覧回数
LeonardoSandova
Specialist I

I think it would be better to place the 'queue' after the source element. Also, do you see the same SEGFAULT with textoverlay?

0 件の賞賛
返信

2,243件の閲覧回数
fabiendelafonta
Contributor I

hi,

I try many piepline, but i have always same error.

I create the topic (Segmentation fault using queue in pipeline gstreamer), the problem come from mfw_v4lsrc plugins, but i don't find a solution.

Fabien.

0 件の賞賛
返信