Motion - Real Time Gen Html Shell Script

RTgenhtml

Introduction

RTgenhtml generates a web page in real time.

Detailed Description

RTgenhtml is a bash script which is called by motion each time it saves a file. Motion must be configured with the following options:
target_dir /var/www
ffmpeg_cap_new on
output_normal=best
ffmpeg_filename=%d-%m/motion/%H%M%S
jpeg_filename=preview
on_picture_save /usr/local/bin/RTgenhtml
This way, motions saves jpeg's and avi's under /var/www/26-06/motion/ for the day 26th June, and runs the script. Then, a link with the jpeg pointing to the avi is appended to the index.html file (it is created if it does not exist) under /var/www/26-06.

The script:

#!/bin/bash

BASENAME=`basename $1 .jpg`
DATEDIR=/var/www/`date +%d-%m`

gen_index()
{
        cat <<header
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>Motion</title>
  <meta name="description" content="Motion">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta http-equiv="Expires" content="-1">
  <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
</head>
<body bgcolor="#000000" text="#ffffff" link="#00cfcf" vlink="#ffff66" alink="#99ffff"
<div align="center">
<center><h1><a href="/">Motion</a></h1></center>
<!-- START_OF_BODY -->
</body>
</html>
header
}

cd $DATEDIR
test -f index.html || gen_index > index.html

cp index.html index.tmp
LINK=\<A\ HREF=motion/$BASENAME.avi\>\<IMG\ border="0"\ src=motion/$BASENAME.jpg\>\</A\>
sed '/^<!-- START_OF_BODY -->/a\'"$LINK" index.tmp > index.html
rm index.tmp

Installation

Just copy the script to /usr/local/bin/RTgenhtml. Don't forget to edit /etc/motion/motion.conf

Comments and Bug Reports


I'm Trying to use this script and it creates the HTML file just fine, but the links do not work... This is what is generated for the HTML Body section What could I have done wrong.. I did have to change the directories to match mine.

-- TroyBackus - 14 Aug 2006

RelatedProjectsForm edit

ProjectSummary A bash script that generates html code in real time.
ProjectStatus Stable
ReleaseVersion
ProjectSubmitter Ramiro
Topic revision: r2 - 14 Aug 2006, TroyBackus
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Please do not email Kenneth for support questions (read why). Use the Support Requests page or join the Mailing List.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.