@@ -608,6 +608,8 @@ static void event_ffmpeg_newfile(struct context *cnt,
608608 unsigned char * convbuf , * y , * u , * v ;
609609 char stamp [PATH_MAX ];
610610 const char * moviepath ;
611+ char codec [8 ];
612+ long codenbr ;
611613
612614 if (!cnt -> conf .ffmpeg_output && !cnt -> conf .ffmpeg_output_debug )
613615 return ;
@@ -627,9 +629,54 @@ static void event_ffmpeg_newfile(struct context *cnt,
627629 * motion movies get the same name as normal movies plus an appended 'm'
628630 * PATH_MAX - 4 to allow for .mpg to be appended without overflow
629631 */
630- snprintf (cnt -> motionfilename , PATH_MAX - 4 , "%s/%sm" , cnt -> conf .filepath , stamp );
631- snprintf (cnt -> newfilename , PATH_MAX - 4 , "%s/%s" , cnt -> conf .filepath , stamp );
632-
632+ /* Set up a testing / evaluation codec which will use a different
633+ * codec for the events.
634+ */
635+ snprintf (codec , sizeof (codec ), "%s" , cnt -> conf .ffmpeg_video_codec );
636+ if (strcmp (codec , "test" ) == 0 ) {
637+ MOTION_LOG (NTC , TYPE_ENCODER , NO_ERRNO , "%s Running test of the various output formats." );
638+ codenbr = cnt -> event_nr ;
639+ while (codenbr > 10 ){
640+ codenbr -= 10 ;
641+ }
642+ switch (codenbr ) {
643+ case 1 :
644+ snprintf (codec , sizeof (codec ), "%s" , "mpeg4" );
645+ break ;
646+ case 2 :
647+ snprintf (codec , sizeof (codec ), "%s" , "msmpeg4" );
648+ break ;
649+ case 3 :
650+ snprintf (codec , sizeof (codec ), "%s" , "swf" );
651+ break ;
652+ case 4 :
653+ snprintf (codec , sizeof (codec ), "%s" , "flv" );
654+ break ;
655+ case 5 :
656+ snprintf (codec , sizeof (codec ), "%s" , "ffv1" );
657+ break ;
658+ case 6 :
659+ snprintf (codec , sizeof (codec ), "%s" , "mov" );
660+ break ;
661+ case 7 :
662+ snprintf (codec , sizeof (codec ), "%s" , "mp4" );
663+ break ;
664+ case 8 :
665+ snprintf (codec , sizeof (codec ), "%s" , "mkv" );
666+ break ;
667+ case 9 :
668+ snprintf (codec , sizeof (codec ), "%s" , "hevc" );
669+ break ;
670+ default :
671+ snprintf (codec , sizeof (codec ), "%s" , "msmpeg4" );
672+ break ;
673+ }
674+ snprintf (cnt -> motionfilename , PATH_MAX - 4 , "%s/%s_%sm" , cnt -> conf .filepath , codec , stamp );
675+ snprintf (cnt -> newfilename , PATH_MAX - 4 , "%s/%s_%s" , cnt -> conf .filepath , codec , stamp );
676+ } else {
677+ snprintf (cnt -> motionfilename , PATH_MAX - 4 , "%s/%sm" , cnt -> conf .filepath , stamp );
678+ snprintf (cnt -> newfilename , PATH_MAX - 4 , "%s/%s" , cnt -> conf .filepath , stamp );
679+ }
633680 if (cnt -> conf .ffmpeg_output ) {
634681 if (cnt -> imgs .type == VIDEO_PALETTE_GREY ) {
635682 convbuf = mymalloc ((width * height ) / 2 );
@@ -645,7 +692,7 @@ static void event_ffmpeg_newfile(struct context *cnt,
645692 }
646693
647694 if ((cnt -> ffmpeg_output =
648- ffmpeg_open (cnt -> conf . ffmpeg_video_codec , cnt -> newfilename , y , u , v ,
695+ ffmpeg_open (codec , cnt -> newfilename , y , u , v ,
649696 cnt -> imgs .width , cnt -> imgs .height , cnt -> movie_fps , cnt -> conf .ffmpeg_bps ,
650697 cnt -> conf .ffmpeg_vbr ,TIMELAPSE_NONE )) == NULL ) {
651698 MOTION_LOG (ERR , TYPE_EVENTS , SHOW_ERRNO , "%s: ffopen_open error creating (new) file [%s]" ,
@@ -673,7 +720,7 @@ static void event_ffmpeg_newfile(struct context *cnt,
673720 }
674721
675722 if ((cnt -> ffmpeg_output_debug =
676- ffmpeg_open (cnt -> conf . ffmpeg_video_codec , cnt -> motionfilename , y , u , v ,
723+ ffmpeg_open (codec , cnt -> motionfilename , y , u , v ,
677724 cnt -> imgs .width , cnt -> imgs .height , cnt -> movie_fps , cnt -> conf .ffmpeg_bps ,
678725 cnt -> conf .ffmpeg_vbr ,TIMELAPSE_NONE )) == NULL ) {
679726 MOTION_LOG (ERR , TYPE_EVENTS , SHOW_ERRNO , "%s: ffopen_open error creating (motion) file [%s]" ,
0 commit comments