Skip to content

Commit 2496e21

Browse files
committed
add ffmpeg_duplicate_frames option
This lets the user decide which video problems they would rather see. In my case a Raspberry Pi 2 with a 640x480 webcam sometimes can keep up with 10fps so I don't want to set the framerate any lower, but then sometimes it can't and with duplicate frames it looks like the video output freezes every second.
1 parent fb73273 commit 2496e21

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

conf.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,15 @@ config_param config_params[] = {
668668
print_string
669669
},
670670
{
671+
"ffmpeg_duplicate_frames",
672+
"# True to duplicate frames to achieve \"framerate\" fps, but enough\n"
673+
"duplicated frames and the video appears to freeze once a second.",
674+
0,
675+
CONF_OFFSET(ffmpeg_duplicate_frames),
676+
copy_bool,
677+
print_bool
678+
},
679+
{
671680
"output_debug_pictures",
672681
"# Output pictures with only the pixels moving object (ghost images) (default: off)",
673682
0,

conf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ struct config {
3030
int max_changes;
3131
int threshold_tune;
3232
const char *output_pictures;
33+
int ffmpeg_duplicate_frames;
3334
int motion_img;
3435
int emulate_motion;
3536
int event_gap;

motion.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,13 @@ static void process_image_ring(struct context *cnt, unsigned int max_images)
570570
/*
571571
* Check if we must add any "filler" frames into movie to keep up fps
572572
* Only if we are recording videos ( ffmpeg or extenal pipe )
573+
* While the overall elapsed time might be correct, if there are
574+
* many duplicated frames, say 10 fps, 5 duplicated, the video will
575+
* look like it is frozen every second for half a second.
573576
*/
574-
if ((cnt->imgs.image_ring[cnt->imgs.image_ring_out].shot == 0) &&
577+
if (!cnt->conf.ffmpeg_duplicate_frames) {
578+
/* don't duplicate frames */
579+
} else if ((cnt->imgs.image_ring[cnt->imgs.image_ring_out].shot == 0) &&
575580
#ifdef HAVE_FFMPEG
576581
(cnt->ffmpeg_output || (cnt->conf.useextpipe && cnt->extpipe))) {
577582
#else

0 commit comments

Comments
 (0)