KLV encoder / decoder library for STANAG 4609
KLV (Key-Length-Value) is a byte-level data encoding standard used for binary data byte-packing and metadata embedding into video feeds. Data is encoded into Key-Length-Value triplets, where Key identifies the data, Length specifies the data's length, and Value is the data itself. It is defined in SMPTE 336M-2007 (Data Encoding Protocol Using Key-Length Value), approved by the Society of Motion Picture and Television Engineers. KLV encoding protocol defines a data structure which is independent of the application or transportation method used.
KLV encoder C++ library allows seamless integration at the encoding/streaming side, while KLV decoder module ( available also as Direct Show KLV decoder filter or C# module ) may be used at the client side for extraction of encoded data. When used with optional MISB 0601 converter module, KLV decoder translates received data according to the EG0601 standard and provides a list of parsed and converted KLV items with corresponding timing information.
KLV lib and STANAG4609Lib have been specially designed to deal with STANAG 4609 standard and contain numerous helper functions and converters to facilitate LDS and UDS metadata sets creation, Big Endian swap, etc.
STANAG 4609 is intended to provide common methods for exchange of motion imagery across systems within and among NATO nations. It provides a guidance on uncompressed, compressed, and related motion imagery sampling structures; motion imagery time standards, motion imagery metadata standards, interconnections, and common language descriptions of motion imagery system parameters.
Unmanned Air Systems uses two types of KLV encoded metadata. Universal Data Set (UDS) - the 16-byte key, basic encoding rules (BER) formatted length, and data value is appropriate for applications where bandwidth isn't a concern. However, transmitting the 16-byte universal key quickly uses up the available bandwidth. UAS airborne platforms use a wireless communications channel where the bandwidth for metadata is limited. Because of the bandwidth disadvantages of using a Universal Data Set, it is more desirable to use a Local Data Set for transmission over a UAS Datalink. Local Data Set can use a 1, 2 or 4-byte key with a 1, 2, 4-byte, or BER encoded length.
Used in both military and civil applications, the KLV lib allows developers to create applications that receive streaming video coming from UAV platforms, extract the telemetry and other metadata (KLV format, for example EG 0601.X) process it in real time or archive for later retrieval.
KLVLib makes it easy to encode or decode the KLV data. KlvLib is a C++ library, if you need to use it in C#, there is a .NET wrapper available. Please see the blog article that explains how to do that. The wrapper itself is available on request.
Below is the hypothetical example MMS data packets (MISB Standards 0601.2, 0102.5, and SMPTE 336M-2007), as described in MISB EG0902.
All values are shown for illustration purposes only!
The TLV bytes are appended end-to-end, and together become the value portion of the enclosing KLV packet. In this example, there are 97 bytes of TLV data - this is encoded as the length of the KLV packet. The whole local set starts with the 16 byte UL key, followed by the length 0x61, followed by all the TLV hex bytes above in order. In hex, the whole example KLV packet is:
All metadata shall be represented using big-endian encoding, i.e. the most significant byte (MSB) is first. Bytes shall be big-endian bit encoding – with the most significant bit (msb) first.
Below is a sequence diagram for encoding the above Metadata using KLVLib
Sequence diagram that describes decoding of Metadata using KLVLib
*For the commercial and governmental organizations with 500 employees or more the corporate license is limited to “same department”.