[Libav-user] Custom IO-Callback with prepended Header

Christoph Winter mail.christoph.winter at googlemail.com
Sun Oct 30 14:45:41 CET 2011


Hey,

Im writing a program where I have to use custom IO Callbacks because I 
have to play video files with a prepended extra header. However, if I 
try to play a movie with an offset of e.g. 10 bytes and I seek, the 
movie might play on, but audio doesnt:

[h264 @ 0x240afc0] left block unavailable for requested intra mode at 0 17

[h264 @ 0x240afc0] error while decoding MB 0 17

[h264 @ 0x240afc0] AVC: nal size 399

[h264 @ 0x240afc0] concealing 229 DC, 229 AC, 229 MV errors

[h264 @ 0x240afc0] AVC: nal size 25153

[h264 @ 0x240afc0] no frame!

packet didnt contain a complete frame!

[aac @ 0x20220a0] channel element 2.14 is not allocated


This happens sporadic and I cant figure out why. My Seek_Func just calls 
a subclassed QFile::seek(...) which returns QFile::seek(... + offset ). 
Has anybody an Idea why seek often doesnt work? Maybe I am missing a 
parameter when I create my callback? Btw: The format is recognized 
correctly, also without seeking the video is played correctly...

Many thanks,
Christoph Winter

MController.cpp:

    ioContext = avio_alloc_context(buffer, BUFFER_SIZE, 0, fileReader,
    ReadFunc, NULL, SeekFunc);
         ioContext->write_flag  = 0;
         ioContext->is_streamed = 1;
         ioContext->seekable    = 1;


MFile.cpp:

    bool MFile::seek(qint64 offset)
    {
         return QFile::seek(offset+10);
    }

Utils.h:

    int64_t SeekFunc(void *opaque, int64_t offset, int whence)
    {
         qDebug() << "SeekFunc offset=" << offset << " whence=" << whence;
         QIODevice *io = (MFile*)opaque;

         int64_t absolute_pos = 0;

         switch(whence)
         {
         case AVSEEK_SIZE:
             return io->size();
         case SEEK_SET:
             absolute_pos = offset;
             break;
         case SEEK_CUR:
             absolute_pos = io->pos() + offset;
         case SEEK_END:
             absolute_pos = io->size() - offset;
         default:
             return -1;
         }
         if( absolute_pos < 0 || absolute_pos > io->size() )
             return -1;
         bool ret = io->seek(absolute_pos);
         return ret;
    }

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20111030/d898cc56/attachment.html>


More information about the Libav-user mailing list