How to play a self-definded video file format. (With codes)

This forum is about all development around libVLC.
haiying7
Blank Cone
Blank Cone
Posts: 23
Joined: 24 Jan 2011 09:15
VLC version: vlc 1.1.7
Operating System: Mac OS and Linux
Location: Hong Kong

How to play a self-definded video file format. (With codes)

Postby haiying7 » 25 Mar 2011 10:32

Dear all,

I want to play a video file which contains packet timestamp. In order that VLC can play it, I plan to add some codes to extract the timestamp values and delete them. Then the video format with timestamp is changed to the original and VLC can play it. I decide to modify "/modules/access/file.c" to make VLC to play it. I find the video file is read by VLC according to the p_buffer in FileRead(). The code is following, but VLC neither gets timestamp nor changes video to the original format. Could anybody help me? THX.........

Code: Select all

ssize_t FileRead( access_t *p_access, uint8_t *p_buffer, size_t i_len ) { ... #ifndef WIN32 if (p_access->pf_seek == NoSeek) i_ret = net_Read (p_access, fd, NULL, p_buffer, i_len, false); else #endif i_ret = read (fd, p_buffer, i_len); int TimeValue; int nloop; for (nloop=0; nloop < i_len; nloop++) { // if p_buffer[] = "EULAVEMIT=", it means the following item is time value if(p_buffer[nloop] == "E" && p_buffer[nloop+1] == "U" && p_buffer[nloop+2] == "L" && p_buffer[nloop+3] == "A" && p_buffer[nloop+4] == "V" && p_buffer[nloop+5] == "E" && p_buffer[nloop+6] == "M" && p_buffer[nloop+7] == "I" && p_buffer[nloop+8] == "T" && p_buffer[nloop+9] == "=") { // extract timestamp value int Tj = 0; for(int Ti=2; Ti<=6; Ti++) { // if it is a number, that means it is one of the timestamp if(p_buffer[nloop+Ti] <=9 && p_buffer[nloop+Ti]>=0) { Tj ++; } else { for(int npos=0; npos<=Tj; npos++) { TimeValue += p_buffer[nloop+(Ti-npos)] * pow10(npos); } fprintf(stdout, "TimeValue=%d\n", TimeValue); fflush(stdout); // delete "EULAVEMIT=" and TimeValue in p_buffer. video file is changed to the original format. for(int bufpos=0; bufpos<=Ti; bufpos++) { p_buffer[nloop+bufpos] = p_buffer[nloop+Ti+bufpos]; } break; } } } else { fprintf(stdout, "\n"); fprintf(stdout, "%02x ", p_buffer[nloop]); fflush(stdout); } } fprintf(stdout, "\n"); fflush(stdout); } if( i_ret < 0 ) { switch (errno) ...........

Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 1 guest