1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Implemented --edit and --genindex options

This commit is contained in:
Klaus Schmidinger 2010-01-02 14:02:48 +01:00
parent 0faae7c3f0
commit b5edaaa7cc
8 changed files with 98 additions and 8 deletions

View File

@ -600,6 +600,8 @@ Helmut Auer <vdr@helmutauer.de>
for suggesting to improve logging system time changes to avoid problems on slow for suggesting to improve logging system time changes to avoid problems on slow
systems under heavy load systems under heavy load
for making the SVDRP command PUTE support reading the EPG data from a given file 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> Jeremy Hall <jhall@UU.NET>
for fixing an incomplete initialization of the filter parameters in eit.c for fixing an incomplete initialization of the filter parameters in eit.c

View File

@ -6249,3 +6249,6 @@ Video Disk Recorder Revision History
its base class. its base class.
- Fixed compiler warnings "format not a string literal and no format arguments" - Fixed compiler warnings "format not a string literal and no format arguments"
in some syslog calls (thanks to Rolf Ahrenberg). 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).

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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" #include "cutter.h"
@ -274,3 +274,31 @@ bool cCutter::Ended(void)
ended = false; ended = false;
return result; 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;
}

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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 #ifndef __CUTTER_H
@ -26,4 +26,6 @@ public:
static bool Ended(void); static bool Ended(void);
}; };
bool CutRecording(const char *FileName);
#endif //__CUTTER_H #endif //__CUTTER_H

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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" #include "recording.h"
@ -674,7 +674,9 @@ cRecording::cRecording(const char *FileName)
deleted = 0; deleted = 0;
titleBuffer = NULL; titleBuffer = NULL;
sortBuffer = NULL; sortBuffer = NULL;
fileName = strdup(FileName); FileName = fileName = strdup(FileName);
if (*(fileName + strlen(fileName) - 1) == '/')
*(fileName + strlen(fileName) - 1) = 0;
FileName += strlen(VideoDirectory) + 1; FileName += strlen(VideoDirectory) + 1;
const char *p = strrchr(FileName, '/'); 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 ------------------------------------------------------------- // --- cFileName -------------------------------------------------------------
#define MAXFILESPERRECORDINGPES 255 #define MAXFILESPERRECORDINGPES 255

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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 #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 // 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. // value points to the resulting string, which may be different from s.
bool GenerateIndex(const char *FileName);
#endif //__RECORDING_H #endif //__RECORDING_H

18
vdr.1
View File

@ -8,7 +8,7 @@
.\" License as specified in the file COPYING that comes with the .\" License as specified in the file COPYING that comes with the
.\" vdr distribution. .\" 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" .TH vdr 1 "10 Feb 2008" "1.6" "Video Disk Recorder"
.SH NAME .SH NAME
@ -54,6 +54,11 @@ Run in daemon mode (implies \-\-no\-kbd).
Use only the given DVB device (\fInum\fR = 0, 1, 2...). 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). There may be several \fB\-D\fR options (by default all DVB devices will be used).
.TP .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 .BI \-E\ file ,\ \-\-epgfile= file
Write the EPG data into the given \fIfile\fR Write the EPG data into the given \fIfile\fR
(default is \fI/video/epg.data\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 If \fIfile\fR is a directory, the file \fIepg.data\fR
will be created in that directory. will be created in that directory.
.TP .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 .BI \-g,\ \-\-grab= dir
Write images from the SVDRP command GRAB into the Write images from the SVDRP command GRAB into the
given directory \fIdir\fR. \fIdir\fR must be the full path name of an given directory \fIdir\fR. \fIdir\fR must be the full path name of an

12
vdr.c
View File

@ -22,7 +22,7 @@
* *
* The project's page is at http://www.tvdr.de * 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> #include <getopt.h>
@ -220,7 +220,9 @@ int main(int argc, char *argv[])
{ "config", required_argument, NULL, 'c' }, { "config", required_argument, NULL, 'c' },
{ "daemon", no_argument, NULL, 'd' }, { "daemon", no_argument, NULL, 'd' },
{ "device", required_argument, NULL, 'D' }, { "device", required_argument, NULL, 'D' },
{ "edit", required_argument, NULL, 'e' | 0x100 },
{ "epgfile", required_argument, NULL, 'E' }, { "epgfile", required_argument, NULL, 'E' },
{ "genindex", required_argument, NULL, 'g' | 0x100 },
{ "grab", required_argument, NULL, 'g' }, { "grab", required_argument, NULL, 'g' },
{ "help", no_argument, NULL, 'h' }, { "help", no_argument, NULL, 'h' },
{ "instance", required_argument, NULL, 'i' }, { "instance", required_argument, NULL, 'i' },
@ -246,7 +248,7 @@ int main(int argc, char *argv[])
}; };
int c; 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) { switch (c) {
case 'a': AudioCommand = optarg; case 'a': AudioCommand = optarg;
break; break;
@ -263,8 +265,12 @@ int main(int argc, char *argv[])
fprintf(stderr, "vdr: invalid DVB device number: %s\n", optarg); fprintf(stderr, "vdr: invalid DVB device number: %s\n", optarg);
return 2; return 2;
break; break;
case 'e' | 0x100:
return CutRecording(optarg) ? 0 : 2;
case 'E': EpgDataFileName = (*optarg != '-' ? optarg : NULL); case 'E': EpgDataFileName = (*optarg != '-' ? optarg : NULL);
break; break;
case 'g' | 0x100:
return GenerateIndex(optarg) ? 0 : 2;
case 'g': cSVDRP::SetGrabImageDir(*optarg != '-' ? optarg : NULL); case 'g': cSVDRP::SetGrabImageDir(*optarg != '-' ? optarg : NULL);
break; break;
case 'h': DisplayHelp = true; 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" " -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" " there may be several -D options (default: all DVB\n"
" devices will be used)\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" " -E FILE, --epgfile=FILE write the EPG data into the given FILE (default is\n"
" '%s' in the video directory)\n" " '%s' in the video directory)\n"
" '-E-' disables this\n" " '-E-' disables this\n"
" if FILE is a directory, the default EPG file will be\n" " if FILE is a directory, the default EPG file will be\n"
" created in that directory\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" " -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" " given DIR; DIR must be the full path name of an\n"
" existing directory, without any \"..\", double '/'\n" " existing directory, without any \"..\", double '/'\n"