By doing this, FFmpeg will crash because of a buffer overrun. For a custom IO-Context this is necessary! FFmpeg will otherwise read about 5Mb data from the stream by default to determine the input format. Now you have to tell FFmpeg, which input format it has to use. Note: As you can see, the custom IO-Context can also be used for writing, but this is not explained here. PInStream, // user data will be passed to our callback functionsĠ, // Write callback function (not used in this example)ĪVFormatContext* pCtx = avformat_alloc_context() The fourth parameter (pStream) is a user parameter which will be passed to our callback functionsĪVIOContext* pIOCtx = avio_alloc_context(pBuffer, iBufSize, // internal Buffer and its size IStream-Interface that was already created elsewhere: The two functions ReadFunc and SeekFunc are shown later. The size of the internal buffer is up to you, I decided to provide 32kb for internal buffering. At first we will create the AVIOContext and the AVFormatContext structures. Creating the IO-ContextįFmpeg uses a custom IO-Context, when you allocate the AVFormatContext-structure yourself and provide your own version of AVIOContext but there are several other things to consider. After some hours of experimentation I finally managed to get this working without getting access-violations in FFmpeg functions. I could not find any resource in the internet which offeres a complete and working solution with the current version of FFmpeg explaining how to deal correctly with an IO-Context. Although I used an IStream Object the code can be used for other Streams like std::istream.įFmpeg can only read from files or named pipes easily, but if you want to read directly from memory, from sockets or IStreams you have to provide a custom IO-Context. In this short Article I will explain how to use a custom IO-Context with FFmpeg.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |