Hi again,
just added some checks/messages concerning the -cut switch!
Also there are now "Convert to..."-entries in the eventlist context menu,...
sometimes it's handy to convert a Stop into a Start marker (and deleting the
others) when cutting episodes of TV series (without commercials inbetween).
The patch form yesterday evening is included...
ciao
Ralph
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 &)</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-25 10:08:21.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()
@@ -948,8 +987,8 @@
return;
if (lbi->rtti()!=EventListItem::RTTI())
return;
- const EventListItem &eli=*static_cast<const EventListItem*>(lbi);
-
+ // is it a problem to have no "const EventListItem &eli=..."? Needed for seteventtype()...!
+ EventListItem &eli=*static_cast<const EventListItem*>(lbi);
QPopupMenu popup(eventlist);
popup.insertItem("Go to",1);
@@ -957,7 +996,11 @@
popup.insertItem("Delete others",3);
popup.insertItem("Delete all",4);
popup.insertItem("Delete all bookmarks",5);
- popup.insertItem("Display difference from this picture",6);
+ popup.insertItem("Convert to start marker",6);
+ popup.insertItem("Convert to stop marker",7);
+ popup.insertItem("Convert to chapter marker",8);
+ popup.insertItem("Convert to bookmark",9);
+ popup.insertItem("Display difference from this picture",10);
QListBox *lb=lbi->listBox();
QListBoxItem *first=lb->firstItem(),*current,*next;
@@ -1005,6 +1048,22 @@
break;
case 6:
+ eli.seteventtype(EventListItem::start);
+ break;
+
+ case 7:
+ eli.seteventtype(EventListItem::stop);
+ break;
+
+ case 8:
+ eli.seteventtype(EventListItem::chapter);
+ break;
+
+ case 9:
+ eli.seteventtype(EventListItem::bookmark);
+ break;
+
+ case 10:
if (imgp)
delete imgp;
imgp=new differenceimageprovider(*mpg,eli.getpicture(),new dvbcutbusy(this),false,viewscalefactor);
@@ -1022,14 +1081,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 +1129,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 +1329,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 +1638,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 +1661,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 +1814,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 +1833,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-25 10:09:43.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 numbers (you can use ',-|;:/' as separators).\n"
+ "Without any (valid) 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,21 @@
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 if(cutlist.size()>1) {
+ // just one entry entry makes no sense and/or can be a typo (atoi() returned 0)!
+ main->addStartStopItems(cutlist);
+ if(cutlist.size()%2)
+ fprintf(stderr,"*** Cut list contained an odd number of entries, discarded last one! ***");
+ } else
+ fprintf(stderr,"*** Problems parsing parameter provided with option `-cut'! ***");
+ }
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