summaryrefslogtreecommitdiff
path: root/community/motion
diff options
context:
space:
mode:
authorroot <root@rshg054.dnsready.net>2013-08-13 01:33:19 -0700
committerroot <root@rshg054.dnsready.net>2013-08-13 01:33:19 -0700
commit7a65a910b77ad191d69881098c47f9b0c852d92e (patch)
tree9564e611af1442f8952a8cbddb3b0ad25ed71aab /community/motion
parent60da6abff6c9577a783d72865f11de7a585e912e (diff)
Tue Aug 13 01:31:08 PDT 2013
Diffstat (limited to 'community/motion')
-rw-r--r--community/motion/PKGBUILD48
-rw-r--r--community/motion/ffmpeg-0.8.patch112
-rw-r--r--community/motion/ffmpeg-compat.patch172
-rw-r--r--community/motion/linux-headers.patch35
-rw-r--r--community/motion/motion.service12
-rw-r--r--community/motion/motion.tmpfiles1
-rw-r--r--community/motion/rc.motion37
7 files changed, 417 insertions, 0 deletions
diff --git a/community/motion/PKGBUILD b/community/motion/PKGBUILD
new file mode 100644
index 000000000..b97b1b43e
--- /dev/null
+++ b/community/motion/PKGBUILD
@@ -0,0 +1,48 @@
+# $Id: PKGBUILD 94894 2013-08-01 06:55:12Z bpiotrowski $
+# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
+
+pkgname=motion
+pkgver=3.2.12
+pkgrel=10
+pkgdesc="A software motion detector which grabs images from video4linux devices and/or from webcams"
+arch=('i686' 'x86_64')
+license=('GPL')
+url="http://www.lavrsen.dk/twiki/bin/view/Motion/WebHome"
+depends=('libjpeg' 'v4l-utils' 'ffmpeg-compat')
+backup=('etc/motion/motion.conf')
+options=('!makeflags')
+source=(http://downloads.sourceforge.net/${pkgname}/${pkgname}-${pkgver}.tar.gz
+ motion.service
+ motion.tmpfiles
+ ffmpeg-0.8.patch
+ linux-headers.patch
+ ffmpeg-compat.patch)
+md5sums=('1ba0065ed50509aaffb171594c689f46'
+ 'b5b589f8f39939b7a1802cbd9dbe2e1a'
+ 'f863f8c025f7f025b2178def8418decd'
+ 'd36687710837d69fbce4608b1345fa34'
+ 'd8c3c4fdded5cfbd729710475559a21d'
+ 'e85c596292aceb425fcf17e5072e2fff')
+
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ export PKG_CONFIG_PATH=/usr/lib/ffmpeg-compat/pkgconfig:$PKG_CONFIG_PATH
+ patch -Np1 -i $srcdir/ffmpeg-0.8.patch
+ patch -Np1 -i $srcdir/linux-headers.patch
+ patch -Np1 -i $srcdir/ffmpeg-compat.patch
+ autoreconf
+ ./configure --prefix=/usr \
+ --without-pgsql \
+ --without-mysql \
+ --sysconfdir=/etc/motion \
+ --with-ffmpeg
+ make
+}
+
+package(){
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR="${pkgdir}" install
+ mv "${pkgdir}/etc/motion/motion-dist.conf" "${pkgdir}/etc/motion/motion.conf"
+ install -Dm644 "${srcdir}/motion.service" "${pkgdir}/usr/lib/systemd/system/motion.service"
+ install -Dm644 "${srcdir}/motion.tmpfiles" "${pkgdir}/usr/lib/tmpfiles.d/motion.conf"
+}
diff --git a/community/motion/ffmpeg-0.8.patch b/community/motion/ffmpeg-0.8.patch
new file mode 100644
index 000000000..5dcc6e686
--- /dev/null
+++ b/community/motion/ffmpeg-0.8.patch
@@ -0,0 +1,112 @@
+diff -aur motion-3.2.12/ffmpeg.c motion-3.2.12.new/ffmpeg.c
+--- motion-3.2.12/ffmpeg.c 2010-06-01 08:48:23.000000000 +0200
++++ motion-3.2.12.new/ffmpeg.c 2011-10-31 17:25:03.000000000 +0100
+@@ -14,7 +14,7 @@
+
+ #include "ffmpeg.h"
+ #include "motion.h"
+-
++#include <libavformat/avformat.h>
+ #if LIBAVCODEC_BUILD > 4680
+ /* FFmpeg after build 4680 doesn't have support for mpeg1 videos with
+ * non-standard framerates. Previous builds contained a broken hack
+@@ -228,10 +228,12 @@
+ mpeg1_file_protocol.url_close = file_protocol.url_close;
+
+ /* Register the append file protocol. */
+-#if LIBAVFORMAT_BUILD >= (52<<16 | 31<<8)
+- av_register_protocol(&mpeg1_file_protocol);
++#ifdef have_av_register_protocol2
++ av_register_protocol2(&mpeg1_file_protocol, sizeof(mpeg1_file_protocol));
++#elif defined have_av_register_protocol
++ av_register_protocol(&mpeg1_file_protocol);
+ #else
+- register_protocol(&mpeg1_file_protocol);
++# warning av_register_protocolXXX missing
+ #endif
+ }
+
+@@ -244,7 +246,7 @@
+ const char *ext;
+ AVOutputFormat *of = NULL;
+
+- /* Here, we use guess_format to automatically setup the codec information.
++ /* Here, we use av_guess_format to automatically setup the codec information.
+ * If we are using msmpeg4, manually set that codec here.
+ * We also dynamically add the file extension to the filename here. This was
+ * done to support both mpeg1 and mpeg4 codecs since they have different extensions.
+@@ -258,7 +260,7 @@
+ /* We use "mpeg1video" for raw mpeg1 format. Using "mpeg" would
+ * result in a muxed output file, which isn't appropriate here.
+ */
+- of = guess_format("mpeg1video", NULL, NULL);
++ of = av_guess_format("mpeg1video", NULL, NULL);
+ if (of) {
+ /* But we want the trailer to be correctly written. */
+ of->write_trailer = mpeg1_write_trailer;
+@@ -270,24 +272,24 @@
+ #endif
+ } else if (strcmp(codec, "mpeg4") == 0) {
+ ext = ".avi";
+- of = guess_format("avi", NULL, NULL);
++ of = av_guess_format("avi", NULL, NULL);
+ } else if (strcmp(codec, "msmpeg4") == 0) {
+ ext = ".avi";
+- of = guess_format("avi", NULL, NULL);
++ of = av_guess_format("avi", NULL, NULL);
+ if (of) {
+ /* Manually override the codec id. */
+ of->video_codec = CODEC_ID_MSMPEG4V2;
+ }
+ } else if (strcmp(codec, "swf") == 0) {
+ ext = ".swf";
+- of = guess_format("swf", NULL, NULL);
++ of = av_guess_format("swf", NULL, NULL);
+ } else if (strcmp(codec, "flv") == 0) {
+ ext = ".flv";
+- of = guess_format("flv", NULL, NULL);
++ of = av_guess_format("flv", NULL, NULL);
+ of->video_codec = CODEC_ID_FLV1;
+ } else if (strcmp(codec, "ffv1") == 0) {
+ ext = ".avi";
+- of = guess_format("avi", NULL, NULL);
++ of = av_guess_format("avi", NULL, NULL);
+ if (of) {
+ /* Use the FFMPEG Lossless Video codec (experimental!).
+ Requires strict_std_compliance to be <= -2 */
+@@ -295,7 +297,7 @@
+ }
+ } else if (strcmp(codec, "mov") == 0) {
+ ext = ".mov";
+- of = guess_format("mov", NULL, NULL);
++ of = av_guess_format("mov", NULL, NULL);
+ } else {
+ motion_log(LOG_ERR, 0, "ffmpeg_video_codec option value %s is not supported", codec);
+ return NULL;
+@@ -377,7 +379,7 @@
+
+ ffmpeg->c = c = AVSTREAM_CODEC_PTR(ffmpeg->video_st);
+ c->codec_id = ffmpeg->oc->oformat->video_codec;
+- c->codec_type = CODEC_TYPE_VIDEO;
++ c->codec_type = AVMEDIA_TYPE_VIDEO;
+ is_mpeg1 = c->codec_id == CODEC_ID_MPEG1VIDEO;
+
+ if (strcmp(ffmpeg_video_codec, "ffv1") == 0)
+@@ -646,7 +648,7 @@
+ if (ffmpeg->oc->oformat->flags & AVFMT_RAWPICTURE) {
+ /* raw video case. The API will change slightly in the near future for that */
+ #ifdef FFMPEG_AVWRITEFRAME_NEWAPI
+- pkt.flags |= PKT_FLAG_KEY;
++ pkt.flags |= AV_PKT_FLAG_KEY;
+ pkt.data = (uint8_t *)pic;
+ pkt.size = sizeof(AVPicture);
+ ret = av_write_frame(ffmpeg->oc, &pkt);
+@@ -667,7 +669,7 @@
+ #ifdef FFMPEG_AVWRITEFRAME_NEWAPI
+ pkt.pts = AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->pts;
+ if (AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->key_frame) {
+- pkt.flags |= PKT_FLAG_KEY;
++ pkt.flags |= AV_PKT_FLAG_KEY;
+ }
+ pkt.data = ffmpeg->video_outbuf;
+ pkt.size = out_size;
diff --git a/community/motion/ffmpeg-compat.patch b/community/motion/ffmpeg-compat.patch
new file mode 100644
index 000000000..278166e18
--- /dev/null
+++ b/community/motion/ffmpeg-compat.patch
@@ -0,0 +1,172 @@
+diff -wbBur motion-3.2.12/configure.in motion-3.2.12.q/configure.in
+--- motion-3.2.12/configure.in 2010-06-01 10:48:23.000000000 +0400
++++ motion-3.2.12.q/configure.in 2012-06-20 13:51:42.000000000 +0400
+@@ -290,163 +290,11 @@
+ fi
+
+
+-#
+-# Check for libavcodec and libavformat from ffmpeg
+-#
+-FFMPEG_DIR="yes"
+-FFMPEG_OK="no_found"
+-FFMPEG_OBJ=""
+-AC_ARG_WITH(ffmpeg,
+-[ --with-ffmpeg[=DIR] Specify the prefix for the install path for
+- libavcodec/libavformat (part of ffmpeg) be able to
+- encode mpeg movies realtime.
+- If this is not specified motion will try to find
+- the libraries in /usr and /usr/local.
+- ],
+-FFMPEG_DIR="$withval"
+-)
+-#
+-# --without-ffmpeg or with-ffmpeg=no
+-#
+-if test "${FFMPEG_DIR}" = "no"; then
+- AC_MSG_CHECKING(for ffmpeg)
+- AC_MSG_RESULT(skipping)
+-#
+-# with-ffmpeg=<dir> or nothing
+-#
+-else if test "${FFMPEG_DIR}" = "yes"; then
+- # AUTODETECT STATIC/SHARED LIB
+- AC_MSG_CHECKING(for ffmpeg autodetecting)
+-
+- if test -f /usr/lib64/libavcodec.a -o -f /usr/lib64/libavcodec.so && test -f /usr/lib64/libavformat.a -o -f /usr/lib64/libavformat.so ; then
+- AC_MSG_RESULT(found in /usr/lib64)
+- FFMPEG_OK="found"
+- FFMPEG_LIB="/usr/lib64"
+- FFMPEG_DIR="/usr"
+- elif test -f /usr/lib/libavcodec.a -o -f /usr/lib/libavcodec.so && test -f /usr/lib/libavformat.a -o -f /usr/lib/libavformat.so ; then
+- AC_MSG_RESULT(found in /usr/lib)
+- FFMPEG_OK="found"
+- FFMPEG_LIB="/usr/lib"
+- FFMPEG_DIR="/usr"
+- elif test -f /usr/local/lib/libavcodec.a -o -f /usr/local/lib/libavcodec.so && test -f /usr/local/lib/libavformat.a -o -f /usr/local/lib/libavformat.so ; then
+- AC_MSG_RESULT(found in /usr/local/lib)
+- FFMPEG_OK="found"
+- FFMPEG_LIB="/usr/local/lib"
+- FFMPEG_DIR="/usr/local"
+- else
+- AC_MSG_RESULT(not found)
+- echo ""
+- echo "**********************************************"
+- echo "* libavcodec.a or libavcodec.so or *"
+- echo "* libavformat.a or libavformat.so not found: *"
+- echo "* ALL FFMPEG FEATURES DISABLED *"
+- echo "* *"
+- echo "* Please read the Motion Guide for help: *"
+- echo "* http://motion.sourceforge.net *"
+- echo "**********************************************"
+- echo ""
+- fi
+-else
+- AC_MSG_CHECKING(for ffmpeg in -> [${FFMPEG_DIR}] <-)
+- if test -f ${FFMPEG_DIR}/lib/libavcodec.a -o -f ${FFMPEG_DIR}/lib/libavcodec.so && test -f ${FFMPEG_DIR}/lib/libavformat.a -o -f ${FFMPEG_DIR}/lib/libavformat.so ; then
+- AC_MSG_RESULT(found)
+- FFMPEG_OK="found"
+- FFMPEG_LIB="${FFMPEG_DIR}/lib"
+- elif test -f ${FFMPEG_DIR}/libavcodec.a -o -f ${FFMPEG_DIR}/libavcodec.so && test -f ${FFMPEG_DIR}/libavformat.a -o -f ${FFMPEG_DIR}/libavformat.so ; then
+- AC_MSG_RESULT(found)
+- FFMPEG_LIB="${FFMPEG_DIR}"
+- FFMPEG_OK="found"
+- else
+- AC_MSG_RESULT(not found)
+- if test "${FFMPEG_OK}" != "found"; then
+- echo ""
+- echo "**********************************************"
+- echo "* libavcodec.a or libavcodec.so or *"
+- echo "* libavformat.a or libavformat.so not found: *"
+- echo "* ALL FFMPEG FEATURES DISABLED *"
+- echo "* *"
+- echo "* Please read the Motion Guide for help: *"
+- echo "* http://motion.sourceforge.net *"
+- echo "**********************************************"
+- echo ""
+- fi
+- fi
+-fi
+-
+-#
+-# Now check for ffmpeg headers ( avformat.h ) if ffmpeg libs were found
+-#
+-
+-if test "${FFMPEG_OK}" = "found"; then
+- AC_MSG_CHECKING(for ffmpeg headers in ${FFMPEG_DIR})
+-
+- if test -f ${FFMPEG_DIR}/include/avformat.h; then
+- AC_MSG_RESULT(found ${FFMPEG_DIR}/include/avformat.h)
+- FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include"
+- elif test -f ${FFMPEG_DIR}/avformat.h; then
+- AC_MSG_RESULT(found ${FFMPEG_DIR}/avformat.h)
+- FFMPEG_CFLAGS="-I${FFMPEG_DIR}"
+- elif test -f ${FFMPEG_DIR}/include/ffmpeg/avformat.h; then
+- AC_MSG_RESULT(found ${FFMPEG_DIR}/include/ffmpeg/avformat.h)
+- FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg"
+- elif test -f ${FFMPEG_DIR}/include/libavformat/avformat.h; then
+- AC_MSG_RESULT(found ${FFMPEG_DIR}/include/libavformat/avformat.h)
+- FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include -DFFMPEG_NEW_INCLUDES"
+- elif test -f ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h; then
+- AC_MSG_RESULT(found ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h)
+- FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg -DFFMPEG_NEW_INCLUDES"
+- else
+- AC_MSG_RESULT(not found)
+- FFMPEG_OK="no_found"
+- echo "**********************************************"
+- echo "* avformat.h not found: *"
+- echo "* ALL FFMPEG FEATURES DISABLED *"
+- echo "* *"
+- echo "* Please read the Motion Guide for help: *"
+- echo "* http://motion.sourceforge.net *"
+- echo "**********************************************"
+- echo ""
+- fi
+-
+-#
+-# If ffmpeg libs and headers have been found
+-#
+-
+- if test "${FFMPEG_OK}" = "found"; then
+- TEMP_LIBS="$TEMP_LIBS -L${FFMPEG_LIB} -lavformat -lavcodec -lavutil -lm -lz"
+- TEMP_LDFLAGS="${TEMP_LDFLAGS} -L${FFMPEG_LIB}"
+- TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG ${FFMPEG_CFLAGS}"
+-
+- FFMPEG_OBJ="ffmpeg.o"
+- AC_SUBST(FFMPEG_OBJ)
+-
+- AC_MSG_CHECKING([file_protocol is defined in ffmpeg ?])
+- saved_CFLAGS=$CFLAGS
+- saved_LIBS=$LIBS
+- CFLAGS="${FFMPEG_CFLAGS}"
+- LIBS="$TEMP_LIBS"
+-
+- AC_COMPILE_IFELSE(
+- [
+- #include <avformat.h>
+- URLProtocol test_file_protocol;
+- int main(void){
+- test_file_protocol.url_read = file_protocol.url_read;
+- return 0;
+- }
+- ],
+- [AC_MSG_RESULT(yes)],
+- [
+- AC_MSG_RESULT(no)
+- TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG_NEW"
+- ]
+- )
+- CFLAGS=$saved_CFLAGS
+- LIBS=$saved_LIBS
+- fi
+-fi
+-fi
+-
++TEMP_CFLAGS+=" `pkg-config --cflags libavformat libavcodec` -DHAVE_FFMPEG -DFFMPEG_NEW_INCLUDES -DHAVE_FFMPEG_NEW"
++TEMP_LIBS+=" `pkg-config --libs libavformat libavcodec` -lavutil -Wl,-rpath /usr/lib/ffmpeg-compat"
++FFMPEG_OK=found
++FFMPEG_OBJ="ffmpeg.o"
++AC_SUBST(FFMPEG_OBJ)
+
+ #
+ # Check Mysql
diff --git a/community/motion/linux-headers.patch b/community/motion/linux-headers.patch
new file mode 100644
index 000000000..795c8aec5
--- /dev/null
+++ b/community/motion/linux-headers.patch
@@ -0,0 +1,35 @@
+diff -urN motion-3.2.12-OLD/motion.h motion-3.2.12-NEW/motion.h
+--- motion-3.2.12-OLD/motion.h 2010-05-31 23:48:23.000000000 -0700
++++ motion-3.2.12-NEW/motion.h 2011-08-30 02:11:08.000000000 -0700
+@@ -40,7 +40,7 @@
+
+ #define _LINUX_TIME_H 1
+ #if !defined(WITHOUT_V4L) && !defined(BSD)
+-#include <linux/videodev.h>
++#include <libv4l1-videodev.h>
+ #endif
+
+ #include <pthread.h>
+diff -urN motion-3.2.12-OLD/track.c motion-3.2.12-NEW/track.c
+--- motion-3.2.12-OLD/track.c 2010-05-31 23:48:23.000000000 -0700
++++ motion-3.2.12-NEW/track.c 2011-08-30 23:05:09.000000000 -0700
+@@ -11,6 +11,7 @@
+ #include "motion.h"
+
+ #ifndef WITHOUT_V4L
++#include <linux/videodev2.h>
+ #include "pwc-ioctl.h"
+ #endif
+
+diff -urN motion-3.2.12-OLD/video.h motion-3.2.12-NEW/video.h
+--- motion-3.2.12-OLD/video.h 2010-05-31 23:48:23.000000000 -0700
++++ motion-3.2.12-NEW/video.h 2011-08-30 02:11:12.000000000 -0700
+@@ -12,7 +12,7 @@
+
+ #define _LINUX_TIME_H 1
+ #ifndef WITHOUT_V4L
+-#include <linux/videodev.h>
++#include <libv4l1-videodev.h>
+ #include <sys/mman.h>
+ #include "pwc-ioctl.h"
+ #endif
diff --git a/community/motion/motion.service b/community/motion/motion.service
new file mode 100644
index 000000000..23aba29cd
--- /dev/null
+++ b/community/motion/motion.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Motion daemon
+After=local-fs.target
+
+[Service]
+ExecStart=/usr/bin/motion
+Type=forking
+#StandardOutput=null
+StandardError=null
+
+[Install]
+WantedBy=multi-user.target
diff --git a/community/motion/motion.tmpfiles b/community/motion/motion.tmpfiles
new file mode 100644
index 000000000..b558b66df
--- /dev/null
+++ b/community/motion/motion.tmpfiles
@@ -0,0 +1 @@
+D /var/run/motion 0755 root root
diff --git a/community/motion/rc.motion b/community/motion/rc.motion
new file mode 100644
index 000000000..5b4c65500
--- /dev/null
+++ b/community/motion/rc.motion
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+
+PID=`pidof -o %PPID /usr/bin/motion`
+case "$1" in
+ start)
+ stat_busy "Starting Motion"
+ mkdir -p /var/run/motion
+ [ -z "$PID" ] && /usr/bin/motion 1>/dev/null 2>&1
+ if [ $? -gt 0 ]; then
+ stat_fail
+ else
+ add_daemon motion
+ stat_done
+ fi
+ ;;
+ stop)
+ stat_busy "Stopping Motion"
+ [ ! -z "$PID" ] && kill $PID &> /dev/null
+ if [ $? -gt 0 ]; then
+ stat_fail
+ else
+ rm_daemon motion
+ stat_done
+ fi
+ ;;
+ restart)
+ $0 stop
+ sleep 3
+ $0 start
+ ;;
+ *)
+ echo "usage: $0 {start|stop|restart}"
+esac
+exit 0