Mailing List archive

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

[vdr] Re: Good tool for channels.conf



Luca Merega wrote:
> 
> I am looking for a tool (linux or windows) to generate, modify and work
> on channels.conf file.
> Perhaps a tool to convert between DVB format and VDR format...

You mean the DVB format generated by the linux mmtools for DVB2000?

I am using mmlink to read channel data after a channel scan from my
D-Box and I convert them to channels.conf format using the tiny
program below.

I believe that there are many tools (mostly on Windows) that generate
this format. It is also available on the dxandy page. 


Hmmm. Now that you mention it - with my little program below it might 
even be possible to get data from dxandy and convert it to the 
new channels.conf format. Last time I looked, dxandy was still on 
vdr 0.6 channels.conf format. I have not tried this, though. 
I guess there are several DVB ASCII formats, but it should be easy 
to tweak my little program by changing some of the const's.

Put the source below on file convertmm.cxx and type 
   make convertmm

then execute convertmm with stdin redirected from the existing
DVB ASCII file and stdout redirected to the new channels.conf file.

Carsten.




----------------------------- cut here -----------------------------------
/*  Convert from DVB to channels.conf format.
    Carsten Koch, April 2002.
 */



#include <stdio.h>
#include <string.h>

main(int argc, char **argv)

{
   const int radio = argc > 1;
   
   const int name_start = 0;
   const int name_end = 20;
   const int type1 = 95;
   const int type2 = 96;
   const int video_pid_start = 42;
   const int audio_pid_start = 47;
   const int ac3_pid_start = 72;
   const int tt_pid_start = 62;
   const int pnr_start = 103;
   const int hv = 40;
   const int freq_start = 21;
   const int sym_start = 27;
   
   while(1)
   {
      char line[1024];
      char name[25];
      int last_non_blank = 0, name_index = 0, line_index;
      gets(line);
      if (feof(stdin)) break;
      size_t length = strlen(line);
      while ((length > 0) && (line[length-1] <= ' ')) length--;
      for (line_index = name_start; (line_index <= name_end) && (line_index < length); line_index++)   
      {                                                                                
         char ch = line[line_index];                                                   
         if ((ch != '[') && (ch != ']') && (ch >= ' '))
         {                                                                             
            if (ch != ' ') last_non_blank = name_index;                                
            if (ch == ':') ch = '|';                                                   
            name[name_index++] = ch;                                                   
         }                                                 
      }  
      name[last_non_blank+1] = 0;                                                                                
      if ((line[0] == '-') && (line[1] == '>'))  // a marker
      {
         if (radio)
            printf(":%s Radio\n", name);
         else
            printf(":%s\n", name);
      }
      else if ((line[type1] == '0') && (line[type2] == (radio + '1'))) // normal entry
      {
         int video_pid, audio_pid, ac3_pid, tt_pid, pnr;
         sscanf(line+video_pid_start, "%x", &video_pid);
         sscanf(line+audio_pid_start, "%x", &audio_pid);
         sscanf(line+ac3_pid_start, "%x", &ac3_pid);
         sscanf(line+tt_pid_start, "%x", &tt_pid);
         sscanf(line+pnr_start, "%x", &pnr);
         if (((video_pid != 0x1FFF) || radio) && (audio_pid != 0x1FFF))
         {
            printf("%s:%.5s:%c:0:%.5s:%d:%d", name, line+freq_start, line[hv], line+sym_start, radio? 0 : video_pid, audio_pid);
            if ((ac3_pid != 0x1FFF) && (ac3_pid != 0xFF1F))
               printf(";%d", ac3_pid);
            printf(":%d:0:%d\n", tt_pid == 0x1FFF? 0 : tt_pid, pnr);
         }
      }
   }
}
----------------------------- cut here -----------------------------------




Home | Main Index | Thread Index