Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Tomaka17's excellent answer gave me a good start toward solving an analogous problem using Qt QIODevice rather than std::istream. I found I needed to blend aspects of Tomaka17's solution, with aspects of the related experience at <a href="http://cdry.wordpress.com/2009/09/09/using-custom-io-callbacks-with-ffmpeg/">http://cdry.wordpress.com/2009/09/09/using-custom-io-callbacks-with-ffmpeg/</a></p> <p>My custom Read function looks like this:</p> <pre><code>int readFunction(void* opaque, uint8_t* buf, int buf_size) { QIODevice* stream = (QIODevice*)opaque; int numBytes = stream-&gt;read((char*)buf, buf_size); return numBytes; } </code></pre> <p>...but I also needed to create a custom Seek function:</p> <pre><code>int64_t seekFunction(void* opaque, int64_t offset, int whence) { if (whence == AVSEEK_SIZE) return -1; // I don't know "size of my handle in bytes" QIODevice* stream = (QIODevice*)opaque; if (stream-&gt;isSequential()) return -1; // cannot seek a sequential stream if (! stream-&gt;seek(offset) ) return -1; return stream-&gt;pos(); } </code></pre> <p>...and I tied it together like this:</p> <pre><code>... const int ioBufferSize = 32768; unsigned char * ioBuffer = (unsigned char *)av_malloc(ioBufferSize + FF_INPUT_BUFFER_PADDING_SIZE); // can get av_free()ed by libav AVIOContext * avioContext = avio_alloc_context(ioBuffer, ioBufferSize, 0, (void*)(&amp;fileStream), &amp;readFunction, NULL, &amp;seekFunction); AVFormatContext * container = avformat_alloc_context(); container-&gt;pb = avioContext; avformat_open_input(&amp;container, "dummyFileName", NULL, NULL); ... </code></pre> <p>Note I have not yet worked out the memory management issues.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload