Skip to content

Commit

Permalink
fix has_audio to check if 'none'
Browse files Browse the repository at this point in the history
  • Loading branch information
McCloudS authored Sep 8, 2024
1 parent 1cee50a commit 222582e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions subgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,13 +813,22 @@ def has_audio(file_path):
if has_image_extension(file_path):
logging.debug(f"{file_path} is an image, skipping processing")
return False

with av.open(file_path) as container:
return any(stream.type == 'audio' for stream in container.streams)
# Check for an audio stream and ensure it has a valid codec
for stream in container.streams:
if stream.type == 'audio':
# Check if the codec is supported (not 'none')
if stream.codec.name != 'none':
return True
else:
logging.debug(f"Unsupported codec for audio stream in {file_path}")
return False

except (av.AVError, UnicodeDecodeError):
logging.debug(f"Error processing file {file_path}")
return False



def path_mapping(fullpath):
if use_path_mapping:
logging.debug("Updated path: " + fullpath.replace(path_mapping_from, path_mapping_to))
Expand Down

0 comments on commit 222582e

Please sign in to comment.