Hi,

today I wanted to convert some TS to PS (without cuttting) and missed again 
that I can't do that with dvbcut without knowing the total number of frames 
(and that I have to write a project file for this simple job). 

Therefore I added a few lines to fileExport().... patch file appended!

I know it's not a perfect solution since the last frame is still/always 
missing, but it's better than nothing.... also with the batch/project file 
method implemented at the moment the last frame would be missing... 
as well as with the GUI! So that's a different problem...

The good thing is that now no more project file is needed, since if no 
START/STOP markers are known to dvbcut everything (except the last frame) 
will be exported! 

Of course, one also could use a inputfile without markers now... 
for instance to give the path to the index file or to supply multiple 
filenames or to specify the location of the export file (a patch Sven 
hopefully will commit soon... would be nice if he also could add a -expfile 
CLI switch... ;-))

ciao
Ralph

PS: Michael don't worry about the large diff file... I had to reformat 
dvbcut.cpp a bit since the indentation was not correct.... at least 
confusing! And I also hate tab characters in source code... ;-)

PSPS: BTW, what about the $Id$ keywords? Always have to edit
the setCaption call... ;-)
diff -Naur svn/src/dvbcut.cpp mysvn55/src/dvbcut.cpp
--- svn/src/dvbcut.cpp	2007-07-06 23:30:10.000000000 +0200
+++ mysvn55/src/dvbcut.cpp	2007-07-09 18:18:55.000000000 +0200
@@ -376,7 +376,7 @@
   // starting export, switch source to sequential mode
   buf.setsequential(true);
 
-  int startpic=-1;
+  int startpic=-1, stoppic=-1;
   int totalpics=0;
 
   for(QListBoxItem *lbi=eventlist->firstItem();lbi;lbi=lbi->next())
@@ -390,7 +390,7 @@
         break;
       case EventListItem::stop:
         if (startpic>=0) {
-          int stoppic=eli.getpicture();
+          stoppic=eli.getpicture();
           totalpics+=stoppic-startpic;
           startpic=-1;
         }
@@ -400,13 +400,15 @@
     }
     }
 
-    int savedpic=0;
-    long long savedtime=0;
-    pts_t startpts=0;
-    std::list<pts_t> chapterlist;
-    chapterlist.push_back(0);
-    startpic=-1;
+  int savedpic=0;
+  long long savedtime=0;
+  pts_t startpts=0, stoppts=0;
+  std::list<pts_t> chapterlist;
+  chapterlist.push_back(0);
+  startpic=-1;
 
+  if(totalpics>0) {
+    // at least one START/STOP marker pair was found!
     for(QListBoxItem *lbi=eventlist->firstItem();lbi && (nogui || !prgwin->cancelled());lbi=lbi->next())
       if (lbi->rtti()==EventListItem::RTTI()) {
       EventListItem &eli=(EventListItem&)*lbi;
@@ -420,11 +422,14 @@
           break;
         case EventListItem::stop:
           if (startpic>=0) {
-            int stoppic=eli.getpicture();
-            pts_t stoppts=(*mpg)[stoppic].getpts();
+            stoppic=eli.getpicture();
+            stoppts=(*mpg)[stoppic].getpts();
             if (!nogui)
 	      prgwin->printheading("Exporting %d pictures: %s .. %s",
 				  stoppic-startpic,ptsstring(startpts-firstpts).c_str(),ptsstring(stoppts-firstpts).c_str());
+            else
+	      fprintf(stderr,"Exporting %d pictures: %s .. %s\n",
+				  stoppic-startpic,ptsstring(startpts-firstpts).c_str(),ptsstring(stoppts-firstpts).c_str());
             mpg->savempg(*mux,startpic,stoppic,savedpic,totalpics,prgwin);
             savedpic+=stoppic-startpic;
             savedtime+=stoppts-startpts;
@@ -443,66 +448,89 @@
       }
 
       }
+  }
+  else if(nogui) {
+      // batch-convertion with no START/STOP pair given at all! 
+      startpic=0; 
+      startpts=(*mpg)[startpic].getpts();   
+      // last picture is missing! ==> Indexer has to add a (invisible) dummy frame at the end... 
+      stoppic=pictures-1;
+      stoppts=(*mpg)[stoppic].getpts();
+      savedpic=0;
+      totalpics=stoppic-startpic;
+      fprintf(stderr,"Exporting %d pictures: %s .. %s\n",
+                     stoppic-startpic,ptsstring(startpts-firstpts).c_str(),ptsstring(stoppts-firstpts).c_str());
+      mpg->savempg(*mux,startpic,stoppic,savedpic,totalpics,prgwin);
+      savedpic=stoppic-startpic;
+      savedtime=stoppts-startpts;
+  }
 
-      mux.reset();
+  mux.reset();
 
-      if (!nogui)
-	prgwin->printheading("Saved %d pictures (%02d:%02d:%02d.%03d)",savedpic,
+  if (!nogui)
+      prgwin->printheading("Saved %d pictures (%02d:%02d:%02d.%03d)",savedpic,
+                          int(savedtime/(3600*90000)),
+                          int(savedtime/(60*90000))%60,
+                          int(savedtime/90000)%60,
+                          int(savedtime/90)%1000	);
+  else
+      fprintf(stderr,"Saved %d pictures (%02d:%02d:%02d.%03d)\n",savedpic,
                           int(savedtime/(3600*90000)),
                           int(savedtime/(60*90000))%60,
                           int(savedtime/90000)%60,
                           int(savedtime/90)%1000	);
 
-      std::string chapterstring;
-      if (!chapterlist.empty()) {
-        int nchar=0;
-        char chapter[16];
-        if (!nogui)
-	  prgwin->printheading("\nChapterlist:");
-        pts_t lastch=-1;
-        for(std::list<pts_t>::const_iterator it=chapterlist.begin();
-            it!=chapterlist.end();++it)
-          if (*it != lastch) {
-          lastch=*it;
+  std::string chapterstring;
+  if (!chapterlist.empty()) {
+    int nchar=0;
+    char chapter[16];
+    if (!nogui)
+      prgwin->printheading("\nChapterlist:");
+    pts_t lastch=-1;
+    for(std::list<pts_t>::const_iterator it=chapterlist.begin();
+        it!=chapterlist.end();++it)
+      if (*it != lastch) {
+        lastch=*it;
         // formatting the chapter string
-          if(nchar>0) {
-            nchar++; 
-            chapterstring+=",";
-          }  
-          nchar+=sprintf(chapter,"%02d:%02d:%02d.%03d",
-                         int(lastch/(3600*90000)),
-                         int(lastch/(60*90000))%60,
-                         int(lastch/90000)%60,
-                         int(lastch/90)%1000	);
+        if(nchar>0) {
+          nchar++; 
+          chapterstring+=",";
+        }  
+        nchar+=sprintf(chapter,"%02d:%02d:%02d.%03d",
+                       int(lastch/(3600*90000)),
+                       int(lastch/(60*90000))%60,
+                       int(lastch/90000)%60,
+                       int(lastch/90)%1000	);
         // normal output as before
-          if (!nogui)
-	    prgwin->print(chapter);
+        if (!nogui)
+	  prgwin->print(chapter);
         // append chapter marks to a comma separated list for dvdauthor xml-file         
-          chapterstring+=chapter;
-          }
+        chapterstring+=chapter;
       }
+  }
+
   // simple dvdauthor xml file with chapter marks
-      std::string filename,destname;
-      if(expfilen.rfind("/")<expfilen.length()) 
-        filename=expfilen.substr(expfilen.rfind("/")+1);
-      else 
-        filename=expfilen;
-      destname=filename.substr(0,filename.rfind("."));
-      if (!nogui) {
-	prgwin->printheading("\nSimple XML-file for dvdauthor with chapter marks:");
-	prgwin->print("<dvdauthor dest=\"%s\">",destname.c_str());
-	prgwin->print("  <vmgm />");
-	prgwin->print("  <titleset>");
-	prgwin->print("    <titles>");
-	prgwin->print("      <pgc>");
-	prgwin->print("        <vob file=\"%s\" chapters=\"%s\" />",filename.c_str(),chapterstring.c_str());
-	prgwin->print("      </pgc>");
-	prgwin->print("    </titles>");
-	prgwin->print("  </titleset>");
-	prgwin->print("</dvdauthor>");
+  std::string filename,destname;
+  if(expfilen.rfind("/")<expfilen.length()) 
+    filename=expfilen.substr(expfilen.rfind("/")+1);
+  else 
+    filename=expfilen;
+  destname=filename.substr(0,filename.rfind("."));
+  if (!nogui) {
+    prgwin->printheading("\nSimple XML-file for dvdauthor with chapter marks:");
+    prgwin->print("<dvdauthor dest=\"%s\">",destname.c_str());
+    prgwin->print("  <vmgm />");
+    prgwin->print("  <titleset>");
+    prgwin->print("    <titles>");
+    prgwin->print("      <pgc>");
+    prgwin->print("        <vob file=\"%s\" chapters=\"%s\" />",filename.c_str(),chapterstring.c_str());
+    prgwin->print("      </pgc>");
+    prgwin->print("    </titles>");
+    prgwin->print("  </titleset>");
+    prgwin->print("</dvdauthor>");
 
-	prgwin->finish();
-      }
+    prgwin->finish();
+  }
   if (!nogui)
     delete prgwin;
 
@@ -1260,6 +1288,7 @@
     std::string errorstring;
     busy.setbusy(true);
     pictures=mpg->loadindex(idxfilename.c_str(),&errorstring);
+    if(nogui && pictures>0) fprintf(stderr,"Loaded index with %d pictures!\n",0,pictures);
     int serrno=errno;
     busy.setbusy(false);
     if (pictures==-1 && serrno!=ENOENT) {
@@ -1292,6 +1321,7 @@
     std::string errorstring;
     busy.setbusy(true);
     pictures=mpg->generateindex(idxfilename.empty()?0:idxfilename.c_str(),&errorstring,&psb);
+    if(nogui && pictures>0) fprintf(stderr,"Generated index with %d pictures!\n",0,pictures);
     busy.setbusy(false);
 
     if (psb.cancelled()) {
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
DVBCUT-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dvbcut-user

Reply via email to