From a7a422644e9587cb3869730f9b1c37cef4727b44 Mon Sep 17 00:00:00 2001 From: "Jeremy T. Hetzel" Date: Thu, 24 Jan 2013 21:04:49 -0500 Subject: [PATCH 1/2] Added WebM / VP8 codec support Added WebM / VP8 container and codec support. Also modified the concatenation of filename and extension to allow for extensions longer than 4 characters (e.g. '.webm'). --- conf.c | 3 ++- ffmpeg.c | 23 +++++++++++++++-------- motion-dist.conf.in | 1 + motion.1 | 2 +- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/conf.c b/conf.c index 2da0da6..76617d1 100644 --- a/conf.c +++ b/conf.c @@ -750,7 +750,8 @@ config_param config_params[] = { "# flv - gives you a flash video with extension .flv\n" "# ffv1 - FF video codec 1 for Lossless Encoding ( experimental )\n" "# mov - QuickTime ( testing )\n" - "# ogg - Ogg/Theora ( testing )", + "# ogg - Ogg/Theora ( testing )\n" + "# webm - WebM/VP8 ( testing )", 0, CONF_OFFSET(ffmpeg_video_codec), copy_string, diff --git a/ffmpeg.c b/ffmpeg.c index 1c2ae47..592dfa3 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -326,6 +326,7 @@ void ffmpeg_init() static AVOutputFormat *get_oformat(const char *codec, char *filename) { const char *ext; + const int *ext_length; AVOutputFormat *of = NULL; /* * Here, we use guess_format to automatically setup the codec information. @@ -412,14 +413,19 @@ static AVOutputFormat *get_oformat(const char *codec, char *filename) #else of = av_guess_format("mov", NULL, NULL); #endif - } - else if (strcmp (codec, "ogg") == 0) - { - ext = ".ogg"; + } else if (strcmp (codec, "ogg") == 0) { + ext = ".ogg"; #ifdef GUESS_NO_DEPRECATED - of = guess_format ("ogg", NULL, NULL); + of = guess_format ("ogg", NULL, NULL); #else - of = av_guess_format ("ogg", NULL, NULL); + of = av_guess_format ("ogg", NULL, NULL); +#endif + } else if (strcmp (codec, "webm") == 0) { + ext = ".webm"; +#ifdef GUESS_NO_DEPRECATED + of = guess_format ("webm", NULL, NULL); +#else + of = av_guess_format ("webm", NULL, NULL); #endif } else { MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: ffmpeg_video_codec option value" @@ -433,8 +439,9 @@ static AVOutputFormat *get_oformat(const char *codec, char *filename) return NULL; } - /* The 4 allows for ".avi" or ".mpg" to be appended. */ - strncat(filename, ext, 4); + /* Append extension to filename */ + ext_length = strlength(ext); + strncat(filename, ext, ext_length); return of; } diff --git a/motion-dist.conf.in b/motion-dist.conf.in index 30886bc..ac635c0 100644 --- a/motion-dist.conf.in +++ b/motion-dist.conf.in @@ -303,6 +303,7 @@ ffmpeg_variable_bitrate 0 # ffv1 - FF video codec 1 for Lossless Encoding ( experimental ) # mov - QuickTime ( testing ) # ogg - Ogg/Theora ( testing ) +# webm - WebM/VP8 ( testing ) ffmpeg_video_codec mpeg4 # Use ffmpeg to deinterlace video. Necessary if you use an analog camera diff --git a/motion.1 b/motion.1 index a023f83..a20195c 100644 --- a/motion.1 +++ b/motion.1 @@ -170,7 +170,7 @@ Values: 0, 2 - 31 / Default: 0 (disabled) Enables and defines variable bitrate for the ffmpeg encoder. ffmpeg_bps is ignored if variable bitrate is enabled. Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps, or the range 2 - 31 where 2 means best quality and 31 is worst. .TP .B ffmpeg_video_codec discrete strings -Values: mpeg1 (ffmpeg-0.4.8 only), mpeg4, msmpeg4, swf , flv , ffv1, mov, ogg / Default: mpeg4 +Values: mpeg1 (ffmpeg-0.4.8 only), mpeg4, msmpeg4, swf , flv , ffv1, mov, ogg, webm / Default: mpeg4 .br Codec to be used by ffmpeg for the video compression. Timelapse movies are always made in mpeg1 format independent from this option. .TP From 88411b2503a002106f1b8bc24c31e9a9e7252312 Mon Sep 17 00:00:00 2001 From: "Jeremy T. Hetzel" Date: Fri, 25 Jan 2013 11:31:11 -0500 Subject: [PATCH 2/2] Added WebM/VP8 codec support to changelog --- CHANGELOG | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 7c7f11e..e688ac4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -48,6 +48,8 @@ Features * Added codec Ogg/Theora as new output format for regular movies. http://www.lavrsen.dk/foswiki/bin/view/Motion/OggTimelapse (Michael Luich) * Added support for ffmpeg 0.11 new API. + * Added codec WebM/Theora as new output format for motion-triggered movies. + http://www.lavrsen.dk/foswiki/bin/edit/Motion/WebMVP8Codec (Jeremy T. Hetzel) Bugfixes * Avoid segfault detecting strerror_r() version GNU or SUSv3. (Angel Carpintero)