Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'UnknownElement' object has no attribute 'structure' #39

Open
adamxyzxyz opened this issue Jan 4, 2021 · 5 comments
Open

Comments

@adamxyzxyz
Copy link

adamxyzxyz commented Jan 4, 2021

Hi,

I am receiving this error when running klvdata_test.py:

AttributeError: 'UnknownElement' object has no attribute 'structure'

I believe it has something to do with the way the klvdata is embedded in the stream:
Stream #0:0: Data: bin_data (KLVA / 0x41564C4B)

Are there any adjustments I can make to this script to have it properly parse the data?

Thanks

@adamxyzxyz adamxyzxyz changed the title AttributeError: 'UnknownElement' object has no attribute 'MetadataList' AttributeError: 'UnknownElement' object has no attribute 'structure' Jan 4, 2021
@firestorm22
Copy link

I have also the same problem.

@ayhangenc
Copy link

Hi,

Same problem here, trying to decode a recorded ts stream, here is the output...

Duration: 00:01:25.40, start: 1778.243333, bitrate: 5850 kb/s
Program 1
Metadata:
service_name : CAMERA 01
service_provider: HC4
Stream #0:0[0x12c]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 100 tbc
Stream #0:1[0x12d]: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, fltp, 256 kb/s
Stream #0:2[0x5]: Data: bin_data ([6][0][0][0] / 0x0006)
Stream #0:3[0x259]: Data: bin_data (TELM / 0x4D4C4554)
Stream #0:4[0x32]: Data: bin_data (CCII / 0x49494343)
Stream #0:5[0x258]: Data: klv (KLVA / 0x41564C4B)
Output #0, data, to 'pipe:':
Metadata:
encoder : Lavf58.45.100
Stream #0:0: Data: klv (KLVA / 0x41564C4B)
Stream mapping:
Stream #0:5 -> #0:0 (copy)
Press [q] to stop, [?] for help
size= 668kB time=00:01:25.36 bitrate= 64.1kbits/s speed=1.19e+03x
video:0kB audio:0kB subtitle:0kB other streams:668kB global headers:0kB muxing overhead: 0.000000%
Traceback (most recent call last):
File "./klvdata_test.py", line 3, in
for packet in klvdata.StreamParser(sys.stdin.buffer.read()): packet.structure()
AttributeError: 'UnknownElement' object has no attribute 'structure'

@All4Gis
Copy link
Collaborator

All4Gis commented Mar 7, 2021

I cannot reproduce this error. Sorry for the delay. Can you specify the steps to reproduce it?

@zaidbhat1234
Copy link

@firestorm22 @adamxyzxyz @ayhangenc Were you guys able to resolve this issue? I am also facing this similar issue and not able to figure out the reason behind it.

@patrickjmccarty
Copy link

I hit this as well and resolved it. It happens if your stream has data fields that are not implemented, and you are using code like the sample script from the homepage Quick Start that calls packet.structure(). On a related note I implemented an improvement to nicely print the info about the UnknownElement.

Edit klvdata/klvdata/element.py in two places as follows:

# I changed the __str__ method in the Element class to print hex more clearly, the way MISB does.
    def __str__(self):
        return "{}: ({}, {}, {})".format(self.name, '.'.join('{:02x}'.format(x) for x in self.key), len(self), '.'.join('{:02x}'.format(v) for v in self.value))


# I added a structure method to the UnknownElement class so that it will continue printing when it encounters an unrecognized field.
    def structure(self):
        """Print this unsupported element."""
        print(str(self))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants