Stream mjpeg from webcam to firefox with ffmpeg ffserver and drawtext

Tested with:
ffmpeg version N-80901-gfebc862 Copyright (c) 2000-2016 the FFmpeg developers built with gcc 4.9.3 (Gentoo 4.9.3 p1.5, pie-0.6.4)
configuration: –prefix=/usr –enable-nonfree –disable-doc –disable-htmlpages –disable-manpages –disable-podpages –disable-txtpages –enable-frei0r –enable-gcrypt –enable-libcaca –enable-libfontconfig –enable-libfreetype –enable-libfribidi –enable-libopencv –enable-librtmp –enable-libv4l2 –enable-libx264 –enable-libx265 –enable-debug=3 –enable-gpl

 

List webcam’s supported capture formats (add -d /dev/video0-n if more than one is connected):

v4l2-ctl --list-formats-ext

Write the config file for ffserver:

ffserver.conf:

HTTPPort 8090
HTTPBindAddress 0.0.0.0
MaxHTTPConnections 10
MaxClients 10
MaxBandwidth 10000
CustomLog -

<Feed feed1.ffm>
 File ./feed1.ffm
 FileMaxSize 5M
 ACL allow 127.0.0.1
 Launch - -f v4l2 -input_format mjpeg -video_size 800x600 -r 60 -i /dev/video0 -override_ffserver -vf "drawtext=fontfile=/usr/share/fonts/freefont/FreeSerif.ttf:text='%{localtime\:%T}':fontsize=32:fontcolor=white" -c:v mjpeg -r 1 -b:v 800k -q:v 5
</Feed>

<Stream video.mjpeg>
 Feed feed1.ffm
 NoDefaults
 Format mpjpeg
 NoAudio
 VideoSize 800x600
 Metadata title LiveCam Dresden
 Metadata author "Paul"
 Metadata copyright "copy right!"
 Metadata comment "1/2.7 CMOS OV2710 Sensor Test"
</Stream>

<Stream status.html>
 Format status
 ACL allow localhost
 ACL allow 192.168.0.0 192.168.255.255
</Stream>

<Redirect index.html>
 URL http://www.ffmpeg.org/
</Redirect>

Start ffserver with:

ffserver -f ffserver.conf

create a minimal HTML page:
play.html:

<html>
<head>
<title>Webcam</title>
</head>
<body>
<img src="http://localhost:8090/video.mjpeg" width="800" height="600" />
</body>
</html>

Open play.html in firefox or open video directly with url:

http://localhost:8090/video.mjpeg

There is also an status page of the ffserver:

http://localhost:8090/status.html