[Ffmpeg-devel] Decoding from blocks

Emanuele Fumagalli emanuele.fumagalli
Tue Jan 16 10:48:30 CET 2007


>> thanks, in my case I download sequentially the block so (block1, 
>> block2...)
>> which are all buffer in memory(or saved as files on disk), what I'm 
>> trying
>> to understand is how to start the decoding since I've no full video file
>> but just blocks, do I have to use av_open_input_stream or
>> av_open_input_file?

>1. implement a URLProtocol
>2. register it
>3. use av_open_input_file()
>4. try to read the source code if you have questions
>5. help improving the documentation

Thanks a lot! I implemented my own URLProtocol and now I can intercept all 
the access to file.
I'm still having some difficulties because sometimes I get on my seek a call 
for a
offset=0 and whence=65536 (In this case I just return -1)
followed by another request for
offset=-1 and whence=2

I don't know if my problem is due to the fact that I'm using fopen, fread, 
fseek (I'm on windows) or do I have to do something particular on those seek 
requests?

thanks in advance

Here my code for clarity (for the moment I'm just trying to reproduce 
URLProtocol file_protocol found in file.c, avoiding my blocks)

static FILE *pFile = NULL;

static int my_file_open(URLContext *h, const char *filename, int flags)
{
 pFile=fopen("C:\\a.avi", "rb");
 if(pFile==NULL)
  return -1;
 return 0;
}

static int my_file_read(URLContext *h, unsigned char *buf, int size)
{
 size_t p = fread(buf, 1, size, pFile);
 return p;
}

static int my_file_write(URLContext *h, unsigned char *buf, int size)
{
 return 0;
}

static offset_t my_file_seek(URLContext *h, offset_t pos, int whence)
{
 if(whence < 3)
  return fseek(pFile, pos, whence);
 else
  return -1;
}

static int my_file_close(URLContext *h)
{
 if(pFile)
  return fclose(pFile);
 else
  return 0;
}

URLProtocol my_file_protocol = {
 "test",
 my_file_open,
 my_file_read,
 my_file_write,
 my_file_seek,
 my_file_close,
};







More information about the ffmpeg-devel mailing list