[Libav-user] Parse raw movie packet data into AVPacket

dream01 at email.it dream01 at email.it
Tue Nov 8 11:36:28 CET 2011


Matthew Einhorn <moiein2000 at ...> writes:

> Have you looked into using custom IO calls like here:
> http://cdry.wordpress.com/2009/09/09/using-custom-io-callbacks-with-ffmpeg/

Thank you very much! It's exactly what I need.
But it works only partially, I mean, I'm able to play the movie file directly
from the buffer but I am not able to seek.

I've implemented the seek function but it doesn't work as expected.
As I seek, the seek callback function is correctly called with 
SEEK_SET as whence but it behaves in a strange way.

I try to explain this clearly:

seek function is called with the required file position to seek to, 
then I seek into my buffer to reach the 
required position and return the new position after seek. 
Remember that my buffer is an exact 1:1 copy byte by byte of 
the entire file, so seeking to a certain position in a file is 
equal to seeking to that position in my buffer.

After seek callback function has returned, it gets called 
once again with SEEK_SET as whence and with a negative offset, 
therefore I am supposed to seek to a negative position in 
my file/buffer. 
This obviously makes seek function to return -1 and therefore
also av_seek_frame returns -1 and this is interpreted as end-of-file.

Where is the mistake?
I don't know if this is important or not, but my buffer is a copy of 
a m2ts file which contains:
video (h264), audio (DTS and AC3) and subtitles (PGS). 
 



More information about the Libav-user mailing list