crewAIInc/crewAI · error · FileValidationError

Audio '{filename}' duration ({duration:.1f}s) exceeds maximu

Error message

Audio '{filename}' duration ({duration:.1f}s) exceeds maximum ({constraints.max_duration_seconds}s)

What it means

validate_audio probes the audio's duration and raises FileValidationError when duration > constraints.max_duration_seconds; the message formats the actual duration with one decimal (e.g. '45.2s') plus the limit. It only fires when duration probing succeeds and the constraint is set.

Source

Thrown at lib/crewai-files/src/crewai_files/processing/validators.py:383

    _validate_format(
        "Audio",
        filename,
        file.content_type,
        constraints.supported_formats,
        errors,
        raise_on_error,
    )

    if constraints.max_duration_seconds is not None:
        duration = _get_audio_duration(content, filename)
        if duration is not None and duration > constraints.max_duration_seconds:
            msg = (
                f"Audio '{filename}' duration ({duration:.1f}s) exceeds "
                f"maximum ({constraints.max_duration_seconds}s)"
            )
            errors.append(msg)
            if raise_on_error:
                raise FileValidationError(msg, file_name=filename)

    return errors


def validate_video(
    file: VideoFile,
    constraints: VideoConstraints,
    *,
    raise_on_error: bool = True,
) -> Sequence[str]:
    """Validate a video file against constraints.

    Args:
        file: The video file to validate.
        constraints: Video constraints to validate against.
        raise_on_error: If True, raise exceptions on validation failure.

    Returns:

View on GitHub (pinned to 754d7323be)

Solutions

  1. Split the audio upstream into segments under max_duration_seconds (ffmpeg -f segment).
  2. Raise max_duration_seconds if the provider permits longer audio.
  3. Transcribe long audio externally and attach the transcript as text instead.
  4. Catch FileValidationError and use the reported duration to tell users the accepted limit.

Example fix

# before
constraints = AudioConstraints(max_duration_seconds=60)
validate_audio(meeting_recording, constraints)  # FileValidationError: 1873.4s exceeds maximum 60s

# after
# shell: ffmpeg -i meeting.mp3 -f segment -segment_time 60 -c copy meeting_%02d.mp3
for seg in segmented_files:
    validate_audio(seg, constraints)  # each segment passes
Defensive patterns

Strategy: validation

Validate before calling

duration = probe_duration(content, filename)  # e.g. via ffprobe/mutagen
if constraints.max_duration_seconds is not None and duration > constraints.max_duration_seconds:
    return split_or_reject(file, duration, constraints.max_duration_seconds)

Try / catch

from crewai_files.processing.exceptions import FileValidationError

try:
    processor.process(audio_file)
except FileValidationError as e:
    if "duration" in str(e):
        return split_audio(file, segment_seconds=constraints.max_duration_seconds)
    raise

Prevention

When it happens

Trigger: Validating an audio file (e.g. a 15-minute recording, duration ~900s) against AudioConstraints(max_duration_seconds=60) with raise_on_error=True, or via STRICT-mode processing. Short clips within the limit never trigger it.

Common situations: Provider caps on audio length (e.g. speech-to-text or audio-understanding APIs limiting to 25MB / ~1-25 minutes); meeting recordings and podcasts attached whole; max_duration_seconds tuned for voice notes but hit by uploaded files.

Related errors


AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15). Data as JSON: /api/errors/46c79efdf6613dcb. Report an issue: GitHub.