Mobotix Cameras: getting the stream

I’ve grabbed some times ago two Mobotix cameras.. I must say first that I was impressed by they quality (nice look, high resolutions, good framerate and nevertheless, GNU/Linux based).

As I put them to monitor some outdoor part of my house, I’ve wanted to record everything that would happen, but hey, first question, how to record ?

Indeed, they don’t support MPEG4 streaming. In fact, they are using some half-proprietary MxPEG format, that seems to be on its way to become a good choice when it comes to camera streaming. I’ve searched out the internet to find the SDK of the camera that provide also the little mxgconv binary, allowing you to convert MxPEG to JPEG frames. Well.

Here is then the little script I used to record in MPEG4 everything coming from the cameras on hourly-basis.

#!/bin/bash
CAM=camera.hostname
USERNAME=admin
PASSWORD=default
MXG=/usr/bin/mxgconv_linux
PREFIX="${CAM}"
OUTDIR="/data/camera/archives"
OUT=
VIDTIME=3610
old=0;
seq=0;
while (:); do
  DAY=`date "+%d"`
  MONTH=`date "+%m"`
  YEAR=`date "+%Y"`
  HOUR=`date "+%H"`
  if [ $HOUR -ne $old -a $seq -ne 0 ]; then
    seq=0;
  fi
  DIR="${OUTDIR}/${YEAR}/${MONTH}/${DAY}";
  mkdir -p $DIR
  OUT="${DIR}/${PREFIX}-${HOUR}.${seq}.avi"
  curl -m ${VIDTIME} -N -s --basic --user ${USERNAME}:${PASSWORD} \
    "http://${CAM}/control/faststream.jpg?stream=MxPEG&fps=0&error=picture&noaudio&quality=100"| ${MXG} \
    | ffmpeg -f mjpeg -r 1 -i - ${OUT} -vcodec mpeg4 -mbd rd -flags \
    +4mv+aic -trellis 2 -cmp 2 -subcmp 2 -g 300 -pass 1/2
  $((seq++))
  old=${HOUR}
done;
This entry was posted in Uncategorized. Bookmark the permalink.

2 Responses to Mobotix Cameras: getting the stream

  1. Edi Ramos says:

    Good day. Interesting your code, but how and where to implement it?

    • Thomas says:

      I’ve cleaned a bit the mess so it should be easier to read now, lemme know if you still have troubles.. although, this code is pretty old and I don’t know if it still work out of the box.

Leave a Reply

Your email address will not be published. Required fields are marked *