summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2010-01-02 14:02:48 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2010-01-02 14:02:48 +0100
commitb5edaaa7ccb55ae13f197be2b40c8de460233fd4 (patch)
tree1a6f3d053256becd8f05286ca862afccf2b3b753
parent0faae7c3f04abc13049b1a526a3d05a36e28d014 (diff)
downloadvdr-b5edaaa7ccb55ae13f197be2b40c8de460233fd4.tar.gz
vdr-b5edaaa7ccb55ae13f197be2b40c8de460233fd4.tar.bz2
Implemented --edit and --genindex options
-rw-r--r--CONTRIBUTORS2
-rw-r--r--HISTORY3
-rw-r--r--cutter.c30
-rw-r--r--cutter.h4
-rw-r--r--recording.c33
-rw-r--r--recording.h4
-rw-r--r--vdr.118
-rw-r--r--vdr.c12
8 files changed, 98 insertions, 8 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 8844db86..872f6d23 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -600,6 +600,8 @@ Helmut Auer <vdr@helmutauer.de>
for suggesting to improve logging system time changes to avoid problems on slow
systems under heavy load
for making the SVDRP command PUTE support reading the EPG data from a given file
+ for a patch that was used to implement the command line options --edit and
+ --genindex
Jeremy Hall <jhall@UU.NET>
for fixing an incomplete initialization of the filter parameters in eit.c
diff --git a/HISTORY b/HISTORY
index f83de336..68bf671c 100644
--- a/HISTORY
+++ b/HISTORY
@@ -6249,3 +6249,6 @@ Video Disk Recorder Revision History
its base class.
- Fixed compiler warnings "format not a string literal and no format arguments"
in some syslog calls (thanks to Rolf Ahrenberg).
+- The new command line options --edit and --genindex can be used to edit a
+ recording or generate its index without actually starting the entire VDR
+ (based on a patch from Helmut Auer).
diff --git a/cutter.c b/cutter.c
index e83c5ac1..ff6b4edb 100644
--- a/cutter.c
+++ b/cutter.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: cutter.c 2.3 2009/04/19 10:56:33 kls Exp $
+ * $Id: cutter.c 2.4 2010/01/02 13:08:08 kls Exp $
*/
#include "cutter.h"
@@ -274,3 +274,31 @@ bool cCutter::Ended(void)
ended = false;
return result;
}
+
+#define CUTTINGCHECKINTERVAL 500 // ms between checks for the active cutting process
+
+bool CutRecording(const char *FileName)
+{
+ if (DirectoryOk(FileName)) {
+ cRecording Recording(FileName);
+ if (Recording.Name()) {
+ cMarks Marks;
+ if (Marks.Load(FileName, Recording.FramesPerSecond(), Recording.IsPesRecording()) && Marks.Count()) {
+ if (cCutter::Start(FileName)) {
+ while (cCutter::Active())
+ cCondWait::SleepMs(CUTTINGCHECKINTERVAL);
+ return true;
+ }
+ else
+ fprintf(stderr, "can't start editing process\n");
+ }
+ else
+ fprintf(stderr, "'%s' has no editing marks\n", FileName);
+ }
+ else
+ fprintf(stderr, "'%s' is not a recording\n", FileName);
+ }
+ else
+ fprintf(stderr, "'%s' is not a directory\n", FileName);
+ return false;
+}
diff --git a/cutter.h b/cutter.h
index 8275281f..afc5e935 100644
--- a/cutter.h
+++ b/cutter.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: cutter.h 1.1 2002/06/22 10:03:15 kls Exp $
+ * $Id: cutter.h 2.1 2010/01/02 12:09:54 kls Exp $
*/
#ifndef __CUTTER_H
@@ -26,4 +26,6 @@ public:
static bool Ended(void);
};
+bool CutRecording(const char *FileName);
+
#endif //__CUTTER_H
diff --git a/recording.c b/recording.c
index 7fdb2244..41ad47aa 100644
--- a/recording.c
+++ b/recording.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: recording.c 2.20 2009/12/06 12:55:36 kls Exp $
+ * $Id: recording.c 2.21 2010/01/02 13:46:05 kls Exp $
*/
#include "recording.h"
@@ -674,7 +674,9 @@ cRecording::cRecording(const char *FileName)
deleted = 0;
titleBuffer = NULL;
sortBuffer = NULL;
- fileName = strdup(FileName);
+ FileName = fileName = strdup(FileName);
+ if (*(fileName + strlen(fileName) - 1) == '/')
+ *(fileName + strlen(fileName) - 1) = 0;
FileName += strlen(VideoDirectory) + 1;
const char *p = strrchr(FileName, '/');
@@ -1751,6 +1753,33 @@ void cIndexFile::Delete(void)
}
}
+bool GenerateIndex(const char *FileName)
+{
+ if (DirectoryOk(FileName)) {
+ cRecording Recording(FileName);
+ if (Recording.Name()) {
+ if (!Recording.IsPesRecording()) {
+ cString IndexFileName = AddDirectory(FileName, INDEXFILESUFFIX);
+ unlink(IndexFileName);
+ cIndexFileGenerator *IndexFileGenerator = new cIndexFileGenerator(FileName);
+ while (IndexFileGenerator->Active())
+ cCondWait::SleepMs(INDEXFILECHECKINTERVAL);
+ if (access(IndexFileName, R_OK) == 0)
+ return true;
+ else
+ fprintf(stderr, "cannot create '%s'\n", *IndexFileName);
+ }
+ else
+ fprintf(stderr, "'%s' is not a TS recording\n", FileName);
+ }
+ else
+ fprintf(stderr, "'%s' is not a recording\n", FileName);
+ }
+ else
+ fprintf(stderr, "'%s' is not a directory\n", FileName);
+ return false;
+}
+
// --- cFileName -------------------------------------------------------------
#define MAXFILESPERRECORDINGPES 255
diff --git a/recording.h b/recording.h
index 6c95a34e..663d66d2 100644
--- a/recording.h
+++ b/recording.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: recording.h 2.11 2009/12/06 12:46:31 kls Exp $
+ * $Id: recording.h 2.12 2010/01/02 12:10:07 kls Exp $
*/
#ifndef __RECORDING_H
@@ -285,4 +285,6 @@ char *ExchangeChars(char *s, bool ToFileSystem);
// be modified and may be reallocated if more space is needed. The return
// value points to the resulting string, which may be different from s.
+bool GenerateIndex(const char *FileName);
+
#endif //__RECORDING_H
diff --git a/vdr.1 b/vdr.1
index 97780dd5..9bd1f0e7 100644
--- a/vdr.1
+++ b/vdr.1
@@ -8,7 +8,7 @@
.\" License as specified in the file COPYING that comes with the
.\" vdr distribution.
.\"
-.\" $Id: vdr.1 2.3 2009/10/18 14:09:03 kls Exp $
+.\" $Id: vdr.1 2.4 2010/01/02 12:08:40 kls Exp $
.\"
.TH vdr 1 "10 Feb 2008" "1.6" "Video Disk Recorder"
.SH NAME
@@ -54,6 +54,11 @@ Run in daemon mode (implies \-\-no\-kbd).
Use only the given DVB device (\fInum\fR = 0, 1, 2...).
There may be several \fB\-D\fR options (by default all DVB devices will be used).
.TP
+.BI \-\-edit= rec
+Edit the given recording.
+\fIrec\fR must be the full path name of an existing recording.
+The program will return immediately after editing the recording.
+.TP
.BI \-E\ file ,\ \-\-epgfile= file
Write the EPG data into the given \fIfile\fR
(default is \fI/video/epg.data\fR).
@@ -61,6 +66,17 @@ Use \fB\-E\-\fR to disable this.
If \fIfile\fR is a directory, the file \fIepg.data\fR
will be created in that directory.
.TP
+.BI \-\-genindex= rec
+Generate the index file for the given recording.
+\fIrec\fR must be the full path name of an existing recording.
+The recording must be in TS format.
+If the recording already has an index file, it will be deleted
+before creating the new one.
+The program will return immediately after generating the index.
+Note that using this option while another instance of VDR is
+currently replaying the given recording, or if the recording
+has not been finished yet, may lead to unexpected results.
+.TP
.BI \-g,\ \-\-grab= dir
Write images from the SVDRP command GRAB into the
given directory \fIdir\fR. \fIdir\fR must be the full path name of an
diff --git a/vdr.c b/vdr.c
index 7b8bc590..e1bfc16a 100644
--- a/vdr.c
+++ b/vdr.c
@@ -22,7 +22,7 @@
*
* The project's page is at http://www.tvdr.de
*
- * $Id: vdr.c 2.13 2009/12/06 12:20:43 kls Exp $
+ * $Id: vdr.c 2.14 2010/01/02 11:52:40 kls Exp $
*/
#include <getopt.h>
@@ -220,7 +220,9 @@ int main(int argc, char *argv[])
{ "config", required_argument, NULL, 'c' },
{ "daemon", no_argument, NULL, 'd' },
{ "device", required_argument, NULL, 'D' },
+ { "edit", required_argument, NULL, 'e' | 0x100 },
{ "epgfile", required_argument, NULL, 'E' },
+ { "genindex", required_argument, NULL, 'g' | 0x100 },
{ "grab", required_argument, NULL, 'g' },
{ "help", no_argument, NULL, 'h' },
{ "instance", required_argument, NULL, 'i' },
@@ -246,7 +248,7 @@ int main(int argc, char *argv[])
};
int c;
- while ((c = getopt_long(argc, argv, "a:c:dD:E:g:hi:l:L:mp:P:r:s:t:u:v:Vw:", long_options, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "a:c:dD:e:E:g:hi:l:L:mp:P:r:s:t:u:v:Vw:", long_options, NULL)) != -1) {
switch (c) {
case 'a': AudioCommand = optarg;
break;
@@ -263,8 +265,12 @@ int main(int argc, char *argv[])
fprintf(stderr, "vdr: invalid DVB device number: %s\n", optarg);
return 2;
break;
+ case 'e' | 0x100:
+ return CutRecording(optarg) ? 0 : 2;
case 'E': EpgDataFileName = (*optarg != '-' ? optarg : NULL);
break;
+ case 'g' | 0x100:
+ return GenerateIndex(optarg) ? 0 : 2;
case 'g': cSVDRP::SetGrabImageDir(*optarg != '-' ? optarg : NULL);
break;
case 'h': DisplayHelp = true;
@@ -406,11 +412,13 @@ int main(int argc, char *argv[])
" -D NUM, --device=NUM use only the given DVB device (NUM = 0, 1, 2...)\n"
" there may be several -D options (default: all DVB\n"
" devices will be used)\n"
+ " --edit=REC cut recording REC and exit\n"
" -E FILE, --epgfile=FILE write the EPG data into the given FILE (default is\n"
" '%s' in the video directory)\n"
" '-E-' disables this\n"
" if FILE is a directory, the default EPG file will be\n"
" created in that directory\n"
+ " --genindex=REC generate index for recording REC and exit\n"
" -g DIR, --grab=DIR write images from the SVDRP command GRAB into the\n"
" given DIR; DIR must be the full path name of an\n"
" existing directory, without any \"..\", double '/'\n"