Hi,

Am Mittwoch, 12. Dezember 2007 10:23 schrieb Michael Riepe:
> It might be more convenient to use two different conversions: "extract
> 4:3" and "extract 16:9". 
Good idea...  just was to lazy when implementig AR... nevertheless, AR would 
work with any aspect ratio (but I don't know if this can happen...).

> The first one would convert bookmarks with an 
> AR of 4:3 to START markers, and those with 16:9 AR to STOP markers,
> while the second one works vice versa. 

OK... for converting the bookmarks I implemented now submenus under "Edit":
--> START/STOP
--> STOP/START
-> 4:3 
->16:9 
and editConvert() hast to be called with an argument 0-3 (with 0 giving the 
old behavoir, 1=reverse order, 2=4:3, 3=16:9)! 

I hope I have not broken the UI-File when implementing it manualy without
QT designer... ahemmm...

The CLI now knows the -cut parameters "4:3" and "16:9", the old "AR" 
is obsolete (but still there... just in case...;-)). There is now also a "TS2"
for the imported transport stream bookmarks, which will start with a STOP...

> Additionally, we could add an 
> option that strips leading STOP and trailing START markers afterwards.

Actually we had that options already in the settings, with start_bof=false 
resp. stop_eof=false leading STOPs / trailing STARTs would be ignored! 

I just have implemented now the corresponding CLI-switch "-automarker 0|1|2|3" 
to set those two bool variables (which of course will not be written to the 
settings ;-)),... bit1 for START and bit2 for STOP...

David, for instance, now can get his 4:3 movie with "-cut 4:3 -auto 3" ... 
The EOF/BOF behavoir from the settings file now no longer is used for the CLI 
(also not as default, which is now ALWAYS "-auto 3" resp. start_bof=true and 
stop_eof=true,.... like the CLI export format that defaults to 0 since the 
last patch). 

Therefore actually David could just type  '-cut 4:3' which in any case would 
export every single 4:3-frame from the TS... :-)

ciao
Ralph
diff -Naur svn/ChangeLog r109-exportAR/ChangeLog
--- svn/ChangeLog       2007-12-12 11:14:15.000000000 +0100
+++ r109-exportAR/ChangeLog     2007-12-12 19:01:47.000000000 +0100
@@ -1,3 +1,13 @@
+2007-12-12  Ralph Glasstetter  <[EMAIL PROTECTED]>  (mr)
+
+
+        * src/dvbcutbase.ui
+        * src/dvbcut.cpp
+        * src/dvbcut.h
+        * src/main.cpp
+                Added 4:3 & 16:9 bookmark conversion to GUI & CLI
+                Addtional -cut & -automarker CLI switches
+
+
 2007-12-08  Ralph Glasstetter  <[EMAIL PROTECTED]>  (mr)

        * src/dvbcut.cpp:
diff -Naur svn/src/dvbcutbase.ui r109-exportAR/src/dvbcutbase.ui
--- svn/src/dvbcutbase.ui	2007-12-06 16:44:12.000000000 +0100
+++ r109-exportAR/src/dvbcutbase.ui	2007-12-12 16:29:09.000000000 +0100
@@ -378,7 +378,6 @@
         <separator/>
         <action name="editSuggestAction"/>
         <action name="editImportAction"/>
-        <action name="editConvertAction"/>
     </item>
     <item text="View" name="viewMenu">
         <action name="viewNormalAction"/>
@@ -682,20 +681,6 @@
     </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">
@@ -953,12 +938,6 @@
         <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>
@@ -1105,7 +1084,8 @@
     <slot>editBookmark()</slot>
     <slot>editSuggest()</slot>
     <slot>editImport()</slot>
-    <slot>editConvert()</slot>
+    <slot>editConvert(int)</slot>
+    <slot>abouttoshoweditconvert()</slot>
     <slot>doubleclickedeventlist(QListBoxItem *)</slot>
     <slot>eventlistcontextmenu(QListBoxItem *, const QPoint &amp;)</slot>
     <slot>clickedgo()</slot>
diff -Naur svn/src/dvbcut.cpp r109-exportAR/src/dvbcut.cpp
--- svn/src/dvbcut.cpp	2007-12-12 11:14:15.000000000 +0100
+++ r109-exportAR/src/dvbcut.cpp	2007-12-12 17:30:21.000000000 +0100
@@ -119,7 +119,7 @@
 
 dvbcut::dvbcut(QWidget *parent, const char *name, WFlags fl)
   :dvbcutbase(parent, name, fl),
-    audiotrackpopup(0), recentfilespopup(0), audiotrackmenuid(-1),
+    audiotrackpopup(0), recentfilespopup(0), editconvertpopup(0), audiotrackmenuid(-1),
     buf(8 << 20, 128 << 20),
     mpg(0), pictures(0),
     curpic(~0), showimage(true), fine(false),
@@ -147,6 +147,11 @@
   connect( recentfilespopup, SIGNAL( activated(int) ), this, SLOT( loadrecentfile(int) ) );
   connect( recentfilespopup, SIGNAL( aboutToShow() ), this, SLOT( abouttoshowrecentfiles() ) );
 
+  editconvertpopup=new QPopupMenu(this);
+  editMenu->insertItem(QString("Convert bookmarks"),editconvertpopup,-1,7);
+  connect( editconvertpopup, SIGNAL( activated(int) ), this, SLOT( editConvert(int) ) );
+  connect( editconvertpopup, SIGNAL( aboutToShow() ), this, SLOT( abouttoshoweditconvert() ) );
+
   setviewscalefactor(settings().viewscalefactor);
 
   // install event handler
@@ -170,6 +175,8 @@
     delete audiotrackpopup;
   if (recentfilespopup)
     delete recentfilespopup;
+  if (editconvertpopup)
+    delete editconvertpopup;
 
   if (imgp)
     delete imgp;
@@ -870,8 +877,21 @@
     statusBar()->message(QString("*** No valid bookmarks available/found! ***"));
 }
 
-void dvbcut::editConvert()
+
+void dvbcut::abouttoshoweditconvert()
+{
+  editconvertpopup->clear();
+  editconvertpopup->insertItem(QString("START / STOP"), 0);    
+  editconvertpopup->insertItem(QString("STOP / START"), 1);    
+  editconvertpopup->insertItem(QString("4 : 3"), 2);    
+  editconvertpopup->insertItem(QString("16 : 9"), 3);    
+}
+
+void dvbcut::editConvert(int option)
 {
+  // convert Bookmarks to START/STOP markers
+  if(option<0 || option>3) return;
+  
   int found=0;
   std::vector<int> cutlist;
   for (QListBoxItem *item=eventlist->firstItem();item;item=item->next())
@@ -884,7 +904,7 @@
       } 
     } 
   if (found) {
-    addStartStopItems(cutlist);
+    addStartStopItems(cutlist, option);
 
     if (found%2) 
       statusBar()->message(QString("*** No matching stop marker!!! ***"));
@@ -893,10 +913,16 @@
     statusBar()->message(QString("*** No bookmarks to convert! ***"));  
 }
 
-void dvbcut::addStartStopItems(std::vector<int> cutlist)
+void dvbcut::addStartStopItems(std::vector<int> cutlist, int option)
 {
   // take list of frame numbers and set alternating START/STOP markers
-
+  bool alternate=true;
+  EventListItem::eventtype type=EventListItem::start;
+  if(option==1)
+    type=EventListItem::stop;
+  else if(option==2 || option==3)
+    alternate=false;   
+ 
   // make sure list is sorted... 
   sort(cutlist.begin(),cutlist.end());
 
@@ -907,14 +933,25 @@
       if (eli->geteventtype()==EventListItem::start || eli->geteventtype()==EventListItem::stop) 
          delete item;       
     } 
-
-  EventListItem::eventtype type=EventListItem::start;
+  
   for (std::vector<int>::iterator it = cutlist.begin(); it != cutlist.end(); ++it) {   
+    if(!alternate) {
+      // set START/STOP according aspect ratio (2=4:3, 3=16:9)
+      if (option == (*mpg)[*it].getaspectratio()) 
+        type=EventListItem::start;
+      else 
+        type=EventListItem::stop;  
+    } 
+
     addEventListItem(*it, type);
-    if (type==EventListItem::start) 
-      type=EventListItem::stop;
-    else 
-      type=EventListItem::start;  
+
+    if(alternate) {
+      // set START/STOP alternatingly
+      if(type==EventListItem::start) 
+        type=EventListItem::stop;
+      else
+        type=EventListItem::start;  
+    }
   }
   
   update_quick_picture_lookup_table();
@@ -1565,7 +1602,7 @@
   editBookmarkAction->setEnabled(false);
   editSuggestAction->setEnabled(false);
   editImportAction->setEnabled(false);
-  editConvertAction->setEnabled(false);
+  //editConvertAction->setEnabled(false);
 
 #ifdef HAVE_LIB_AO
 
@@ -1896,7 +1933,7 @@
   editBookmarkAction->setEnabled(true);
   editSuggestAction->setEnabled(true);
   editImportAction->setEnabled(true);
-  editConvertAction->setEnabled(true);
+  //editConvertAction->setEnabled(true);
   viewNormalAction->setEnabled(true);
   viewUnscaledAction->setEnabled(true);
   viewDifferenceAction->setEnabled(true);
@@ -2117,7 +2154,13 @@
   pts_t startpts, stoppts, outpts=0;
   bool realzero=false;
   
-  if (settings().start_bof) {
+  if(!nogui) {
+    // overwrite CLI options
+    start_bof = settings().start_bof;
+    stop_eof = settings().stop_eof;
+  }
+  
+  if (start_bof) {
     startpic=0;
     startpts=(*mpg)[0].getpts()-firstpts; 
   }
@@ -2131,7 +2174,7 @@
     const EventListItem &eli=*static_cast<const EventListItem*>(item);
     switch (eli.geteventtype()) {
       case EventListItem::start:
-	if (startpic<0 || (settings().start_bof && startpic==0 && !realzero)) {
+	if (startpic<0 || (start_bof && startpic==0 && !realzero)) {
           startpic=eli.getpicture();
           startpts=eli.getpts();
           if (startpic==0)
@@ -2164,7 +2207,7 @@
     }
 
   // last item in list was a (real or virtual) START
-  if (settings().stop_eof && startpic>=0) {
+  if (stop_eof && startpic>=0) {
     // create a new export range by adding a virtual STOP marker at EOF 
     stoppic=pictures-1;
     stoppts=(*mpg)[stoppic].getpts()-firstpts;
diff -Naur svn/src/dvbcut.h r109-exportAR/src/dvbcut.h
--- svn/src/dvbcut.h	2007-12-08 12:11:13.000000000 +0100
+++ r109-exportAR/src/dvbcut.h	2007-12-12 16:04:24.000000000 +0100
@@ -72,7 +72,7 @@
   quick_picture_lookup_t quick_picture_lookup;
   std::list<pts_t> chapterlist;
 
-  QPopupMenu *audiotrackpopup,*recentfilespopup;
+  QPopupMenu *audiotrackpopup,*recentfilespopup,*editconvertpopup;
   int audiotrackmenuid;
   inbuffer buf;
   mpgfile *mpg;
@@ -98,6 +98,8 @@
   int currentaudiotrack;
   bool nogui;
   int exportformat; 
+  bool start_bof; 
+  bool stop_eof; 
 
 protected:
   //   QPixmap getpixmap(int picture, bool allgop=false);
@@ -133,9 +135,9 @@
             std::string idxfilename=std::string(), std::string expfilename=std::string());
   void setbusy(bool b=true);
   void batchmode(bool b=true) { nogui = b; }
-  void setexportformat(int ef=0) { exportformat = ef; }
+  void exportoptions(int format=0, bool bof=true, bool eof=true) { exportformat = format; start_bof=bof; stop_eof=eof; }
   // static dvbcut *New(std::string filename=std::string(), std::string idxfilename=std::string());
-  void addStartStopItems(std::vector<int>);
+  void addStartStopItems(std::vector<int>, int option=0);
   int getTimePerFrame() { return timeperframe>0 && timeperframe<5000 ? timeperframe : 3003; };
 
 public slots:
@@ -153,7 +155,8 @@
   virtual void editStart();
   virtual void editSuggest();
   virtual void editImport();
-  virtual void editConvert();
+  virtual void editConvert(int);
+  virtual void abouttoshoweditconvert();
   virtual void viewDifference();
   virtual void viewUnscaled();
   virtual void viewNormal();
diff -Naur svn/src/main.cpp r109-exportAR/src/main.cpp
--- svn/src/main.cpp	2007-12-08 12:11:13.000000000 +0100
+++ r109-exportAR/src/main.cpp	2007-12-12 18:57:36.000000000 +0100
@@ -54,21 +54,24 @@
   fprintf(stderr,
     "Usage ("VERSION_STRING"):\n"
     "  %s -generateidx [-idx <idxfilename>] [<mpgfilename> ...]\n"
-    "  %s -batch [-cut AR|TS|<list>] [-exp <expfilename>] [-format <num>] <prjfilename> | <mpgfilename> ...\n\n",
+    "  %s -batch [ OPTIONS ] <prjfilename> | <mpgfilename> ...\n\n"
+    "OPTIONS: -cut 4:3|16:9|TS|TS2|<list>, -exp <expfilename>,\n"
+    "         -format <num>, -automarker <num>\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 numbers / time stamps (use ',-|;' as separators).\n" 
+    "In batch mode you can use `-cut' to keep only 4:3 resp. 16:9 frames or\n"
+    "create automatically alternating START/STOP cut markers for the bookmarks\n"
+    "imported from the input transport stream (TS, TS2) or for a given list of\n"
+    "frame numbers / time stamps (you can use any of ',-|;' as separators).\n" 
     "Without any (valid) cut markers the whole file will be converted!\n\n");
   fprintf(stderr,
     "The -exp switch specifies the name of the exported file, with -format\n"
-    "the default export format (0=MPEG program stream/DVD) can be canged.\n\n");
+    "the default export format (0=MPEG program stream/DVD) can be changed and\n"
+    "-automarker sets START/STOP markers at BOF/EOF (0=none,1=BOF,2=EOF,3=both).\n\n");
   fprintf(stderr,
     "Options may be abbreviated as long as they remain unambiguous.\n\n");
   exit(rv);
@@ -78,7 +81,7 @@
 main(int argc, char *argv[]) {
   argv0=argv[0];
   bool generateidx=false;
-  bool batchmode=false;
+  bool batchmode=false, start_bof=true, stop_eof=true;
   int exportformat=0;
   std::string idxfilename, expfilename;
   std::vector<std::string> cutlist;
@@ -91,7 +94,7 @@
    * process arguments
    */
   for (i = 1; i < argc; ++i) {
-    if (argv[i][0] == '-') {
+    if (argv[i][0] == '-' || argv[i][0] == '+') {
       // process switches / options
       size_t n = strlen(argv[i]);
       if (n == 2 && argv[i][1] == '-') {	// POSIX argument separator
@@ -108,7 +111,11 @@
         expfilename = argv[i];
       else if (strncmp(argv[i], "-format", n) == 0 && ++i < argc)
         exportformat = atoi(argv[i]);
-      else if (strncmp(argv[i], "-cut", n) == 0 && ++i < argc) {
+      else if (strncmp(argv[i], "-automarker", n) == 0 && ++i < argc) {
+        int bofeof = atoi(argv[i]);
+        start_bof = (bofeof&1)==1;
+        stop_eof  = (bofeof&2)==2;
+      } else if (strncmp(argv[i], "-cut", n) == 0 && ++i < argc) {
         char *pch = strtok(argv[i],",-|;");
         while(pch) {
           if(strlen(pch))
@@ -200,19 +207,28 @@
   int rv=1;
   dvbcut *main=new dvbcut;
   main->batchmode(batchmode);
-  main->setexportformat(exportformat);
+  main->exportoptions(exportformat,start_bof,stop_eof);
 
   if (batchmode) {
     if (filenames.empty())	// must provide at least one filename
       usage_exit();
     main->open(filenames,idxfilename,expfilename);
     if(!cutlist.empty()) {
-      if(cutlist.front()=="AR") {
+      if(cutlist.front()=="AR") {  // obsolete (use 4:3 resp. 16:9 instead)! Or just in case of another AR... 
           main->editSuggest();
-          main->editConvert();             
-      } else if(cutlist.front()=="TS") {
+          main->editConvert(0);             
+      } else if(cutlist.front()=="4:3") {
+          main->editSuggest();     
+          main->editConvert(2);             
+      } else if(cutlist.front()=="16:9") {
+          main->editSuggest();     
+          main->editConvert(3);             
+      } else if(cutlist.front()=="TS" || cutlist.front()=="TS1") {  // first bookmark is a START
           main->editImport();     
-          main->editConvert();             
+          main->editConvert(0);             
+      } else if(cutlist.front()=="TS2") { // 2nd bookmark is a START
+          main->editImport();     
+          main->editConvert(1);             
       } else { 
           std::vector<int> piclist, prob_item, prob_pos;
           unsigned int pos, j;
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
DVBCUT-user mailing list
DVBCUT-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dvbcut-user

Reply via email to