You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When processing webm audio files, the get_audio_duration function fails with a KeyError because the 'duration' field is not available in the audio stream metadata.
The function attempts to read the duration directly from the audio stream metadata, but for some webm files, this information is only available in the format metadata section of the ffmpeg probe result.
Proposed Solution
defget_audio_duration(file_path):
probe=ffmpeg.probe(file_path)
# First try to get duration from audio streamstream=next((streamforstreaminprobe['streams'] ifstream['codec_type'] =='audio'), None)
ifstreamand'duration'instream:
returnfloat(stream['duration']) *1000# Fallback to format duration if stream duration is not availableif'format'inprobeand'duration'inprobe['format']:
returnfloat(probe['format']['duration']) *1000raiseValueError("Could not determine audio duration from file metadata")
Description
When processing webm audio files, the
get_audio_duration
function fails with a KeyError because the 'duration' field is not available in the audio stream metadata.Error Message
Current Behavior
The function attempts to read the duration directly from the audio stream metadata, but for some webm files, this information is only available in the format metadata section of the ffmpeg probe result.
Proposed Solution
PR: #12
Additional Context
This issue specifically occurs with webm files where the duration information is stored in the format metadata rather than the stream metadata.
The text was updated successfully, but these errors were encountered: