Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: vdr to anything else



I use a quick and dirty patch to add some hotkeys to the recordings menu. So
I can call up to 9 different scripts to manipulate the recoding (e.g.
converting to MPEG2, DivX etc.). The executed scripts have the names
/dvb/video/video0/recordings_script_1 etc. You have to fix the path for your
environment.

Change the following in menu.c:

======= schnipp =============
eOSState cMenuRecordings::ProcessKey(eKeys Key)
{
  switch (Key) {                                             // RJR
    case k1 ... k9: return ExecuteScript(Key);               // RJR
    default:        break;                                   // RJR
  }                                                          // RJR

  eOSState state = cOsdMenu::ProcessKey(Key);

  if (state == osUnknown) {
     switch (Key) {
       case kOk:
       case kRed:    return Play();
       case kGreen:  return Rewind();
       case kYellow: return Del();
       case kBlue:   return Summary();
       case kMenu:   return osEnd;
       default: break;
       }
     }
  return state;
}
======= schnapp =============

and add the following:

======= schnipp =============
eOSState cMenuRecordings::ExecuteScript(eKeys Key)           // RJR
{
  char msg[256];

  sprintf(msg, "Execute script %d?", Key-k0);

  if (Interface->Confirm(tr(msg))) {
    cMenuRecordingItem *ri = (cMenuRecordingItem *)Get(Current());
    char *cmd_result = NULL;  delete cmd_result;
    char *command = NULL;     delete command;

    command = (char*)malloc( strlen(ri->recording->FileName()) + 12 +
strlen("/dvb/video/video0/recordings_script_n") );
    sprintf(command, "/dvb/video/video0/recordings_script_%d %s", Key-k0,
ri->recording->FileName());

    cmd_result = NULL;
    FILE *p = popen(command, "r");
    if (p) {
      int l = 0;
      int c;
      while ((c = fgetc(p)) != EOF) {
        if (l % 20 == 0)
          cmd_result = (char *)realloc(cmd_result, l + 21);
        cmd_result[l++] = c;
      }
      if (cmd_result)
        cmd_result[l] = 0;
      pclose(p);
    }
    else
      esyslog(LOG_ERR, "ERROR: can't open pipe for command '%s'", command);
  }

  return osContinue;
}

======= schnapp =============

and last change the following lines in menu.h:

======= schnipp =============
class cMenuRecordings : public cOsdMenu {
private:
  cRecordings Recordings;
  eOSState Play(void);
  eOSState Rewind(void);
  eOSState Del(void);
  eOSState Summary(void);
  eOSState ExecuteScript(eKeys Key);                          // RJR
public:
  cMenuRecordings(void);
  virtual eOSState ProcessKey(eKeys Key);
  };
======= schnapp =============

An example for a script:

======= schnipp =============
#!/bin/sh

#  ____________________________
#  VDR recording command script
#
#  Link the current recording to the vdr_converter directory.
#  First check whether the link already exists.
#
#  $Id: recordings_script 0.1 2001/10/09 09:00:00 rjr Exp $

# arg=/dvb/video/video0/filmname/2001-10-06.00.00.50.50.rec

src_dir=$1
src_root=${src_dir:0:${#src_dir}-27}
dest_dir=/usr/tmp/convert/vdr_to_mpeg2
command='ln -s '$src_root' '$dest_dir

logger -i -t recordings_script_1 Scheduling ${src_root} for MPEG2 conversion

${command}
======= schnapp =============

ciao
  Richard



-----Original Message-----
From: vdr-bounce@linuxtv.org [mailto:vdr-bounce@linuxtv.org]On Behalf Of
Tilo Renkl
Sent: Tuesday, December 04, 2001 9:54 PM
To: vdr@linuxtv.org
Subject: [vdr] .vdr to anything else



Hi List.

Today I saw artikles about three skripts that convert .vdr files into Divx
movies direkt after
cutting them.
Great thing so far, but I do not want to convert every recording I cut. :-(

So here is my question:

Can anybody tell me how I can patch the great VDR so that one of the four
color buttons in the
recodings menu (maybe the blue one) calls a skript. (the one to convert the
aktually selekted
movie)
I don't know to much about programming, but I think if Stefan Hueswitt can
program this
superb mp3 and MPlayer patch it can't be impossible.

Tilo




Home | Main Index | Thread Index