planktoscope/scripts/raspimjpeg/macros/startstopX.sh
Romain Bazile f27c9823a1 Integration of raspimjpeg
The source code of the modified version of raspimjpeg used by the PlanktoScope is hosted [here](https://github.com/PlanktonPlanet/userland/tree/master/host_applications/linux/apps/raspicam).

We moved away from picamera to improve the stability of the system. This commit should closes the elusive #51 and #54.

After a lot of tests, it was clear that even a forked version of picamera was not going to solve our problem while also improving on our capturing speed.

The modified version of RaspiMJPEG does that.
RaspiMJPEG streams the image flux to /dev/shm/mjpeg/cam.jpg . This is passively reloaded by the streaming server (still written in python).

RaspiMJPEG is controlled through a special file called a Pipe which is used to send it commands.
The list is available [here](https://github.com/PlanktonPlanet/userland/tree/master/host_applications/linux/apps/raspicam/Config.md).

The raspimjpeg binary is distributed directly in this repository, in the folder `scripts/raspimjpeg/bin/`.
2020-11-16 17:53:23 +01:00

41 lines
1.2 KiB
Bash

#!/bin/bash
# example start up script which converts any existing .h264 files into MP4
MACRODIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
BASEDIR="$( cd "$( dirname "${MACRODIR}" )" >/dev/null 2>&1 && pwd )"
mypidfile=${MACRODIR}/startstop.sh.pid
mylogfile=${BASEDIR}/scheduleLog.txt
#Check if script already running
NOW=`date +"-%Y/%m/%d %H:%M:%S-"`
if [ -f $mypidfile ]; then
echo "${NOW} Script already running..." >> ${mylogfile}
exit
fi
#Remove PID file when exiting
trap "rm -f -- '$mypidfile'" EXIT
echo $$ > "$mypidfile"
#Do conversion
if [ "$1" == "start" ]; then
cd ${MACRODIR}
cd ../media
shopt -s nullglob
for f in *.h264
do
f1=${f%.*}.mp4
NOW=`date +"-%Y/%m/%d %H:%M:%S-"`
echo "${NOW} Converting $f" >> ${mylogfile}
#set -e;MP4Box -fps 25 -add $f $f1 > /dev/null 2>&1;rm $f;
if MP4Box -fps 25 -add $f $f1; then
NOW=`date +"-%Y/%m/%d %H:%M:%S-"`
echo "${NOW} Conversion complete, removing $f" >> ${mylogfile}
rm $f
else
NOW=`date +"-%Y/%m/%d %H:%M:%S-"`
echo "${NOW} Error with $f" >> ${mylogfile}
fi
done
fi