diff --git a/cvat/apps/engine/media_extractors.py b/cvat/apps/engine/media_extractors.py index 8e682950e73a..9114e1033fd6 100644 --- a/cvat/apps/engine/media_extractors.py +++ b/cvat/apps/engine/media_extractors.py @@ -546,7 +546,10 @@ def _get_av_container(self): self._source_path[0].seek(0) # required for re-reading encoding = self.get_file_encoding(self._source_path[0]) - return av.open(self._source_path[0], metadata_encoding = encoding) + if encoding: + return av.open(self._source_path[0], metadata_encoding = encoding) + else: + return av.open(self._source_path[0]) def _get_duration(self): with self._get_av_container() as container: diff --git a/cvat/apps/engine/task.py b/cvat/apps/engine/task.py index aa21cde9012c..32fd70c5a98d 100644 --- a/cvat/apps/engine/task.py +++ b/cvat/apps/engine/task.py @@ -970,7 +970,10 @@ def get_audio_duration(file_path): slogger.glob.debug("ENCODING") slogger.glob.debug(encoding) # Open the audio file - container = av.open(file_path, metadata_encoding=encoding) + if encoding: + container = av.open(file_path, metadata_encoding=encoding) + else: + container = av.open(file_path) # Get the first audio stream audio_stream = next((stream for stream in container.streams if stream.codec.type == 'audio'), None)