From 22b2461cb273dab0eb807e0463dd45d4bb50347b Mon Sep 17 00:00:00 2001 From: MrDave Date: Thu, 1 Sep 2016 20:35:44 -0600 Subject: [PATCH] Better implementation of the test codec --- event.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/event.c b/event.c index 912a8ad8..f5ca2bb4 100644 --- a/event.c +++ b/event.c @@ -608,7 +608,7 @@ static void event_ffmpeg_newfile(struct context *cnt, unsigned char *convbuf, *y, *u, *v; char stamp[PATH_MAX]; const char *moviepath; - char codec[8]; + const char *codec; long codenbr; if (!cnt->conf.ffmpeg_output && !cnt->conf.ffmpeg_output_debug) @@ -629,46 +629,50 @@ static void event_ffmpeg_newfile(struct context *cnt, * motion movies get the same name as normal movies plus an appended 'm' * PATH_MAX - 4 to allow for .mpg to be appended without overflow */ - /* Set up a testing / evaluation codec which will use a different - * codec for the events. + + /* The following section allows for testing of all the various containers + * that Motion permits. The container type is pre-pended to the name of the + * file so that we can determine which container type created what movie. + * The intent for this is be used for developer testing when the ffmpeg libs + * change or the code inside our ffmpeg module changes. For each event, the + * container type will change. This way, you can turn on emulate motion, then + * specify a maximum movie time and let Motion run for days creating all the + * different types of movies checking for crashes, warnings, etc. */ - snprintf(codec, sizeof(codec), "%s", cnt->conf.ffmpeg_video_codec); + codec = cnt->conf.ffmpeg_video_codec; if (strcmp(codec, "test") == 0) { MOTION_LOG(NTC, TYPE_ENCODER, NO_ERRNO, "%s Running test of the various output formats."); - codenbr = cnt->event_nr; - while (codenbr > 10){ - codenbr -= 10; - } + codenbr = cnt->event_nr % 10; switch (codenbr) { case 1: - snprintf(codec, sizeof(codec), "%s", "mpeg4"); + codec = "mpeg4"; break; case 2: - snprintf(codec, sizeof(codec), "%s", "msmpeg4"); + codec = "msmpeg4"; break; case 3: - snprintf(codec, sizeof(codec), "%s", "swf"); + codec = "swf"; break; case 4: - snprintf(codec, sizeof(codec), "%s", "flv"); + codec = "flv"; break; case 5: - snprintf(codec, sizeof(codec), "%s", "ffv1"); + codec = "ffv1"; break; case 6: - snprintf(codec, sizeof(codec), "%s", "mov"); + codec = "mov"; break; case 7: - snprintf(codec, sizeof(codec), "%s", "mp4"); + codec = "mp4"; break; case 8: - snprintf(codec, sizeof(codec), "%s", "mkv"); + codec = "mkv"; break; case 9: - snprintf(codec, sizeof(codec), "%s", "hevc"); + codec = "hevc"; break; default: - snprintf(codec, sizeof(codec), "%s", "msmpeg4"); + codec = "msmpeg4"; break; } snprintf(cnt->motionfilename, PATH_MAX - 4, "%s/%s_%sm", cnt->conf.filepath, codec, stamp);