Skip to main content

A Python library for parsing MISB/STANAG 4609 Key Length Value (KLV) metadata.

Project description

https://travis-ci.org/paretech/klvdata.svg?branch=master https://coveralls.io/repos/github/paretech/klvdata/badge.svg?branch=master https://img.shields.io/pypi/v/klvdata.svg

What?

Klvdata is a Python library for parsing and constructing Key Length Value (KLV) formatted binary streams. Common uses of the library would be parsing and displaying MISB ST 0601 Unmanned Air System (UAS) metadata from STANAG 4609 compliant MPEG-2 Transport Streams (TS) (MPEG-TS). Note that klvdata alone cannot de-mux KLV data from an MPEG-2 TS, but programs like FFmpeg and GStreamer can be used with klvdata in the workflow to perform the function.

Why?

Not many opensource options available.

Features

  • Parses KLV metadata streams.

  • Supports MISB ST 0601 UAS Datalink Local Set.

  • Supports MISB ST 0102 Security Metadata Local Set.

  • Built for Python 3.5, 3.6.

  • Requires no external Python dependencies.

Quick Start

Try these commands in your GNU/Linux terminal.

First:

$ pip install klvdata

$ wget https://raw.githubusercontent.com/paretech/klvdata/master/data/DynamicConstantMISMMSPacketData.bin

$ cat << EOF > klvdata_test.py
#!/usr/bin/env python
import sys, klvdata;
for packet in klvdata.StreamParser(sys.stdin.buffer.read()): packet.structure()
EOF

And then:

$ python ./klvdata_test.py < DynamicConstantMISMMSPacketData.bin

    <class 'klvdata.misb0601.UASLocalMetadataSet'>
        <class 'klvdata.misb0601.PrecisionTimeStamp'>
        <class 'klvdata.misb0601.MissionID'>
        <class 'klvdata.misb0601.PlatformHeadingAngle'>
        <class 'klvdata.misb0601.PlatformPitchAngle'>
        <class 'klvdata.misb0601.PlatformRollAngle'>
        <class 'klvdata.misb0601.PlatformDesignation'>
        <class 'klvdata.misb0601.ImageSourceSensor'>
        <class 'klvdata.misb0601.ImageCoordinateSystem'>
        <class 'klvdata.misb0601.SensorLatitude'>
        <class 'klvdata.misb0601.SensorLongitude'>
        <class 'klvdata.misb0601.SensorTrueAltitude'>
        <class 'klvdata.misb0601.SensorHorizontalFieldOfView'>
        <class 'klvdata.misb0601.SensorVerticalFieldOfView'>
        <class 'klvdata.misb0601.SensorRelativeAzimuthAngle'>
        <class 'klvdata.misb0601.SensorRelativeElevationAngle'>
        <class 'klvdata.misb0601.SensorRelativeRollAngle'>
        <class 'klvdata.misb0601.SlantRange'>
        <class 'klvdata.misb0601.TargetWidth'>
        <class 'klvdata.misb0601.FrameCenterLatitude'>
        <class 'klvdata.misb0601.FrameCenterLongitude'>
        <class 'klvdata.misb0601.FrameCenterElevation'>
        <class 'klvdata.misb0102.SecurityLocalMetadataSet'>
            <class 'klvdata.misb0102.SecurityClassification'>
            <class 'klvdata.misb0102.UnknownElement'>
            <class 'klvdata.misb0102.UnknownElement'>
            <class 'klvdata.misb0102.UnknownElement'>
            <class 'klvdata.misb0102.UnknownElement'>
            <class 'klvdata.misb0102.UnknownElement'>
        <class 'klvdata.misb0601.UASLSVersionNumber'>
        <class 'klvdata.misb0601.UnknownElement'>
        <class 'klvdata.misb0601.Checksum'>

If you have FFmpeg installed and want to try it on real video from a drone with embedded KLV metadata (~97 MB Download):

$ wget http://samples.ffmpeg.org/MPEG2/mpegts-klv/Day%20Flight.mpg
$ ffmpeg -i Day\ Flight.mpg -map data-re -codec copy -f data - | python ./klvdata_test.py

    <class 'klvdata.misb0601.UASLocalMetadataSet'>
        <class 'klvdata.misb0601.PrecisionTimeStamp'>
        <class 'klvdata.misb0601.UASLSVersionNumber'>
        <class 'klvdata.misb0601.PlatformHeadingAngle'>
        <class 'klvdata.misb0601.PlatformPitchAngle'>
        <class 'klvdata.misb0601.PlatformRollAngle'>
        <class 'klvdata.misb0601.ImageSourceSensor'>
        <class 'klvdata.misb0601.ImageCoordinateSystem'>
        <class 'klvdata.misb0601.SensorLatitude'>
        <class 'klvdata.misb0601.SensorLongitude'>
        <class 'klvdata.misb0601.SensorTrueAltitude'>
        <class 'klvdata.misb0601.SensorHorizontalFieldOfView'>
        <class 'klvdata.misb0601.SensorVerticalFieldOfView'>
        <class 'klvdata.misb0601.SensorRelativeAzimuthAngle'>
        <class 'klvdata.misb0601.SensorRelativeElevationAngle'>
        <class 'klvdata.misb0601.SensorRelativeRollAngle'>
        <class 'klvdata.misb0601.SlantRange'>
        <class 'klvdata.misb0601.TargetWidth'>
        <class 'klvdata.misb0601.FrameCenterLatitude'>
        <class 'klvdata.misb0601.FrameCenterLongitude'>
        <class 'klvdata.misb0601.FrameCenterElevation'>
        <class 'klvdata.misb0601.TargetLocationLatitude'>
        <class 'klvdata.misb0601.TargetLocationLongitude'>
        <class 'klvdata.misb0601.TargetLocationElevation'>
        <class 'klvdata.misb0601.PlatformGroundSpeed'>
        <class 'klvdata.misb0601.GroundRange'>
        <class 'klvdata.misb0601.Checksum'>

        [...]

Documentation

Documentation is available at https://paretech.github.io/klvdata.

Contributing

Contributions are welcome!

Contributors List:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

klvdata-0.0.3.tar.gz (24.6 kB view details)

Uploaded Source

Built Distribution

klvdata-0.0.3-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file klvdata-0.0.3.tar.gz.

File metadata

  • Download URL: klvdata-0.0.3.tar.gz
  • Upload date:
  • Size: 24.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for klvdata-0.0.3.tar.gz
Algorithm Hash digest
SHA256 db45d20bc4877e8e27e6762309a3c3468726c7905a78f550ddad8e837a68e4d1
MD5 a7d24d34607a888decfe534476fb2f31
BLAKE2b-256 6f88deda095aad2ac5d3095d65b93b5d2024a566ac57f9e80ed95493a69a09bf

See more details on using hashes here.

File details

Details for the file klvdata-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: klvdata-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for klvdata-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0e3fc811c85b211f5a8c797bb2b58db5788c72b3abaf95c241b61dfbe5e6a9e7
MD5 a8ac15810729e9cf5bf3153b207bd64f
BLAKE2b-256 2370d0d5ffcefdeced19841231a34c9e1fefbe09b25235445e8fe184bc88913a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page