Hi,

Am Mittwoch, 28. November 2007 15:17 schrieb Wolfram Gloger:
> Hi,
>
> First a big thank you for your merging work.
Yes,... from me too!!! :)
And also for correcting my little bugs... ;-)

>
> > * r104 is Wolfram's pipe output patch, with minor modifications. I think
> > it's better to leave stdout and stderr open, just in case dvdauthor
> > wants to print any error messages.
>
> You're right, that's better.  Still better would be to see the output
> in the log window..  I'll look into this. 
Aehh, please no... I would prefer not to have the dvdauthor output in the log 
window... that can be quite a lot! 
Even without this "discontinuity in audio channel"-bug...

BTW,... my version 0.6.14 still shows that messages (if I don't disable the 
warnings)!

> I'll also take a look into 
> adding a checkbox (or similar) for choosing pipe output.

I also played a little bit around with that and added an entry
to the muxerlist which uses a configurable command/label form the 
settings-file (see the attached patch)...

OK,... with this approach I fixed the muxer type to the internal one which is 
not very flexible (= 1. not so nice feature). If you know how to add a 
checkbox "Use Output Pipe" one could also select the ffmpeg muxer or even 
other output formats... that would be better!

The specified command line in the settings understands the placeholders 
%CHAPTER% and %OUTPUT%... the first one will be replaced by the comma 
separated list of chapter time stamps and the later by the file or directory 
name given in the dialog.

Unfortunately this is a FileOpen dialog and so to get a directory for the 
dvdauthor output one has to type it manually ( = 2. not so nice feature).

I also added a check for exists()&isExecutable() of the used command, since 
your patch crashed when not finding the pipe script. Unfortunatley this 
implies now, that one has to give the command/script with full pathname (= 3. 
not so nice feature). Maybe some one knows a solution for checking the $PATH 
for a command drom inside dvbcut (analog to the which command)?

Appart from this, your approach with "|/pathto/my-dvd.sh" given in the file 
input field still works... :)

So,... feel free to adapt/improve my code... I omitted the ChangeLog since I 
don't expect it to be final... ;-)

ciao
Ralph
 
PS: BTW,... I found a bug concerning the chapterlist, which is also fixed in 
this patch! I also can send it separately Michael if you want to include it 
before (just 3-4 lines in the end of dvbcut.cpp resp. in 
quick_picture_lookup_table()... maybe a left over from the old mechanism, 
showing up when START is on picture 0...?).



diff -Naur svn/src/dvbcut.cpp r105-pipeoutput/src/dvbcut.cpp
--- svn/src/dvbcut.cpp	2007-11-28 16:12:51.000000000 +0100
+++ r105-pipeoutput/src/dvbcut.cpp	2007-11-28 20:17:16.000000000 +0100
@@ -510,6 +510,10 @@
   expd->muxercombo->insertItem("MPEG program stream (DVBCUT multiplexer)");
   expd->muxercombo->insertItem("MPEG program stream/DVD (libavformat)");
   expd->muxercombo->insertItem("MPEG transport stream (libavformat)");
+#ifndef __WIN32__
+  if (!settings().pipe_label.isEmpty())
+    expd->muxercombo->insertItem(settings().pipe_label);
+#endif
 
   if (settings().export_format < 0
       || settings().export_format >= expd->muxercombo->count())
@@ -534,12 +538,62 @@
     expd->hide();
   }
 
+  // create usable chapter lists 
+  std::string chapterstring, chaptercolumn;
+  if (!chapterlist.empty()) {
+    int nchar=0;
+    char chapter[16];
+    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+=",";
+          chaptercolumn+="\n";
+        }  
+        nchar+=sprintf(chapter,"%02d:%02d:%02d.%03d",
+                       int(lastch/(3600*90000)),
+                       int(lastch/(60*90000))%60,
+                       int(lastch/90000)%60,
+                       int(lastch/90)%1000	);
+        // append chapter marks to lists for plain text / dvdauthor xml-file         
+        chapterstring+=chapter;
+        chaptercolumn+=chapter;
+      }
+  }
+
   int child_pid = -1;
   int pipe_fds[2];
 
 #ifndef __WIN32__
   // check for piped output
-  if (expfilen[0] == '|') {
+  std::string expcmd;
+  size_t pos;
+  if(settings().export_format==4 && !settings().pipe_command.isEmpty()) {
+    if (settings().pipe_command.find('|')==-1) 
+      expcmd = "|"+std::string(settings().pipe_command.ascii());
+    else 
+      expcmd = std::string(settings().pipe_command.ascii());
+       
+    if ((pos=expcmd.find("%CHAPTERS%"))!=std::string::npos)
+      expcmd.replace(pos,10,chapterstring);  
+    if ((pos=expcmd.find("%OUTPUT%"))!=std::string::npos)
+      expcmd.replace(pos,8,expfilen);  
+  } else 
+    expcmd = expfilen;
+
+  if ((pos=expcmd.find('|'))!=std::string::npos) {
+    pos++;   
+    size_t end=expcmd.find(' ',pos);   
+    if (!QFileInfo(expcmd.substr(pos,end-pos)).exists() ||
+        !QFileInfo(expcmd.substr(pos,end-pos)).isExecutable()) {
+      critical("Command not found/executable - dvbcut","Problems with piped output to:\n"+expcmd.substr(pos,end-pos));
+      return; 
+    }       
+
     if (::pipe(pipe_fds) < 0)
       return;
     child_pid = fork();
@@ -548,11 +602,11 @@
       if (pipe_fds[0] != STDIN_FILENO) {
 	dup2(pipe_fds[0], STDIN_FILENO);
       }
-      //fprintf(stderr, "Executing %s\n", expfilen.c_str()+1);
+      //fprintf(stderr, "Executing %s\n", expcmd.c_str()+pos);
       for (int fd=0; fd<256; ++fd)
 	if (fd != STDIN_FILENO && fd != STDOUT_FILENO && fd != STDERR_FILENO)
 	  ::close(fd);
-      execl("/bin/sh", "sh", "-c", expfilen.c_str()+1, (char *)0);
+      execl("/bin/sh", "sh", "-c", expcmd.c_str()+pos, (char *)0);
       _exit(127);
     }
     ::close(pipe_fds[0]);
@@ -603,6 +657,7 @@
     case 3:
       mux=std::auto_ptr<muxer>(new lavfmuxer("mpegts",audiostreammask,*mpg,out_file.c_str()));
       break;
+    case 4:
     case 0:
     default:
       mux=std::auto_ptr<muxer>(new mpegmuxer(audiostreammask,*mpg,out_file.c_str()));
@@ -662,33 +717,11 @@
 		    int(savedtime/90000)%60,
 		    int(savedtime/90)%1000	);
 
-  std::string chapterstring;
-  if (!chapterlist.empty()) {
-    int nchar=0;
-    char chapter[16];
-    log->print("");
-    log->printheading("Chapter list");
-    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	);
-        // normal output as before
-	log->print(chapter);
-        // append chapter marks to a comma separated list for dvdauthor xml-file         
-        chapterstring+=chapter;
-      }
-  }
+  // print plain list of chapter marks
+  log->print("");
+  log->printheading("Chapter list");
+  log->print(chaptercolumn.c_str());
+
   // simple dvdauthor xml file with chapter marks
   std::string filename,destname;
   if (expfilen.rfind("/")<expfilen.length()) 
@@ -2063,9 +2096,7 @@
         }
         break;
       case EventListItem::chapter:
-	if (startpic<=0)
-	  chapterlist.push_back(outpts);
-	else
+	if (startpic>=0)
 	  chapterlist.push_back(eli.getpts()-startpts+outpts);
 	break;
       default:
diff -Naur svn/src/settings.cpp r105-pipeoutput/src/settings.cpp
--- svn/src/settings.cpp	2007-11-28 16:12:51.000000000 +0100
+++ r105-pipeoutput/src/settings.cpp	2007-11-28 19:21:13.000000000 +0100
@@ -49,6 +49,11 @@
 #define DVBCUT_DEFAULT_BOOKMARK_LABEL \
 	"<font color=\"darkblue\">BOOKMARK</font>"
 
+#define DVBCUT_DEFAULT_PIPE_COMMAND \
+        "|/usr/bin/dvdauthor -t -c '%CHAPTERS%' -v mpeg2 -o %OUTPUT% -"
+#define DVBCUT_DEFAULT_PIPE_LABEL \
+        "DVD-Video titelset (dvdauthor)"
+
 dvbcut_settings::dvbcut_settings() {
   setPath(DVBCUT_QSETTINGS_DOMAIN, DVBCUT_QSETTINGS_PRODUCT);
   beginGroup("/" DVBCUT_QSETTINGS_DOMAIN "/" DVBCUT_QSETTINGS_PRODUCT);
@@ -122,6 +127,10 @@
     snapshot_range = readNumEntry("/range", 0);
     snapshot_samples = readNumEntry("/samples", 1);
   endGroup();	// snapshots
+  beginGroup("/pipe");
+    pipe_command = readEntry("/command", DVBCUT_DEFAULT_PIPE_COMMAND);
+    pipe_label = readEntry("/string", DVBCUT_DEFAULT_PIPE_LABEL);
+  endGroup();	// pipe
 }
 
 void
@@ -176,6 +185,10 @@
     writeEntry("/range", snapshot_range);
     writeEntry("/samples", snapshot_samples);
   endGroup();	// snapshots
+  beginGroup("/pipe");
+    writeEntry("/command", pipe_command);
+    writeEntry("/label", pipe_label);
+  endGroup();	// pipe
 }
 
 // private settings variable
diff -Naur svn/src/settings.h r105-pipeoutput/src/settings.h
--- svn/src/settings.h	2007-11-28 16:12:51.000000000 +0100
+++ r105-pipeoutput/src/settings.h	2007-11-28 17:59:24.000000000 +0100
@@ -75,6 +75,8 @@
   int snapshot_width;
   int snapshot_range;
   int snapshot_samples;
+  QString pipe_command;
+  QString pipe_label;
 
 };
 
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
DVBCUT-user mailing list
DVBCUT-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dvbcut-user

Reply via email to