Skip to content

Commit

Permalink
bug fix for audios
Browse files Browse the repository at this point in the history
  • Loading branch information
kushalpoddar committed May 30, 2024
1 parent 4cc294c commit e2b4c07
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion cvat/apps/engine/media_extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion cvat/apps/engine/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e2b4c07

Please sign in to comment.