Jump to content


Structure of epg.dat file.

EPG database export

  • Please log in to reply
2 replies to this topic

#1 szaro

  • Member
  • 6 posts


Posted 25 September 2015 - 21:13

Hi all,
I'm looking for information about structure of epg.dat file stored on Enigma2.
I need to extract from epg.dat information about program to HTML.
Does anyone know something about how is the type of epg.dat file (type I mean SQLite or other DB file) and how to read epg.dat?

Re: Structure of epg.dat file. #2 WanWizard

  • Forum Moderator
    PLi® Core member
  • 52,487 posts


Posted 25 September 2015 - 21:57

The file has a custom format that requires parsing, it's not a standad file type.


A simple search on the codebase like https://github.com/O...tf8=✓&q=epg.dat will show you the eEPGCache::load() method in /lib/dvb/epgcache.cpp that takes care of loading the file when Enigma2 starts.


Alternatively look for the source of CrossEPG, I believe that can read the epg.dat file too.

Currently in use: VU+Duo 4K (2xFBC S2), Amiko Viper T2C (T2), Octagon SF8008 (S2+T2), SAB Alpha Triple HD (S2+T2), Zgemma H9.2H (T2+fallback)

Many answers to your question can be found in our new and improved wiki.

note: I do not provide support via PM !


Re: Structure of epg.dat file. #3 szaro

  • Member
  • 6 posts


Posted 28 September 2015 - 22:33

Thanks for good idea:), I tried to write simple app for parse epg.dat file, but I stop on "eventData::load(FILE *f)" event data are not correctly read. For now I can only read - TSID, SID, NID, EventID, StartTime, Duration. 
Someone can help me?
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include "timex.h"
using namespace std;

struct eventData
	uint8_t rawEITdata[10];
	uint8_t n_crc;
	uint8_t type;
	static uint8_t data[];

	int getEventID() const
		return (rawEITdata[0] << 8) | rawEITdata[1];
	time_t getStartTime() const
		return parseDVBtime(&rawEITdata[2]);
	int getDuration() const
		return fromBCD(rawEITdata[7])*3600+fromBCD(rawEITdata[8])*60+fromBCD(rawEITdata[9]);

struct DescriptorPair
	int reference_count;
	uint8_t* data;

    DescriptorPair() {}
	DescriptorPair(int c, uint8_t* d): reference_count(c), data(d) {}

int main()
FILE *f;

f = fopen("epg.dat", "rb");
if (f == NULL)
        printf("File not found.\n");
        printf("File opened!.\n");
int size=0,cnt=0;
unsigned int magic=0;
fread( &magic, sizeof(int), 1, f);
if (magic != 0x98765432)
        printf("[eEPGCache] epg file has incorrect byte order.. dont read it");
        return 0;
char text1[13];
fread( text1, 13, 1, f);

if ( !memcmp( text1, "ENIGMA_EPG_V7", 13) )
			printf("OK - ENIGMA EPG\n",text1);
			fread( &size, sizeof(int), 1, f);
                int size = 0;
                int nid = 0;
                int tsid = 0;
                int sid = 0;

                fread(&sid, sizeof(int), 1, f);
                fread(&nid, sizeof(int), 1, f);
                fread(&tsid, sizeof(int), 1, f);
                fread(&size, sizeof(int), 1, f);

                printf("NID: %d, TSID: %d, SID: %d, Titles count: %d . \n",nid,tsid,sid,size);

                        uint8_t len= 0 ;
                        uint8_t type= 0 ;
                        uint8_t text[128];
                        int event = 0;
                        eventData eventt;

                        fread(&type, sizeof(uint8_t), 1, f);
                        fread(&len, sizeof(uint8_t), 1, f);

                        event = (len-10) / sizeof(uint32_t);

                        printf("SID: %d ,Event ID: %d, Start time : %d, Duration : %d . \n",sid,eventt.getEventID(),eventt.getStartTime(),eventt.getDuration()/60);

                            fread(&text,sizeof(uint32_t), event,f);
                            //printf(" %s \n ",text);
                        //printf("Type: %d, len: %d.\n",type,len);


//  eventData::load(FILE *f)
                int size  = 0;
                int id = 0;
                int ref = 0 ;
                DescriptorPair  p;
                uint8_t header[2],buf[256];

                printf(" size = %d",size);
                    fread(&id , sizeof(uint32_t), 1, f);
                    fread(&p.reference_count, sizeof(int), 1, f);
                    fread(header, 2, 1, f);

                    int bytes = header[1]+2;

                    p.data  = new uint8_t[bytes];
                    p.data[0] = header[0];
                    p.data[1] = header[1];

                    fread(p.data+2, bytes-2,1,f);


                    printf("h[0] = %d, h[1] = %d, ref= %d, id=%d ,data= %s \n",header[0],header[1],p.reference_count,id, p.data);
    printf("Total ch: %d\n",cnt);
    return 0;


Also tagged with one or more of these keywords: EPG, database, export

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users