fix has_audio to check if 'none'
This commit is contained in:
15
subgen.py
15
subgen.py
@@ -813,13 +813,22 @@ def has_audio(file_path):
|
|||||||
if has_image_extension(file_path):
|
if has_image_extension(file_path):
|
||||||
logging.debug(f"{file_path} is an image, skipping processing")
|
logging.debug(f"{file_path} is an image, skipping processing")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
with av.open(file_path) as container:
|
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):
|
except (av.AVError, UnicodeDecodeError):
|
||||||
|
logging.debug(f"Error processing file {file_path}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def path_mapping(fullpath):
|
def path_mapping(fullpath):
|
||||||
if use_path_mapping:
|
if use_path_mapping:
|
||||||
logging.debug("Updated path: " + fullpath.replace(path_mapping_from, path_mapping_to))
|
logging.debug("Updated path: " + fullpath.replace(path_mapping_from, path_mapping_to))
|
||||||
|
|||||||
Reference in New Issue
Block a user