Media (Intel® oneAPI Video Processing Library, Intel Media SDK)
Access community support with transcoding, decoding, and encoding in applications using media tools like Intel® oneAPI Video Processing Library and Intel® Media SDK

Frustrated with documentation on MFX Encode



I just lost many hours debugging an issue, which could have been saved by having clearer documentation and samples. In my program I used EncodeFrameAsync just as shown in samples and described in the documentation: "An ENCODE output consists of one frame of a bitstream with the time stamp passed from the input frame." As the output, I got a sequence of steadily increasing bitstream lengths: bs.DataLength starts at ~7kB and increases to ~40kB on 50th frame, even though only about hundred pixels change between consecutive frames (it's a synthetically generated frame sequence). bs.DataOffset was also zero after each SyncOperation.

The video was also corrupted in a strange way (though the frames had some resemblance to the input) during playback with VLC player or Windows players. I based my code on simple_encode_vmem.cpp, i.e., synchronous encoding of one frame at a time, i.e., no async operations in flight.

I found out that the problem was that my program did not set bs.DataLength to 0 after extracting the bitstream for each frame. Nowhere does the documentation mention that mfxBitstream is an input-output argument to MFXVideoENCODE_EncodeFrameAsync, and resetting of this field is "hidden" away in a different file in the tutorials.

So, as I see it, there are two problems:

  1. Documentation is unclear: it implies that the BitStream argument to EncodeFrameAsync pertains only to a single frame.
  2. A possible bug: even though i forgot to set bs.DataLength to zero before calling EncodeFrameAsync, bs.DataLength was increased after SyncOperation, but bs.DataOffset was set to zero!

​I am using the SDK version API level 1.19, installed as "Intel(R)_Media_SDK_2016.0.2​" on a Windows 10 machine. I have also observed the same behavior on Linux.

0 Kudos
0 Replies