Mailing List archive

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

[vdr] Re: is it possible to recreate the index



Karlheinz Pischke wrote:
...
> Would you please send the package if you still have it ?

here is what I have:

---------------------------------------------------------------------------
#include <stdio.h>

#define BUFFER_SIZE  1024*128

#define SC_PICTURE   0x00

#define I_FRAME      1
#define P_FRAME      2
#define B_FRAME      3


static FILE* fp;
static FILE* idx;
static int Foffset;

unsigned char buf(int p)
{
   static unsigned char ringbuf[BUFFER_SIZE];

   if ((p >= Foffset) && ( p < (Foffset+BUFFER_SIZE)) )
       {return ringbuf[p-Foffset];}
   Foffset=p;
   if (fseek(fp, p, SEEK_SET)==0)
   {
      fread(ringbuf, 1, BUFFER_SIZE, fp);
      return ringbuf[p-Foffset];
   }
   return 0;
}


int readfile(const unsigned char number)
{ 
   int filesize;
   int c;
   char fname[20];

   sprintf(fname,"%03d.vdr", number);
   fp = fopen(fname, "r");
   if(!fp) { printf("Could not open %s.          \n", fname); return -1;}
   fseek(fp, 0, SEEK_END);
   filesize = ftell(fp);
   printf("\nReading %s, %d bytes.\n", fname, filesize);
   Foffset=filesize;
   for (c=0; c < filesize-32; c++)
      if (buf(c) == 0 && buf(c+1) == 0 && buf(c+2) == 1 && buf(c+3)==SC_PICTURE)
      {
         const char Ptype=(buf(c+5)>>3) & 0x07;
         if ((Ptype == I_FRAME) || (Ptype == P_FRAME) || (Ptype == B_FRAME))
         {
            const char index_entry[8]={c, c>>8, c>>16, c>>24, Ptype, number, 0};
            const int  length = (buf(c+4) << 8) + buf(c+5) + 6;
            
            if (fwrite(index_entry, 1, 8, idx) != 8)
            { printf("Error writing index file\n"); return -1;}
            if (Ptype == I_FRAME)
            {
               printf("I-Frame found at %d\r", c);
               fflush(stdout);
            }
            c+=length;
         }
      }
   fclose(fp);
   return 0;
}

int main()
{
   int c;
   idx = fopen("index.vdr", "w");
   for (c=1; readfile(c)==0; c++) { }
   fclose(idx);
   return 0;
}
---------------------------------------------------------------------------

IIRC this is based on the original version and has some modifications
I made. They improved matters for me, but it is quite possible that
one of the other versions may work better for you. Let me know how
this version works for you. If it is not perfect, I'll try to dig
out one of the other versions or maybe someone who knows more about
MPEG file formats would like to create a "universal" genindex that
works with many different MPEG files?



> Would it be an alternative to use DVB card directly for
> regenerating the index by pumping the mpeg file into one
> (which ?) of the DVB devices and record the output with vdr ?

Good idea!
I do not think that the driver supports this.
But maybe one of the conversion tools that comes with
the driver does.
Check out DVB/apps/mpegtools and see if you can come
up with a shell script that converts what you have into
something that genindex AND vdr like.

Carsten.



Home | Main Index | Thread Index