Package: klvdata
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 displayingMISB ST0601 Unmanned Air System (UAS) metadata fromSTANAG 4609compliantMPEG-2 Transport Streams (TS) (MPEG-TS). Note that klvdata alone cannot de-mux KLV data from an MPEG-2 TS, but programs likeFFmpegandGStreamercan be used with klvdata in the workflow to perform the function.Why?Not many opensource options available.FeaturesParses KLV metadata streams.SupportsMISB ST0601 UAS Datalink Local Set.SupportsMISB ST0102 Security Metadata Local Set.Built for Python 3.5, 3.6.Requires no external Python dependencies.Quick StartTry these commands in your GNU/Linux terminal.First:$pipinstallklvdata$wgethttps://raw.githubusercontent.com/paretech/klvdata/master/data/DynamicConstantMISMMSPacketData.bin$cat<<EOF>klvdata_test.py#!/usr/bin/envpythonimport sys, klvdata;
for packet in klvdata.StreamParser(sys.stdin.buffer.read()): packet.structure()
EOFAnd 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):$wgethttp://samples.ffmpeg.org/MPEG2/mpegts-klv/Day%20Flight.mpg$ffmpeg-iDay\Flight.mpg-mapdata-re-codeccopy-fdata-|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'>

        [...]DocumentationDocumentation is available athttps://paretech.github.io/klvdata.ContributingContributions are welcome!Contributors List:Fran Raga