From e2b4c0758b357151d5ab6fa3671d0a205ea0b8cf Mon Sep 17 00:00:00 2001 From: kpoddar160200 Date: Thu, 30 May 2024 21:12:11 +0530 Subject: [PATCH] bug fix for audios --- cvat/apps/engine/media_extractors.py | 5 ++++- cvat/apps/engine/task.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) 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)