iluvcapra / wavinfo

Probe WAVE Files for all metadata
https://wavinfo.readthedocs.io/
MIT License
36 stars 7 forks source link

Broadcast wav files throw errors #2

Closed emc2hahn closed 5 years ago

emc2hahn commented 5 years ago

Hi, I am encountering various errors when trying to open broadcas wav files created with the professional DAW systems Pyramix and Sequoia.

Sequoia uses the RF64 header and calling WavInfoReader on these simply leads to:

Traceback (most recent call last):
  File "C:/Users/xxx/PycharmProjects/test/scratch.py", line 3, in <module>
    info = WavInfoReader("source files/seq_test.wav")
  File "C:\Users\xxx\PycharmProjects\test\venv\lib\site-packages\wavinfo\wave_reader.py", line 41, in __init__
    self.main_list = chunks.children
AttributeError: 'ChunkDescriptor' object has no attribute 'children'

Whereas Pyramix seems to write only the standard RIFF header. Nevertheless trying to parse one of it's files throws:

Traceback (most recent call last):
  File "C:/Users/xxx/PycharmProjects/test/scratch.py", line 3, in <module>
    info = WavInfoReader("source files/test.wav")
  File "C:\Users\xxx\PycharmProjects\test\venv\lib\site-packages\wavinfo\wave_reader.py", line 51, in __init__
    self.ixml   = self._get_ixml(f)
  File "C:\Users\xxx\PycharmProjects\test\venv\lib\site-packages\wavinfo\wave_reader.py", line 129, in _get_ixml
    return WavIXMLFormat(ixml_string)
  File "C:\Users\xxx\PycharmProjects\test\venv\lib\site-packages\wavinfo\wave_ixml_reader.py", line 11, in __init__
    self.parsed = ET.parse(xmlBytes)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python37\lib\xml\etree\ElementTree.py", line 1197, in parse
    tree.parse(source, parser)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python37\lib\xml\etree\ElementTree.py", line 598, in parse
    self._root = parser._parse_whole(source)
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 17, column 9

ProTools created wav's however seem to be interpreted just fine.

iluvcapra commented 5 years ago

Hi, thanks for bringing these to my attention.

At this time I don't support RF64 files though that's definitely something I'd like to add; on the other hand it looks like Pyramix is doing something funny in its iXML header. Do you mind attaching an example of a file from Pyramix that causes this error?

emc2hahn commented 5 years ago

Hi, thanks for taking care of this so quickly. I don't know if my email went through, so I send my comments here one more time:

Indeed, RF64 support would be awesome, since those files are very common in environments where dealing with a lot of metadata is of interest. For now, a quick check and a meaningful error message would help, it took me a moment to figure out that RF64 was the issue.

On the other note: I wouldn't be surprised if Pyramix does funky things here, so I have created a super short BWF file that it generates. For exports Pyramix also has an option to do non-broadcast wav's and those seem to work fine with wavinfo, just that they don't contain much information (the time_reference is missing eg.)

I have attached the wav file. I hope this helps, let me know if I can help with anything else! Testfile_PYR_BWF.zip

iluvcapra commented 5 years ago

If you can run the current head commit give that a try... 0ce18d9

This should work with the Pyramix files, not RF64 yet.

emc2hahn commented 5 years ago

Awesome! It works (at least with the Pyramix files), thank you very much! What was the speciality that caused the issue? I just had to manually install lxml for this update.

Would an RF64 file be helpful for you as well?

iluvcapra commented 5 years ago

If you want to gimme a Pyramix RF64 that'd be good (please just silence and ZIP before you upload!) post it to issue #3 where I'll track this feature.

I'm not sure what was causing the iXML issue, I switched to a different XML parser library and am using it with a fault-tolerant setting. The standard Python XML library thought that Pyramix was leaving an entity open but I wasn't able to figure out how, it looked like valid XML to me.