[FFmpeg-devel] [RFC] Question Regarding Parsing Files with Sections of Unknown Length and No Delimiters

Anamitra Ghorui aghorui at teknik.io
Sun Mar 15 14:40:58 EET 2020


Hello,

I am dealing dealing with a video (gif-like) file format in which there 
are compressed (entropy coded) segments of unknown length. However, the length 
of the uncompressed segment of the file is already known. Please check the 
previous mail by thread if context is required. There are no markers that 
indicate the end of these segments, and these segments are present at the end 
of the file.

One additional problem is that the frames of the video are interleaved, which
means that the parser will have to be provided with the whole pixel data/frame
data at once, and cannot be broken into individual frames.

I have been trying to figure out how to do go about parsing the file, and I
have come up with the following approaches:
1. Decompress the compressed segment in the parser itself, and supply that in
   the output buffer.

2. Keep providing the input buffer of arbitrary length as a packet to the decoder.
   The decoder will decompress the stream and process it accordingly. The decoder 
   will keep an internal buffer. It will return AVERROR(EAGAIN) until the full 
   compressed bitstream has been decoded and AVFrames can be generated.
   
   In this case the parser will not do much aside from finding the start of the
   file stream and returning the buffer.

I think approach 2 will be better in this case because error handling cannot be
done well in the parser. What do you suggest?



More information about the ffmpeg-devel mailing list