Problems with international characters in metadata
Created by: jfhs
I've built PyAV for python 3, and it works fine, except that it fails on reading metadata from files, if they contain unicode/international (I'm not sure) characters. I.e. I had file with title for audio channel with russian letters, and got exception:
"UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)"
I fixed that by changing the avdict_to_dict so that it returns bytebuffers instead of strings as values:
cdef dict avdict_to_dict(lib.AVDictionary *input):
cdef lib.AVDictionaryEntry *element = NULL
cdef dict output = {}
cdef bytes value
while True:
element = lib.av_dict_get(input, "", element, lib.AV_DICT_IGNORE_SUFFIX)
if element == NULL:
break
value = element.value
output[element.key] = value
return output
Maybe you'll find some other, more nicer way, but I'm not sure if there is a way to determine right encoding.