Implemented command line options --filesize and --split

This commit is contained in:
Klaus Schmidinger 2011-08-15 12:45:40 +02:00
parent 9ebdb61995
commit 4a9fd9b097
6 changed files with 61 additions and 4 deletions

View File

@ -2732,6 +2732,7 @@ Dirk Leber <dirk.leber@reel-multimedia.com>
Marco Göbenich <mg@needful.de> Marco Göbenich <mg@needful.de>
for reporting a problem with executing diseqc commands from different threads for reporting a problem with executing diseqc commands from different threads
for suggesting to implement command line option --filesize
Johan Andersson <jna@jna.pp.se> Johan Andersson <jna@jna.pp.se>
for reporting a bug in detecting frames in case the Picture Start Code or Access Unit for reporting a bug in detecting frames in case the Picture Start Code or Access Unit

View File

@ -6691,3 +6691,7 @@ Video Disk Recorder Revision History
- The cutter now sets the 'broken link' flag for MPEG2 TS recordings (thanks to - The cutter now sets the 'broken link' flag for MPEG2 TS recordings (thanks to
Oliver Endriss). Oliver Endriss).
- Fixed language code entry for Portuguese. - Fixed language code entry for Portuguese.
- The new command line options --filesize (suggested by Marco Göbenich) and --split
can be used together with --edit to set the maximum video file size and turn on
splitting edited files at the editing marks. These options must be given before
--edit to have an effect.

17
tools.c
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: tools.c 2.15 2011/07/31 13:19:28 kls Exp $ * $Id: tools.c 2.16 2011/08/15 12:23:20 kls Exp $
*/ */
#include "tools.h" #include "tools.h"
@ -270,6 +270,21 @@ bool isnumber(const char *s)
return true; return true;
} }
int64_t StrToNum(const char *s)
{
char *t = NULL;
int64_t n = strtoll(s, &t, 10);
if (t) {
switch (*t) {
case 'T': n *= 1024;
case 'G': n *= 1024;
case 'M': n *= 1024;
case 'K': n *= 1024;
}
}
return n;
}
cString AddDirectory(const char *DirName, const char *FileName) cString AddDirectory(const char *DirName, const char *FileName)
{ {
return cString::sprintf("%s/%s", DirName && *DirName ? DirName : ".", FileName); return cString::sprintf("%s/%s", DirName && *DirName ? DirName : ".", FileName);

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: tools.h 2.9 2011/08/13 13:36:37 kls Exp $ * $Id: tools.h 2.10 2011/08/15 11:50:02 kls Exp $
*/ */
#ifndef __TOOLS_H #ifndef __TOOLS_H
@ -205,6 +205,12 @@ bool endswith(const char *s, const char *p);
bool isempty(const char *s); bool isempty(const char *s);
int numdigits(int n); int numdigits(int n);
bool isnumber(const char *s); bool isnumber(const char *s);
int64_t StrToNum(const char *s);
///< Converts the given string to a number.
///< The numerical part of the string may be followed by one of the letters
///< K, M, G or T to abbreviate Kilo-, Mega-, Giga- or Terabyte, respectively
///< (based on 1024). Everything after the first non-numeric character is
///< silently ignored, as are any characters other than the ones mentionend here.
cString itoa(int n); cString itoa(int n);
cString AddDirectory(const char *DirName, const char *FileName); cString AddDirectory(const char *DirName, const char *FileName);
bool EntriesOnSameFileSystem(const char *File1, const char *File2); bool EntriesOnSameFileSystem(const char *File1, const char *File2);

16
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.5 2010/04/02 12:22:08 kls Exp $ .\" $Id: vdr.1 2.6 2011/08/15 12:28:54 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
@ -66,6 +66,15 @@ 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 \-\-filesize= size
Limit video files to \fIsize\fR bytes (default is 2000M).
This option is only useful in conjunction with --edit, and must precede that
option to have an effect.
\fIsize\fR is an integer number and may be followed by one of the letters K, M, G or T
to abbreviate Kilo-, Mega-, Giga- or Terabyte, respectively.
The given value is silently limited to the program's internal minimum and
maximum values.
.TP
.BI \-\-genindex= rec .BI \-\-genindex= rec
Generate the index file for the given recording. Generate the index file for the given recording.
\fIrec\fR must be the full path name of an existing recording. \fIrec\fR must be the full path name of an existing recording.
@ -157,6 +166,11 @@ more information.
Call \fIcmd\fR to shutdown the computer. See the file \fIINSTALL\fR for more Call \fIcmd\fR to shutdown the computer. See the file \fIINSTALL\fR for more
information. information.
.TP .TP
.BI \-\-split
Split edited files at the editing marks.
This option is only useful in conjunction with --edit, and must precede that
option to have an effect.
.TP
.BI \-t\ tty ,\ \-\-terminal= tty .BI \-t\ tty ,\ \-\-terminal= tty
Set the controlling terminal. Set the controlling terminal.
.TP .TP

19
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.22 2011/07/31 13:42:53 kls Exp $ * $Id: vdr.c 2.23 2011/08/15 12:42:39 kls Exp $
*/ */
#include <getopt.h> #include <getopt.h>
@ -223,6 +223,7 @@ int main(int argc, char *argv[])
{ "device", required_argument, NULL, 'D' }, { "device", required_argument, NULL, 'D' },
{ "edit", required_argument, NULL, 'e' | 0x100 }, { "edit", required_argument, NULL, 'e' | 0x100 },
{ "epgfile", required_argument, NULL, 'E' }, { "epgfile", required_argument, NULL, 'E' },
{ "filesize", required_argument, NULL, 'f' | 0x100 },
{ "genindex", required_argument, NULL, 'g' | 0x100 }, { "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' },
@ -238,6 +239,7 @@ int main(int argc, char *argv[])
{ "rcu", optional_argument, NULL, 'r' | 0x100 }, { "rcu", optional_argument, NULL, 'r' | 0x100 },
{ "record", required_argument, NULL, 'r' }, { "record", required_argument, NULL, 'r' },
{ "shutdown", required_argument, NULL, 's' }, { "shutdown", required_argument, NULL, 's' },
{ "split", no_argument, NULL, 's' | 0x100 },
{ "terminal", required_argument, NULL, 't' }, { "terminal", required_argument, NULL, 't' },
{ "user", required_argument, NULL, 'u' }, { "user", required_argument, NULL, 'u' },
{ "userdump", no_argument, NULL, 'u' | 0x100 }, { "userdump", no_argument, NULL, 'u' | 0x100 },
@ -270,6 +272,13 @@ int main(int argc, char *argv[])
return CutRecording(optarg) ? 0 : 2; return CutRecording(optarg) ? 0 : 2;
case 'E': EpgDataFileName = (*optarg != '-' ? optarg : NULL); case 'E': EpgDataFileName = (*optarg != '-' ? optarg : NULL);
break; break;
case 'f' | 0x100:
Setup.MaxVideoFileSize = StrToNum(optarg) / MEGABYTE(1);
if (Setup.MaxVideoFileSize < MINVIDEOFILESIZE)
Setup.MaxVideoFileSize = MINVIDEOFILESIZE;
if (Setup.MaxVideoFileSize > MAXVIDEOFILESIZETS)
Setup.MaxVideoFileSize = MAXVIDEOFILESIZETS;
break;
case 'g' | 0x100: case 'g' | 0x100:
return GenerateIndex(optarg) ? 0 : 2; return GenerateIndex(optarg) ? 0 : 2;
case 'g': cSVDRP::SetGrabImageDir(*optarg != '-' ? optarg : NULL); case 'g': cSVDRP::SetGrabImageDir(*optarg != '-' ? optarg : NULL);
@ -348,6 +357,9 @@ int main(int argc, char *argv[])
break; break;
case 's': ShutdownHandler.SetShutdownCommand(optarg); case 's': ShutdownHandler.SetShutdownCommand(optarg);
break; break;
case 's' | 0x100:
Setup.SplitEditedFiles = 1;
break;
case 't': Terminal = optarg; case 't': Terminal = optarg;
if (access(Terminal, R_OK | W_OK) < 0) { if (access(Terminal, R_OK | W_OK) < 0) {
fprintf(stderr, "vdr: can't access terminal: %s\n", Terminal); fprintf(stderr, "vdr: can't access terminal: %s\n", Terminal);
@ -419,6 +431,8 @@ int main(int argc, char *argv[])
" '-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"
" --filesize=SIZE limit video files to SIZE bytes (default is %dM)\n"
" only useful in conjunction with --edit\n"
" --genindex=REC generate index for recording REC and exit\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"
@ -445,6 +459,8 @@ int main(int argc, char *argv[])
" (default: %s)\n" " (default: %s)\n"
" -r CMD, --record=CMD call CMD before and after a recording\n" " -r CMD, --record=CMD call CMD before and after a recording\n"
" -s CMD, --shutdown=CMD call CMD to shutdown the computer\n" " -s CMD, --shutdown=CMD call CMD to shutdown the computer\n"
" --split split edited files at the editing marks (only\n"
" useful in conjunction with --edit)\n"
" -t TTY, --terminal=TTY controlling tty\n" " -t TTY, --terminal=TTY controlling tty\n"
" -u USER, --user=USER run as user USER; only applicable if started as\n" " -u USER, --user=USER run as user USER; only applicable if started as\n"
" root\n" " root\n"
@ -458,6 +474,7 @@ int main(int argc, char *argv[])
"\n", "\n",
DEFAULTCONFDIR, DEFAULTCONFDIR,
DEFAULTEPGDATAFILENAME, DEFAULTEPGDATAFILENAME,
MAXVIDEOFILESIZEDEFAULT,
DEFAULTPLUGINDIR, DEFAULTPLUGINDIR,
LIRC_DEVICE, LIRC_DEVICE,
LOCDIR, LOCDIR,