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

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>
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>
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
Oliver Endriss).
- 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
* 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"
@ -270,6 +270,21 @@ bool isnumber(const char *s)
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)
{
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
* 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
@ -205,6 +205,12 @@ bool endswith(const char *s, const char *p);
bool isempty(const char *s);
int numdigits(int n);
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 AddDirectory(const char *DirName, const char *FileName);
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
.\" 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"
.SH NAME
@ -66,6 +66,15 @@ 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 \-\-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
Generate the index file for the given 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
information.
.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
Set the controlling terminal.
.TP

19
vdr.c
View File

@ -22,7 +22,7 @@
*
* 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>
@ -223,6 +223,7 @@ int main(int argc, char *argv[])
{ "device", required_argument, NULL, 'D' },
{ "edit", required_argument, NULL, 'e' | 0x100 },
{ "epgfile", required_argument, NULL, 'E' },
{ "filesize", required_argument, NULL, 'f' | 0x100 },
{ "genindex", required_argument, NULL, 'g' | 0x100 },
{ "grab", required_argument, NULL, 'g' },
{ "help", no_argument, NULL, 'h' },
@ -238,6 +239,7 @@ int main(int argc, char *argv[])
{ "rcu", optional_argument, NULL, 'r' | 0x100 },
{ "record", required_argument, NULL, 'r' },
{ "shutdown", required_argument, NULL, 's' },
{ "split", no_argument, NULL, 's' | 0x100 },
{ "terminal", required_argument, NULL, 't' },
{ "user", required_argument, NULL, 'u' },
{ "userdump", no_argument, NULL, 'u' | 0x100 },
@ -270,6 +272,13 @@ int main(int argc, char *argv[])
return CutRecording(optarg) ? 0 : 2;
case 'E': EpgDataFileName = (*optarg != '-' ? optarg : NULL);
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:
return GenerateIndex(optarg) ? 0 : 2;
case 'g': cSVDRP::SetGrabImageDir(*optarg != '-' ? optarg : NULL);
@ -348,6 +357,9 @@ int main(int argc, char *argv[])
break;
case 's': ShutdownHandler.SetShutdownCommand(optarg);
break;
case 's' | 0x100:
Setup.SplitEditedFiles = 1;
break;
case 't': Terminal = optarg;
if (access(Terminal, R_OK | W_OK) < 0) {
fprintf(stderr, "vdr: can't access terminal: %s\n", Terminal);
@ -419,6 +431,8 @@ int main(int argc, char *argv[])
" '-E-' disables this\n"
" if FILE is a directory, the default EPG file will be\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"
" -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"
@ -445,6 +459,8 @@ int main(int argc, char *argv[])
" (default: %s)\n"
" -r CMD, --record=CMD call CMD before and after a recording\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"
" -u USER, --user=USER run as user USER; only applicable if started as\n"
" root\n"
@ -458,6 +474,7 @@ int main(int argc, char *argv[])
"\n",
DEFAULTCONFDIR,
DEFAULTEPGDATAFILENAME,
MAXVIDEOFILESIZEDEFAULT,
DEFAULTPLUGINDIR,
LIRC_DEVICE,
LOCDIR,