From 31364dc8419f2b56669b1c06e08eca8449456f19 Mon Sep 17 00:00:00 2001 From: Radek Hvizdos Date: Thu, 26 Jan 2017 19:06:11 +0100 Subject: [PATCH 1/7] Add initial webp image compression support. Only basic webp compression is supported (the only tunable is 0-100% compression adjustment), without EXIF metadata. Motion build scripts are configured to build in the support by default and will emit an error if the needed library is missing. Suport can be manualy disabled at configuration stage adding --without-libwebp. Documentation update will follow in a separate commit. Tested on x86-64 Linux only. --- INSTALL | 3 +- camera1-dist.conf.in | 6 ++-- camera2-dist.conf.in | 6 ++-- camera3-dist.conf.in | 6 ++-- camera4-dist.conf.in | 6 ++-- conf.c | 14 ++++---- configure.ac | 31 ++++++++++++++++ event.c | 3 ++ motion-dist.conf.in | 12 +++---- motion.1 | 10 +++--- motion.c | 2 ++ motion.h | 1 + picture.c | 86 +++++++++++++++++++++++++++++++++++++++++++- 13 files changed, 154 insertions(+), 32 deletions(-) diff --git a/INSTALL b/INSTALL index 618f5ed5..dd8ea86d 100644 --- a/INSTALL +++ b/INSTALL @@ -15,6 +15,7 @@ Build Packages: libjpeg8-dev build-essential libzip-dev + libwebp-dev The option to include FFMPEG or Libav functionality in motion is a choice of one OR the other not both. The packages and library names change frequently and vary across base operating systems. If ffmpeg or @@ -43,4 +44,4 @@ Once required packages are installed, execute: Sample custom configuration options: --prefix : Specify the install location for the motion package --with-ffmpeg=[dir] : Specify the location in which ffmpeg/libav is installed. - + --without-libwebp : Compile without libwebp image support diff --git a/camera1-dist.conf.in b/camera1-dist.conf.in index 12f24102..18446912 100644 --- a/camera1-dist.conf.in +++ b/camera1-dist.conf.in @@ -44,11 +44,11 @@ text_left CAMERA 1 # Recommended to use absolute patch. (Default: current working directory) #target_dir /tmp/motion/cam1 -# File path for motion triggered images (jpeg or ppm) relative to target_dir +# File path for motion triggered images (jpeg, ppm or webp) relative to target_dir # Default: %v-%Y%m%d%H%M%S-%q # Default value is equivalent to legacy oldlayout option # For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q -# File extension .jpg or .ppm is automatically added so do not include this +# File extension .jpg, .ppm or .webp is automatically added so do not include this # Set to 'preview' together with best-preview feature enables special naming # convention for preview shots. See motion guide for details picture_filename CAM1_%v-%Y%m%d%H%M%S-%q @@ -61,7 +61,7 @@ picture_filename CAM1_%v-%Y%m%d%H%M%S-%q # The mini-http server listens to this port for requests (default: 0 = disabled) stream_port 8081 -# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) +# Command to be executed when a picture (.ppm|.jpg|.webp) is saved (default: none) # The filename of the picture is appended as an argument for the command. #on_picture_save /usr/local/motion-extras/camparse2.pl diff --git a/camera2-dist.conf.in b/camera2-dist.conf.in index 65d54eac..e61d9b87 100644 --- a/camera2-dist.conf.in +++ b/camera2-dist.conf.in @@ -44,11 +44,11 @@ text_left CAMERA 2 # Recommended to use absolute patch. (Default: current working directory) #target_dir /tmp/motion/cam2 -# File path for motion triggered images (jpeg or ppm) relative to target_dir +# File path for motion triggered images (jpeg, ppm or webp) relative to target_dir # Default: %v-%Y%m%d%H%M%S-%q # Default value is equivalent to legacy oldlayout option # For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q -# File extension .jpg or .ppm is automatically added so do not include this +# File extension .jpg, .ppm or .webp is automatically added so do not include this # Set to 'preview' together with best-preview feature enables special naming # convention for preview shots. See motion guide for details picture_filename CAM2_%v-%Y%m%d%H%M%S-%q @@ -61,7 +61,7 @@ picture_filename CAM2_%v-%Y%m%d%H%M%S-%q # The mini-http server listens to this port for requests (default: 0 = disabled) stream_port 8082 -# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) +# Command to be executed when a picture (.ppm|.jpg|.webp) is saved (default: none) # The filename of the picture is appended as an argument for the command. #on_picture_save /usr/local/motion-extras/camparse2.pl diff --git a/camera3-dist.conf.in b/camera3-dist.conf.in index 933f038d..38a2c711 100644 --- a/camera3-dist.conf.in +++ b/camera3-dist.conf.in @@ -44,11 +44,11 @@ text_left CAMERA 3 # Recommended to use absolute patch. (Default: current working directory) #target_dir /tmp/motion/cam3 -# File path for motion triggered images (jpeg or ppm) relative to target_dir +# File path for motion triggered images (jpeg, ppm or webp) relative to target_dir # Default: %v-%Y%m%d%H%M%S-%q # Default value is equivalent to legacy oldlayout option # For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q -# File extension .jpg or .ppm is automatically added so do not include this +# File extension .jpg, .ppm or .webp is automatically added so do not include this # Set to 'preview' together with best-preview feature enables special naming # convention for preview shots. See motion guide for details picture_filename CAM3_%v-%Y%m%d%H%M%S-%q @@ -61,7 +61,7 @@ picture_filename CAM3_%v-%Y%m%d%H%M%S-%q # The mini-http server listens to this port for requests (default: 0 = disabled) stream_port 8083 -# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) +# Command to be executed when a picture (.ppm|.jpg|.webp) is saved (default: none) # The filename of the picture is appended as an argument for the command. #on_picture_save /usr/local/motion-extras/camparse2.pl diff --git a/camera4-dist.conf.in b/camera4-dist.conf.in index 8d3b13a3..daa7b5f5 100644 --- a/camera4-dist.conf.in +++ b/camera4-dist.conf.in @@ -44,11 +44,11 @@ text_left CAMERA 4 # Recommended to use absolute patch. (Default: current working directory) #target_dir /tmp/motion/cam4 -# File path for motion triggered images (jpeg or ppm) relative to target_dir +# File path for motion triggered images (jpeg, ppm or webp) relative to target_dir # Default: %v-%Y%m%d%H%M%S-%q # Default value is equivalent to legacy oldlayout option # For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q -# File extension .jpg or .ppm is automatically added so do not include this +# File extension .jpg, .ppm or .webp is automatically added so do not include this # Set to 'preview' together with best-preview feature enables special naming # convention for preview shots. See motion guide for details picture_filename CAM4_%v-%Y%m%d%H%M%S-%q @@ -61,7 +61,7 @@ picture_filename CAM4_%v-%Y%m%d%H%M%S-%q # The mini-http server listens to this port for requests (default: 0 = disabled) stream_port 8084 -# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) +# Command to be executed when a picture (.ppm|.jpg|.webp) is saved (default: none) # The filename of the picture is appended as an argument for the command. #on_picture_save /usr/local/motion-extras/camparse2.pl diff --git a/conf.c b/conf.c index b0aaa45c..9394bead 100644 --- a/conf.c +++ b/conf.c @@ -739,7 +739,7 @@ config_param config_params[] = { }, { "quality", - "# The quality (in percent) to be used by the jpeg compression (default: 75)", + "# The quality (in percent) to be used by the jpeg and webp compression (default: 75)", 0, CONF_OFFSET(quality), copy_int, @@ -758,7 +758,7 @@ config_param config_params[] = { { "picture_type", "# Type of output images\n" - "# Valid values: jpeg, ppm (default: jpeg)", + "# Valid values: jpeg, ppm or webp (default: jpeg)", 0, CONF_OFFSET(picture_type), copy_string, @@ -1010,11 +1010,11 @@ config_param config_params[] = { }, { "snapshot_filename", - "# File path for snapshots (jpeg or ppm) relative to target_dir\n" + "# File path for snapshots (jpeg, ppm or webp) relative to target_dir\n" "# Default: "DEF_SNAPPATH"\n" "# Default value is equivalent to legacy oldlayout option\n" "# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-snapshot\n" - "# File extension .jpg or .ppm is automatically added so do not include this.\n" + "# File extension .jpg, .ppm or .webp is automatically added so do not include this.\n" "# Note: A symbolic link called lastsnap.jpg created in the target_dir will always\n" "# point to the latest snapshot, unless snapshot_filename is exactly 'lastsnap'", 0, @@ -1024,11 +1024,11 @@ config_param config_params[] = { }, { "picture_filename", - "# File path for motion triggered images (jpeg or ppm) relative to target_dir\n" + "# File path for motion triggered images (jpeg, ppm or webp) relative to target_dir\n" "# Default: "DEF_IMAGEPATH"\n" "# Default value is equivalent to legacy oldlayout option\n" "# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q\n" - "# File extension .jpg or .ppm is automatically added so do not include this\n" + "# File extension .jpg, .ppm or .webp is automatically added so do not include this\n" "# Set to 'preview' together with best-preview feature enables special naming\n" "# convention for preview shots. See motion guide for details", 0, @@ -1405,7 +1405,7 @@ config_param config_params[] = { }, { "on_picture_save", - "# Command to be executed when a picture (.ppm|.jpg) is saved (default: none)\n" + "# Command to be executed when a picture (.ppm|.jpg|.webp) is saved (default: none)\n" "# To give the filename as an argument to a command append it with %f", 0, CONF_OFFSET(on_picture_save), diff --git a/configure.ac b/configure.ac index cc33cddc..6bf4fbb8 100644 --- a/configure.ac +++ b/configure.ac @@ -338,6 +338,31 @@ AC_CHECK_PROG([PKGCONFIG],[pkg-config],[yes],[no]) AM_CONDITIONAL([FOUND_PKGCONFIG], [test "x$PKGCONFIG" = xyes]) AM_COND_IF([FOUND_PKGCONFIG],,[AC_MSG_ERROR([Required package 'pkg-config' not found, please check motion_guide.html and install necessary dependencies.])]) + +# Check for the libwebp library +# +AC_ARG_WITH(libwebp, +[ --without-libwebp Compile without webp image support], +LIBWEBP="no", +LIBWEBP="yes" +) + +HAVE_LIBWEBP="" +if test "${LIBWEBP}" = "yes"; then + AC_MSG_CHECKING(for libwebp) + LIBWEBP_DEPS="libwebp" + if pkg-config $LIBWEBP_DEPS; then + AC_MSG_RESULT(found) + HAVE_LIBWEBP="yes" + TEMP_LIBS="$TEMP_LIBS -lwebp -lwebpmux" + TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_WEBP" + else + AC_MSG_RESULT(not found) + AC_MSG_ERROR([Required package 'libwebp-dev' not found. Please check motion_guide.html and install necessary dependencies or use the '--without-libwebp' configuration option.]) + fi +fi + + # Check for raspberry pi mmal interface # WITHOUT_MMAL="no" @@ -1080,6 +1105,12 @@ else echo "**********************************************" fi +if test "${HAVE_LIBWEBP}" = "yes"; then + echo "webp support: yes" +else + echo "webp support: no" +fi + if test "${FreeBSD}" != ""; then if test "${BKTR}" = "yes"; then echo "BKTR included: Yes" diff --git a/event.c b/event.c index 0ed4bb82..fcd0ff90 100644 --- a/event.c +++ b/event.c @@ -325,6 +325,9 @@ const char *imageext(struct context *cnt) if (cnt->imgs.picture_type == IMAGE_TYPE_PPM) return "ppm"; + if (cnt->imgs.picture_type == IMAGE_TYPE_WEBP) + return "webp"; + return "jpg"; } diff --git a/motion-dist.conf.in b/motion-dist.conf.in index 1efc2ca6..25885012 100644 --- a/motion-dist.conf.in +++ b/motion-dist.conf.in @@ -282,11 +282,11 @@ output_pictures on # Output pictures with only the pixels moving object (ghost images) (default: off) output_debug_pictures off -# The quality (in percent) to be used by the jpeg compression (default: 75) +# The quality (in percent) to be used by the jpeg and webp compression (default: 75) quality 75 # Type of output images -# Valid values: jpeg, ppm (default: jpeg) +# Valid values: jpeg, ppm or webp (default: jpeg) picture_type jpeg ############################################################ @@ -449,20 +449,20 @@ text_double off # Recommended to use absolute path. (Default: current working directory) #target_dir /tmp/motion -# File path for snapshots (jpeg or ppm) relative to target_dir +# File path for snapshots (jpeg, ppm or webp) relative to target_dir # Default: %v-%Y%m%d%H%M%S-snapshot # Default value is equivalent to legacy oldlayout option # For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-snapshot -# File extension .jpg or .ppm is automatically added so do not include this. +# File extension .jpg, .ppm or .webp is automatically added so do not include this. # Note: A symbolic link called lastsnap.jpg created in the target_dir will always # point to the latest snapshot, unless snapshot_filename is exactly 'lastsnap' snapshot_filename %v-%Y%m%d%H%M%S-snapshot -# File path for motion triggered images (jpeg or ppm) relative to target_dir +# File path for motion triggered images (jpeg, ppm or .webp) relative to target_dir # Default: %v-%Y%m%d%H%M%S-%q # Default value is equivalent to legacy oldlayout option # For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q -# File extension .jpg or .ppm is automatically added so do not include this +# File extension .jpg, .ppm or .webp is automatically added so do not include this # Set to 'preview' together with best-preview feature enables special naming # convention for preview shots. See motion guide for details picture_filename %v-%Y%m%d%H%M%S-%q diff --git a/motion.1 b/motion.1 index 460058cf..8011f961 100644 --- a/motion.1 +++ b/motion.1 @@ -888,7 +888,7 @@ Default: 75 Description: .fi .RS -The quality (in percent) to be used by the jpeg compression +The quality (in percent) to be used by the jpeg and webp compression .RE .RE @@ -896,7 +896,7 @@ The quality (in percent) to be used by the jpeg compression .B picture_type .RS .nf -Values: jpeg/ppm +Values: jpeg/ppm/webp Default: jpeg Description: .fi @@ -1250,7 +1250,7 @@ Description: .fi .RS The file path for snapshots relative to target_dir. -The file extension .jpg or .ppm is automatically added so do not include this. +The file extension .jpg, .ppm or .webp is automatically added so do not include this. A symbolic link called lastsnap.jpg created in the target_dir will always point to the latest snapshot, unless snapshot_filename is exactly 'lastsnap' This option accepts the conversion specifiers included at the end of this manual. @@ -1266,8 +1266,8 @@ Default: %v-%Y%m%d%H%M%S-%q Description: .fi .RS -The file path for motion triggered images (jpeg or ppm) relative to target_dir. -The file extension of .jpg or .ppm is automatically added so do not include this. +The file path for motion triggered images (jpeg, ppm or webp) relative to target_dir. +The file extension .jpg, .ppm or .webp is automatically added so do not include this. Set to 'preview' together with best-preview feature enables special naming convention for preview shots. This option accepts the conversion specifiers included at the end of this manual. diff --git a/motion.c b/motion.c index 5ea8a914..34cce837 100644 --- a/motion.c +++ b/motion.c @@ -850,6 +850,8 @@ static int motion_init(struct context *cnt) /* Set output picture type */ if (!strcmp(cnt->conf.picture_type, "ppm")) cnt->imgs.picture_type = IMAGE_TYPE_PPM; + else if (!strcmp(cnt->conf.picture_type, "webp")) + cnt->imgs.picture_type = IMAGE_TYPE_WEBP; else cnt->imgs.picture_type = IMAGE_TYPE_JPEG; diff --git a/motion.h b/motion.h index 7e96104e..b795de1d 100644 --- a/motion.h +++ b/motion.h @@ -168,6 +168,7 @@ /* OUTPUT Image types */ #define IMAGE_TYPE_JPEG 0 #define IMAGE_TYPE_PPM 1 +#define IMAGE_TYPE_WEBP 2 /* Filetype defines */ #define FTYPE_IMAGE 1 diff --git a/picture.c b/picture.c index cd20a8d3..0d5a7f0f 100644 --- a/picture.c +++ b/picture.c @@ -14,6 +14,11 @@ #include +#ifdef HAVE_WEBP +#include +#include +#endif /* HAVE_WEBP */ + #include #include @@ -541,6 +546,80 @@ static int put_jpeg_grey_memory(unsigned char *dest_image, int image_size, unsig return dest_image_size; } +#ifdef HAVE_WEBP +/** + * put_webp_yuv420p_file + * Converts an YUV420P coded image to a webp image and writes + * it to an already open file. + * + * Inputs: + * - image is the image in YUV420P format. + * - width and height are the dimensions of the image + * - quality is the webp encoding quality 0-100% + * + * Output: + * - The webp is written directly to the file given by the file pointer fp + * + * Returns nothing + */ +static void put_webp_yuv420p_file(FILE *fp, + unsigned char *image, int width, int height, + int quality) +{ + /* Create a config present and check for compatible library version */ + WebPConfig webp_config; + if (!WebPConfigPreset(&webp_config, WEBP_PRESET_DEFAULT, (float) quality)){ + MOTION_LOG(ERR, TYPE_CORE, NO_ERRNO, "libwebp version error"); + return; + } + + /* Create the input data structure and check for compatible library version */ + WebPPicture webp_image; + if (!WebPPictureInit(&webp_image)){ + MOTION_LOG(ERR, TYPE_CORE, NO_ERRNO, "libwebp version error"); + return; + } + + /* Allocate the image buffer based on image width and height */ + webp_image.width = width; + webp_image.height = height; + if (!WebPPictureAlloc(&webp_image)){ + MOTION_LOG(ERR, TYPE_CORE, NO_ERRNO, "libwebp image buffer allocation error"); + return; + } + + /* Map the input YUV420P buffer as individual Y, U and V pointers */ + webp_image.y = image; + webp_image.u = image + width * height; + webp_image.v = webp_image.u + (width * height) / 4; + + /* Setup the memory writting method */ + WebPMemoryWriter webp_writer; + WebPMemoryWriterInit(&webp_writer); + webp_image.writer = WebPMemoryWrite; + webp_image.custom_ptr = (void*) &webp_writer; + + /* Encode the YUV image as webp */ + if (!WebPEncode(&webp_config, &webp_image)) + MOTION_LOG(WRN, TYPE_CORE, NO_ERRNO, "libwebp image compression error"); + + /* Write the webp bytestream to file */ + if (fwrite(webp_writer.mem, sizeof(uint8_t), webp_writer.size, fp) != webp_writer.size) + MOTION_LOG(ERR, TYPE_CORE, NO_ERRNO, "unable to save webp image to file"); + +#if WEBP_ENCODER_ABI_VERSION > 0x0202 + /* writer.mem must be freed by calling WebPMemoryWriterClear */ + WebPMemoryWriterClear(&webp_writer); +#else + /* writer.mem must be freed by calling 'free(writer.mem)' */ + free(webp_writer.mem); +#endif /* WEBP_ENCODER_ABI_VERSION */ + + /* free the memory used by webp for image object */ + WebPPictureFree(&webp_image); +} +#endif /* HAVE_WEBP */ + /** * put_jpeg_yuv420p_file * Converts an YUV420P coded image to a jpeg image and writes @@ -918,7 +997,12 @@ void put_picture_fd(struct context *cnt, FILE *picture, unsigned char *image, in } else { switch (cnt->imgs.type) { case VIDEO_PALETTE_YUV420P: - put_jpeg_yuv420p_file(picture, image, cnt->imgs.width, cnt->imgs.height, quality, cnt, &(cnt->current_image->timestamp_tv), &(cnt->current_image->location)); + #ifdef HAVE_WEBP + if (cnt->imgs.picture_type == IMAGE_TYPE_WEBP) + put_webp_yuv420p_file(picture, image, cnt->imgs.width, cnt->imgs.height, quality); + #endif /* HAVE_WEBP */ + if (cnt->imgs.picture_type == IMAGE_TYPE_JPEG) + put_jpeg_yuv420p_file(picture, image, cnt->imgs.width, cnt->imgs.height, quality, cnt, &(cnt->current_image->timestamp_tv), &(cnt->current_image->location)); break; case VIDEO_PALETTE_GREY: put_jpeg_grey_file(picture, image, cnt->imgs.width, cnt->imgs.height, quality); From 0e4663ae7e97e4c3de878bf2f978fe90015c1bf7 Mon Sep 17 00:00:00 2001 From: Radek Hvizdos Date: Fri, 27 Jan 2017 14:30:16 +0100 Subject: [PATCH 2/7] Adding webp build fixes and documentation update #1 --- .travis.yml | 2 ++ INSTALL | 4 ++-- README.FreeBSD | 1 + README.MacOSX | 2 +- motion.spec.in | 2 +- motion_guide.html | 14 +++++++++++--- 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 79eb3aaa..e44166a7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,7 @@ matrix: - libjpeg8-dev - libv4l-dev - libzip-dev + - libwebp-dev - os: linux language: c compiler: gcc @@ -39,4 +40,5 @@ matrix: - libjpeg8-dev - libv4l-dev - libzip-dev + - libwebp-dev diff --git a/INSTALL b/INSTALL index dd8ea86d..20f42594 100644 --- a/INSTALL +++ b/INSTALL @@ -15,7 +15,7 @@ Build Packages: libjpeg8-dev build-essential libzip-dev - libwebp-dev + libwebp-dev The option to include FFMPEG or Libav functionality in motion is a choice of one OR the other not both. The packages and library names change frequently and vary across base operating systems. If ffmpeg or @@ -44,4 +44,4 @@ Once required packages are installed, execute: Sample custom configuration options: --prefix : Specify the install location for the motion package --with-ffmpeg=[dir] : Specify the location in which ffmpeg/libav is installed. - --without-libwebp : Compile without libwebp image support + --without-libwebp : Compile without libwebp image support diff --git a/README.FreeBSD b/README.FreeBSD index 7b19b983..eef5f81c 100644 --- a/README.FreeBSD +++ b/README.FreeBSD @@ -9,6 +9,7 @@ To build Motion on FreeBSD, you need the following packages: * gmake * libjpeg-turbo * pkgconf +* libwebp For database backend support, also install one of the following: * mysql57-client diff --git a/README.MacOSX b/README.MacOSX index 9d05ae4d..8204f4fe 100644 --- a/README.MacOSX +++ b/README.MacOSX @@ -9,7 +9,7 @@ http://brew.sh Then: -brew install ffmpeg cmake pkg-config libjpeg +brew install ffmpeg cmake pkg-config libjpeg libwebp cmake . make diff --git a/motion.spec.in b/motion.spec.in index 41c04ebd..9f2cdbca 100644 --- a/motion.spec.in +++ b/motion.spec.in @@ -9,7 +9,7 @@ URL: https://motion-project.github.io/ Source0: https://github.com/Motion-Project/motion BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildRequires: libjpeg-devel ffmpeg-devel zlib-devel +BuildRequires: libjpeg-devel ffmpeg-devel zlib-devel libwebp-devel #This requires comes from the startup script, it will be there until motion supports libv4l calls in the code Requires: libv4l Requires(post): chkconfig diff --git a/motion_guide.html b/motion_guide.html index 92e37cdb..58a96cb9 100644 --- a/motion_guide.html +++ b/motion_guide.html @@ -241,7 +241,7 @@ script for Ubuntu. If errors occur during the process or you wish to customize review the extended building instructions further below.

sudo apt-get install autoconf automake build-essential pkgconf libtool libzip-dev -libjpeg62 libjpeg62-dev git libavformat-dev libavcodec-dev libavutil-dev libswscale-dev +libjpeg62 libjpeg62-dev git libavformat-dev libavcodec-dev libavutil-dev libswscale-dev libwebp-dev

cd ~
git clone https://github.com/Motion-Project/motion.git @@ -277,7 +277,7 @@ Ubuntu / Debian Packages
  • Required
    • - sudo apt-get install autoconf automake build-essential pkgconf libtool git libzip-dev libjpeg62 libjpeg62-dev + sudo apt-get install autoconf automake build-essential pkgconf libtool git libzip-dev libjpeg62 libjpeg62-dev libwebp5 libwebpmux1

    @@ -336,6 +336,8 @@ openSUSE Packages

    sudo zypper install -t pattern devel_C_C++

    + sudo zypper install libwebp-devel +

  • Optional Packages
  • @@ -386,6 +388,7 @@ FreeBSD
  • gcc
  • gmake
  • libjpeg-turbo
  • +
  • libwebp
  • pkgconf
  • ffmpeg
  • @@ -625,6 +628,11 @@ how Motion is built. Specify the prefix for the install path for jpeg-mmx for optimized jpeg handling + + --without-libwebp + Compile without libwebp image support + + --with-ffmpeg=DIR Specify the path for the directory prefix in which the @@ -4053,7 +4061,7 @@ the .jpg or .ppm. E.g. the name can be 01-20020424232936-00m.jpg.
  • Default: 75
  • -The quality for the jpeg images in percent. +The quality for the jpeg or webp images in percent. 100 means hardly compressed. A small number means a much smaller file size but also a less nice quality image to look at.

    From ed820119798705079c2f814e9b1ea2fac81af061 Mon Sep 17 00:00:00 2001 From: Radek Hvizdos Date: Thu, 9 Feb 2017 12:28:46 +0100 Subject: [PATCH 3/7] change the configure to use --without-webp instead of --without-libwebp --- INSTALL | 2 +- configure.ac | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/INSTALL b/INSTALL index 20f42594..560a5c9a 100644 --- a/INSTALL +++ b/INSTALL @@ -44,4 +44,4 @@ Once required packages are installed, execute: Sample custom configuration options: --prefix : Specify the install location for the motion package --with-ffmpeg=[dir] : Specify the location in which ffmpeg/libav is installed. - --without-libwebp : Compile without libwebp image support + --without-webp : Compile without webp image support diff --git a/configure.ac b/configure.ac index 6bf4fbb8..eefd7e6a 100644 --- a/configure.ac +++ b/configure.ac @@ -341,8 +341,8 @@ AM_COND_IF([FOUND_PKGCONFIG],,[AC_MSG_ERROR([Required package 'pkg-config' not f # Check for the libwebp library # -AC_ARG_WITH(libwebp, -[ --without-libwebp Compile without webp image support], +AC_ARG_WITH(webp, +[ --without-webp Compile without webp image support], LIBWEBP="no", LIBWEBP="yes" ) @@ -358,7 +358,7 @@ if test "${LIBWEBP}" = "yes"; then TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_WEBP" else AC_MSG_RESULT(not found) - AC_MSG_ERROR([Required package 'libwebp-dev' not found. Please check motion_guide.html and install necessary dependencies or use the '--without-libwebp' configuration option.]) + AC_MSG_ERROR([Required package 'libwebp-dev' not found. Please check motion_guide.html and install necessary dependencies or use the '--without-webp' configuration option.]) fi fi From a2deae32c456ccadb35712fd4a16c5a4698192e8 Mon Sep 17 00:00:00 2001 From: Radek Hvizdos Date: Thu, 9 Feb 2017 12:30:20 +0100 Subject: [PATCH 4/7] Correct build instructions for Debian/Ubuntu --- motion_guide.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/motion_guide.html b/motion_guide.html index 58a96cb9..50906c98 100644 --- a/motion_guide.html +++ b/motion_guide.html @@ -277,7 +277,7 @@ Ubuntu / Debian Packages
  • Required
    • - sudo apt-get install autoconf automake build-essential pkgconf libtool git libzip-dev libjpeg62 libjpeg62-dev libwebp5 libwebpmux1 + sudo apt-get install autoconf automake build-essential pkgconf libtool git libzip-dev libjpeg62 libjpeg62-dev libwebp-dev

    From 6163d7638414680e047e8a77039aa640e3cb06ff Mon Sep 17 00:00:00 2001 From: Radek Hvizdos Date: Thu, 9 Feb 2017 12:43:20 +0100 Subject: [PATCH 5/7] Fallback to jpeg if webp was selected in the config file, but the support for it was not compiled in --- motion.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/motion.c b/motion.c index 34cce837..659056d8 100644 --- a/motion.c +++ b/motion.c @@ -850,8 +850,15 @@ static int motion_init(struct context *cnt) /* Set output picture type */ if (!strcmp(cnt->conf.picture_type, "ppm")) cnt->imgs.picture_type = IMAGE_TYPE_PPM; - else if (!strcmp(cnt->conf.picture_type, "webp")) + else if (!strcmp(cnt->conf.picture_type, "webp")) { +#ifdef HAVE_WEBP cnt->imgs.picture_type = IMAGE_TYPE_WEBP; +#else + /* Fallback to jpeg if webp was selected in the config file, but the support for it was not compiled in */ + MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: webp image format is not available, failing back to jpeg"); + cnt->imgs.picture_type = IMAGE_TYPE_JPEG; +#endif /* HAVE_WEBP */ + } else cnt->imgs.picture_type = IMAGE_TYPE_JPEG; From 670fcef4e245d5e628e40af385a22dc62384d242 Mon Sep 17 00:00:00 2001 From: Radek Hvizdos Date: Thu, 9 Feb 2017 12:56:20 +0100 Subject: [PATCH 6/7] Replace further references to libwebp with webp and move from CFLAGS to AC_DEFINE --- configure.ac | 20 ++++++++++---------- motion_guide.html | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index eefd7e6a..225dcfe0 100644 --- a/configure.ac +++ b/configure.ac @@ -343,20 +343,20 @@ AM_COND_IF([FOUND_PKGCONFIG],,[AC_MSG_ERROR([Required package 'pkg-config' not f # AC_ARG_WITH(webp, [ --without-webp Compile without webp image support], -LIBWEBP="no", -LIBWEBP="yes" +WEBP="no", +WEBP="yes" ) -HAVE_LIBWEBP="" -if test "${LIBWEBP}" = "yes"; then +HAVE_WEBP="" +if test "${WEBP}" = "yes"; then AC_MSG_CHECKING(for libwebp) - LIBWEBP_DEPS="libwebp" - if pkg-config $LIBWEBP_DEPS; then + WEBP_DEPS="libwebp" + if pkg-config $WEBP_DEPS; then AC_MSG_RESULT(found) - HAVE_LIBWEBP="yes" + AC_DEFINE([HAVE_WEBP], 1, [Define to 1 if WEBP is around]) + HAVE_WEBP="yes" TEMP_LIBS="$TEMP_LIBS -lwebp -lwebpmux" - TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_WEBP" - else +else AC_MSG_RESULT(not found) AC_MSG_ERROR([Required package 'libwebp-dev' not found. Please check motion_guide.html and install necessary dependencies or use the '--without-webp' configuration option.]) fi @@ -1105,7 +1105,7 @@ else echo "**********************************************" fi -if test "${HAVE_LIBWEBP}" = "yes"; then +if test "${HAVE_WEBP}" = "yes"; then echo "webp support: yes" else echo "webp support: no" diff --git a/motion_guide.html b/motion_guide.html index 50906c98..6d1b7a2a 100644 --- a/motion_guide.html +++ b/motion_guide.html @@ -629,8 +629,8 @@ how Motion is built. - --without-libwebp - Compile without libwebp image support + --without-webp + Compile without webp image support From c19ee468e8b2498b783edcc9fe07c2945a0c6913 Mon Sep 17 00:00:00 2001 From: Radek Hvizdos Date: Thu, 9 Feb 2017 13:07:11 +0100 Subject: [PATCH 7/7] Change webp->jpeg fallback message log level to ERR --- motion.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/motion.c b/motion.c index 659056d8..572ffdb7 100644 --- a/motion.c +++ b/motion.c @@ -855,7 +855,7 @@ static int motion_init(struct context *cnt) cnt->imgs.picture_type = IMAGE_TYPE_WEBP; #else /* Fallback to jpeg if webp was selected in the config file, but the support for it was not compiled in */ - MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: webp image format is not available, failing back to jpeg"); + MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: webp image format is not available, failing back to jpeg"); cnt->imgs.picture_type = IMAGE_TYPE_JPEG; #endif /* HAVE_WEBP */ }