>From ae0d3e30935f1dd485f8670f6608162c20766cfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20G=C3=BCntner?= Date: Sun, 25 Sep 2011 23:05:41 +0000 Subject: [PATCH] Merge chapters which are too close --- modules/access/vdr.c | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/modules/access/vdr.c b/modules/access/vdr.c index 873d93f..6888198 100644 --- a/modules/access/vdr.c +++ b/modules/access/vdr.c @@ -63,6 +63,7 @@ See http://www.vdr-wiki.de/ and http://www.tvdr.de/ for more information. #include #include #include +#include #if defined( WIN32 ) && !defined( UNDER_CE ) # undef lseek @@ -90,6 +91,11 @@ static void Close( vlc_object_t * ); #define CHAPTER_OFFSET_LONGTEXT N_( \ "Move all chapters. This value should be set in milliseconds." ) +#define MIN_CHAPTER_GAP_TEXT N_("Minimum gap between chapters") +#define MIN_CHAPTER_GAP_LONGTEXT N_( \ + "Merge chapters which are too close to each other. " \ + "This value should be set in seconds." ) + #define FPS_TEXT N_("Frame rate") #define FPS_LONGTEXT N_( \ "Default frame rate for chapter import." ) @@ -102,6 +108,8 @@ vlc_module_begin () set_description( N_("VDR recordings") ) add_integer( "vdr-chapter-offset", 0, CHAPTER_OFFSET_TEXT, CHAPTER_OFFSET_LONGTEXT, true ) + add_integer_with_range( "vdr-min-chapter-gap", 0, 0, INT_MAX, + MIN_CHAPTER_GAP_TEXT, MIN_CHAPTER_GAP_LONGTEXT, true ) add_float_with_range( "vdr-fps", 25, 1, 1000, FPS_TEXT, FPS_LONGTEXT, true ) set_capability( "access", 60 ) @@ -845,6 +853,14 @@ static void ImportMarks( access_t *p_access ) int i_chapter_offset = p_sys->fps / 1000 * var_InheritInteger( p_access, "vdr-chapter-offset" ); + /* when to merge chapters */ + int i_min_chapter_gap = p_sys->fps * + var_InheritInteger( p_access, "vdr-min-chapter-gap" ); + + /* the last chapter started at this frame (init to 0 so + * we skip useless chapters near the beginning as well) */ + int64_t i_prev_chapter = 0; + /* parse lines of the form "0:00:00.00 foobar" */ char *line = NULL; size_t line_len; @@ -852,6 +868,11 @@ static void ImportMarks( access_t *p_access ) { int64_t i_frame = ParseFrameNumber( line, p_sys->fps ); + /* skip this chapter if it is too close to the previous one */ + if( i_frame - i_prev_chapter < i_min_chapter_gap ) + continue; + i_prev_chapter = i_frame; + /* move chapters (simple workaround for inaccurate cut marks) */ if( i_frame > -i_chapter_offset ) i_frame += i_chapter_offset; -- 1.7.0.4