]> granicus.if.org Git - handbrake/commitdiff
batch: Support --min-duration when doing batch scans
authorJohn Stebbins <jstebbins.hb@gmail.com>
Mon, 27 Feb 2017 20:05:12 +0000 (13:05 -0700)
committerJohn Stebbins <jstebbins.hb@gmail.com>
Mon, 27 Feb 2017 20:06:52 +0000 (13:06 -0700)
Fixes https://github.com/HandBrake/HandBrake/issues/501

libhb/batch.c
libhb/internal.h
libhb/scan.c

index 37e626ce76fec876eb99879e966b0f35526f86ed..cc7808e6c8920c9b447105651080fb21376a8e01 100644 (file)
@@ -114,7 +114,7 @@ int hb_batch_title_count( hb_batch_t * d )
 /***********************************************************************
  * hb_batch_title_scan
  **********************************************************************/
-hb_title_t * hb_batch_title_scan( hb_batch_t * d, int t )
+hb_title_t * hb_batch_title_scan( hb_batch_t * d, int t, uint64_t min_duration )
 {
 
     hb_title_t   * title;
@@ -139,6 +139,11 @@ hb_title_t * hb_batch_title_scan( hb_batch_t * d, int t )
 
     title = hb_stream_title_scan( stream, title );
     hb_stream_close( &stream );
+    if( title->duration < min_duration )
+    {
+        hb_log( "batch: ignoring title (too short)" );
+        hb_title_close(&title);
+    }
 
     return title;
 }
index 1e79447f80c23809b575c332c89622628d6293ed..b41bc29ed354c51a4c3c6e5fd9200be866bb2022 100644 (file)
@@ -309,7 +309,8 @@ typedef struct hb_batch_s hb_batch_t;
 hb_batch_t  * hb_batch_init( hb_handle_t *h, char * path );
 void          hb_batch_close( hb_batch_t ** _d );
 int           hb_batch_title_count( hb_batch_t * d );
-hb_title_t  * hb_batch_title_scan( hb_batch_t * d, int t );
+hb_title_t  * hb_batch_title_scan( hb_batch_t * d, int t,
+                                   uint64_t min_duration );
 
 /***********************************************************************
  * dvd.c
index da7379c0f0318cc98ba48902ad1e99b751a604b6..663ddc6f1538399cd2b340f95c1e26583568b542 100644 (file)
@@ -156,7 +156,7 @@ static void ScanFunc( void * _data )
         if( data->title_index )
         {
             /* Scan this title only */
-            title = hb_batch_title_scan(data->batch, data->title_index);
+            title = hb_batch_title_scan(data->batch, data->title_index, 0);
             if ( title )
             {
                 hb_list_add( data->title_set->list_title, title );
@@ -170,7 +170,8 @@ static void ScanFunc( void * _data )
                 hb_title_t * title;
 
                 UpdateState1(data, i + 1);
-                title = hb_batch_title_scan(data->batch, i + 1);
+                title = hb_batch_title_scan(data->batch, i + 1,
+                                            data->min_title_duration);
                 if ( title != NULL )
                 {
                     hb_list_add( data->title_set->list_title, title );