Hi,

Am Montag, 22. Oktober 2007 22:26 schrieb Ralph Glasstetter:
> > If you plan to add more new features...
>
> Hmmm,.... not at the moment...  [...]

Never say never,... ahemmm... 
the next step was so obvious/obtrusive, so I did it... ;)

I implemented a "Convert bookmarks" Edit-menu entry which converts the 
bookmarks to alternating START/STOP markers. Don't know if this is really 
useful in GUI mode (we could remove it there?), but I did this mainly for the 
pupose of quick&dirty batch cutting (when it's not necessary to hit the exact 
cut points).

Therefore we now also have a CLI switch "-cut" as additional option for 
"-batch", which must be followed by either 'AR' (suggest+convert), 
'TS' (import+convert) or a comma separated list of frame numbers (convert). 
For the latter it's also possible to use different separators, for instance 
'1-100|200-300',... just for better readability...

BTW, with this patch I also enabled the output frame number search box
and found a small bug with the displayed output frame number when 
positioned on a stop marker (it was 1 to large)! :) 

ciao
Ralph

PS: Don't wonder about the (not used) seteventtype member function,... it is 
left from an alternative (faster) way to convert the bookmarks to start/stop 
makers. But that way it was possible to double markers, so I changed it to 
the current version... 

PPS: The statusbar() stuff is also included in the patch!
diff -Naur svn/src/dvbcutbase.ui r93-clicut/src/dvbcutbase.ui
--- svn/src/dvbcutbase.ui	2007-10-22 12:05:55.000000000 +0200
+++ r93-clicut/src/dvbcutbase.ui	2007-10-24 21:48:24.000000000 +0200
@@ -374,6 +374,7 @@
         <separator/>
         <action name="editSuggestAction"/>
         <action name="editImportAction"/>
+        <action name="editConvertAction"/>
     </item>
     <item text="View" name="viewMenu">
         <action name="viewNormalAction"/>
@@ -607,7 +608,7 @@
             <iconset>image9</iconset>
         </property>
         <property name="text">
-            <string>Set end marker</string>
+            <string>Set stop marker</string>
         </property>
         <property name="accel">
             <string>N</string>
@@ -655,7 +656,7 @@
             <bool>false</bool>
         </property>
         <property name="text">
-            <string>Suggest markers</string>
+            <string>Suggest bookmarks</string>
         </property>
         <property name="accel">
             <string>M</string>
@@ -669,7 +670,7 @@
             <bool>false</bool>
         </property>
         <property name="text">
-            <string>Import markers</string>
+            <string>Import bookmarks</string>
         </property>
         <property name="accel">
             <string>I</string>
@@ -677,6 +678,20 @@
     </action>
     <action>
         <property name="name">
+            <cstring>editConvertAction</cstring>
+        </property>
+        <property name="enabled">
+            <bool>false</bool>
+        </property>
+        <property name="text">
+            <string>Convert bookmarks</string>
+        </property>
+        <property name="accel">
+            <string>T</string>
+        </property>
+    </action>
+    <action>
+        <property name="name">
             <cstring>fileNewAction</cstring>
         </property>
         <property name="iconSet">
@@ -920,6 +935,12 @@
         <slot>editImport()</slot>
     </connection>
     <connection>
+        <sender>editConvertAction</sender>
+        <signal>activated()</signal>
+        <receiver>dvbcutbase</receiver>
+        <slot>editConvert()</slot>
+    </connection>
+    <connection>
         <sender>eventlist</sender>
         <signal>doubleClicked(QListBoxItem*)</signal>
         <receiver>dvbcutbase</receiver>
@@ -944,6 +965,18 @@
         <slot>clickedgo()</slot>
     </connection>
     <connection>
+        <sender>gobutton2</sender>
+        <signal>clicked()</signal>
+        <receiver>dvbcutbase</receiver>
+        <slot>clickedgo2()</slot>
+    </connection>
+    <connection>
+        <sender>goinput2</sender>
+        <signal>returnPressed()</signal>
+        <receiver>dvbcutbase</receiver>
+        <slot>clickedgo2()</slot>
+    </connection>
+    <connection>
         <sender>playPlayAction</sender>
         <signal>activated()</signal>
         <receiver>dvbcutbase</receiver>
@@ -1045,9 +1078,11 @@
     <slot>editBookmark()</slot>
     <slot>editSuggest()</slot>
     <slot>editImport()</slot>
+    <slot>editConvert()</slot>
     <slot>doubleclickedeventlist(QListBoxItem *)</slot>
     <slot>eventlistcontextmenu(QListBoxItem *, const QPoint &amp;)</slot>
     <slot>clickedgo()</slot>
+    <slot>clickedgo2()</slot>
     <slot>playPlay()</slot>
     <slot>playStop()</slot>
     <slot>playAudio1()</slot>
diff -Naur svn/src/dvbcut.cpp r93-clicut/src/dvbcut.cpp
--- svn/src/dvbcut.cpp	2007-10-23 15:42:32.000000000 +0200
+++ r93-clicut/src/dvbcut.cpp	2007-10-24 22:55:14.000000000 +0200
@@ -45,6 +45,7 @@
 #include <qmenubar.h>
 #include <qsettings.h>
 #include <qregexp.h>
+#include <qstatusbar.h>
 
 #include "port.h"
 #include "dvbcut.h"
@@ -663,7 +664,7 @@
     found++;
   }
   if(!found)  
-    fprintf(stderr,"No aspect ratio changes detected!\n");   
+    statusBar()->message(QString("*** No aspect ratio changes detected! ***"));   
 }
 
 void dvbcut::editImport()
@@ -675,7 +676,45 @@
     found++;
   }
   if(!found)  
-    fprintf(stderr,"No valid bookmarks available/found!\n");
+    statusBar()->message(QString("*** No valid bookmarks available/found! ***"));
+}
+
+void dvbcut::editConvert()
+{
+  int found=0;
+  std::vector<int> cutlist;
+  for (QListBoxItem *item=eventlist->firstItem();item;item=item->next())
+    if (item->rtti()==EventListItem::RTTI()) {
+      EventListItem *eli=(EventListItem*)item;
+      if (eli->geteventtype()==EventListItem::bookmark) {
+         cutlist.push_back(eli->getpicture());
+         delete item;       
+         found++;
+      } 
+    } 
+  if(found) {
+    addStartStopItems(cutlist);
+    update_quick_picture_lookup_table();
+
+    if(found%2) 
+      statusBar()->message(QString("*** No matching stop marker!!! ***"));
+  }  
+  else
+    statusBar()->message(QString("*** No bookmarks to convert! ***"));  
+}
+
+void dvbcut::addStartStopItems(std::vector<int> cutlist)
+{
+   // take list of frame numbers and set alternating START/STOP markers
+  EventListItem::eventtype type=EventListItem::start;
+  for (std::vector<int>::iterator it = cutlist.begin(); it != cutlist.end(); ++it) {   
+    addEventListItem(*it, type);
+    if(type==EventListItem::start) 
+      type=EventListItem::stop;
+    else 
+      type=EventListItem::start;  
+  }
+  update_quick_picture_lookup_table();
 }
 
 void dvbcut::viewDifference()
@@ -1022,14 +1061,32 @@
   QString text=goinput->text();
   text.stripWhiteSpace();
   bool okay=false;
-  int n=text.toInt(&okay,0);
+  int inpic=text.toInt(&okay,0);
   if (okay) {
     fine=true;
-    linslider->setValue(n);
+    linslider->setValue(inpic);
     fine=false;
   }
   //goinput->clear();
+}
 
+void dvbcut::clickedgo2()
+{
+  QString text=goinput2->text();
+  text.stripWhiteSpace();
+  bool okay=false;
+  int inpic, outpic=text.toInt(&okay,0);
+  if (okay) {
+    // find the entry in the quick_picture_lookup table that corresponds to given output picture
+    quick_picture_lookup_t::iterator it=
+      std::upper_bound(quick_picture_lookup.begin(),quick_picture_lookup.end(),outpic,quick_picture_lookup_s::cmp_outpicture());
+    --it;
+    inpic=outpic-it->outpicture+it->picture;   
+    fine=true;
+    linslider->setValue(inpic);
+    fine=false;
+  }
+  //goinput2->clear();
 }
 
 void dvbcut::mplayer_exited()
@@ -1052,8 +1109,8 @@
   jogslider->setEnabled(true);
   gobutton->setEnabled(true);
   goinput->setEnabled(true);
-  //gobutton2->setEnabled(true);
-  //goinput2->setEnabled(true);
+  gobutton2->setEnabled(true);
+  goinput2->setEnabled(true);
 
 #ifdef HAVE_LIB_AO
 
@@ -1252,10 +1309,11 @@
   audiotrackpopup->clear();
   editStartAction->setEnabled(false);
   editStopAction->setEnabled(false);
-  editSuggestAction->setEnabled(false);
-  editImportAction->setEnabled(false);
   editChapterAction->setEnabled(false);
   editBookmarkAction->setEnabled(false);
+  editSuggestAction->setEnabled(false);
+  editImportAction->setEnabled(false);
+  editConvertAction->setEnabled(false);
 
 #ifdef HAVE_LIB_AO
 
@@ -1560,10 +1618,11 @@
   playStopAction->setEnabled(false);
   editStartAction->setEnabled(true);
   editStopAction->setEnabled(true);
-  editSuggestAction->setEnabled(true);
-  editImportAction->setEnabled(true);
   editChapterAction->setEnabled(true);
   editBookmarkAction->setEnabled(true);
+  editSuggestAction->setEnabled(true);
+  editImportAction->setEnabled(true);
+  editConvertAction->setEnabled(true);
   viewNormalAction->setEnabled(true);
   viewUnscaledAction->setEnabled(true);
   viewDifferenceAction->setEnabled(true);
@@ -1582,8 +1641,8 @@
   pictimelabel2->setEnabled(true);
   goinput->setEnabled(true);
   gobutton->setEnabled(true);
-  //goinput2->setEnabled(true);
-  //gobutton2->setEnabled(true);
+  goinput2->setEnabled(true);
+  gobutton2->setEnabled(true);
   linslider->setEnabled(true);
   jogslider->setEnabled(true);
 
@@ -1735,7 +1794,7 @@
   int outpic=0;
   pts_t outpts=0;
   
-    // find the entry in the quick_picture_lookup table that corresponds to curpic
+  // find the entry in the quick_picture_lookup table that corresponds to curpic
   quick_picture_lookup_t::iterator it=
     std::upper_bound(quick_picture_lookup.begin(),quick_picture_lookup.end(),curpic,quick_picture_lookup_s::cmp_picture());
    
@@ -1754,7 +1813,8 @@
      }
      else
      {
-       outpic=it->outpicture;
+       // the picture number is one less than the number of output pictures!
+       outpic=it->outpicture-1;
        outpts=it->outpts;
      }
    }
diff -Naur svn/src/dvbcut.h r93-clicut/src/dvbcut.h
--- svn/src/dvbcut.h	2007-10-22 12:05:55.000000000 +0200
+++ r93-clicut/src/dvbcut.h	2007-10-24 22:00:19.000000000 +0200
@@ -57,6 +57,13 @@
         return lhs<rhs.picture;
       }
     };
+    struct cmp_outpicture
+    {
+      bool operator()(int lhs, const quick_picture_lookup_s &rhs) const
+      {
+        return lhs<rhs.outpicture;
+      }
+    };
   };
   typedef std::vector<quick_picture_lookup_s> quick_picture_lookup_t;
   
@@ -118,6 +125,7 @@
   void setbusy(bool b=true);
   void batchmode(bool b=true) { nogui = b; }
   // static dvbcut *New(std::string filename=std::string(), std::string idxfilename=std::string());
+  void addStartStopItems(std::vector<int>);
 
 public slots:
   virtual void fileNew();
@@ -133,6 +141,7 @@
   virtual void editStart();
   virtual void editSuggest();
   virtual void editImport();
+  virtual void editConvert();
   virtual void viewDifference();
   virtual void viewUnscaled();
   virtual void viewNormal();
@@ -151,6 +160,7 @@
   virtual void mplayer_exited();
   virtual void mplayer_readstdout();
   virtual void clickedgo();
+  virtual void clickedgo2();
   virtual void updateimagedisplay();
   virtual void audiotrackchosen(int id);
   virtual void loadrecentfile(int id);
diff -Naur svn/src/eventlistitem.h r93-clicut/src/eventlistitem.h
--- svn/src/eventlistitem.h	2007-10-11 20:03:19.000000000 +0200
+++ r93-clicut/src/eventlistitem.h	2007-10-24 17:04:05.000000000 +0200
@@ -50,6 +50,11 @@
     {
     return evtype;
     }
+  void seteventtype(enum eventtype type)
+    {
+    evtype=type;
+    return;
+    }
 
   int	 height( const QListBox *lb ) const;
   int	 width( const QListBox *lb )  const;
diff -Naur svn/src/main.cpp r93-clicut/src/main.cpp
--- svn/src/main.cpp	2007-10-14 01:19:43.000000000 +0200
+++ r93-clicut/src/main.cpp	2007-10-24 21:22:09.000000000 +0200
@@ -40,20 +40,30 @@
 #include "mpgfile.h"
 #include "index.h"
 
+#include "version.h"
+
+#define VERSION_STRING	"dvbcut " VERSION "/" REVISION
+
 static char *argv0;
 
 void
 usage_exit(int rv=1) {
   fprintf(stderr,
-    "Usage:\n"
+    "Usage ("VERSION_STRING"):\n"
     "  %s -generateidx [-idx <indexfilename>] [<mpgfilename> ...]\n"
-    "  %s -batch <prjfilename> | <mpgfilename> ...\n\n",
+    "  %s -batch [ -cut AR|TS|<list> ] <prjfilename> | <mpgfilename> ...\n\n",
     argv0, argv0);
   fprintf(stderr,
     "If no input files are specified, `dvbcut -generateidx' reads from\n"
     "standard input.  By default, it also writes the index to standard\n"
     "output, but you can specify another destination with `-idx'.\n\n");
   fprintf(stderr,
+    "In batch mode you can use `-cut' to create automatically alternating\n"
+    "START/STOP cut markers for each found aspect ratio change (AR), for\n"
+    "the bookmarks imported from the input transport stream (TS) or for\n"
+    "a given list of frame number pairs (i.e. '10-1000,1200-2000,...').\n" 
+    "Without any cut markers the whole file will be converted!\n\n");
+  fprintf(stderr,
     "Options may be abbreviated as long as they remain unambiguous.\n\n");
   exit(rv);
 }
@@ -63,7 +73,8 @@
   argv0=argv[0];
   bool generateidx=false;
   bool batchmode=false;
-  std::string idxfilename;
+  std::string idxfilename, cut;
+  std::vector<int> cutlist;
   int i;
 
   /*
@@ -81,7 +92,14 @@
       generateidx = true;
     else if (strncmp(argv[i], "-idx", n) == 0 && ++i < argc)
       idxfilename = argv[i];
-    else
+    else if (strncmp(argv[i], "-cut", n) == 0 && ++i < argc) {
+      cut=argv[i];
+      char *pch=strtok(argv[i],",-.;:|/ ");     
+      while(pch) {
+         cutlist.push_back(atoi(pch));  
+         pch=strtok(NULL,",-.;:|/ ");                 
+      }
+    } else
       usage_exit();
   }
 
@@ -173,6 +191,16 @@
     if (filenames.empty())	// must provide at least one filename
       usage_exit();
     main->open(filenames,idxfilename);
+    if(!cut.empty()) {
+      if(cut=="AR") {
+          main->editSuggest();
+          main->editConvert();             
+      } else if(cut=="TS") {
+          main->editImport();     
+          main->editConvert();             
+      } else  
+          main->addStartStopItems(cutlist);
+    }  
     main->fileExport();
     rv = 0;
   }
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
DVBCUT-user mailing list
DVBCUT-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dvbcut-user

Reply via email to