affaan-m/ECC · error · RuntimeError

Media command produced an empty output

Error message

Media command produced an empty output

What it means

After the caller's block yields the temporary file path, output_file checks that the media command actually produced non-empty output before linking/replacing the destination. If the temporary file has size 0, it raises RuntimeError('Media command produced an empty output') and never creates the destination, indicating the underlying ffmpeg/render command silently failed.

Solutions

  1. Verify the source media is valid and non-empty: run ffmpeg -i source directly and check it decodes
  2. Check the start/end parameters actually select frames within the media's duration
  3. Capture and inspect the subprocess ffmpeg stderr for the underlying decode/encode failure
  4. Ensure sufficient disk space; an interrupted write can leave an empty temp file

Example fix

// before
make_clip(src, start=9999, end=10000, out)  # seek past EOF -> empty output
// after
make_clip(src, start=0, end=5, out)  # valid range within media duration
Defensive patterns

Strategy: validation

Validate before calling

import subprocess
probe = subprocess.run(['ffprobe','-v','error','-select_streams','v:0','-show_entries','format=duration','-of','csv=p=0', src], capture_output=True)
assert probe.returncode == 0 and probe.stdout.strip(), 'source not decodable'

Try / catch

try:
    make_clip(src, start, end, out)
except RuntimeError as e:
    if 'empty output' in str(e):
        print('source undecodable or empty frame range:', e)

Prevention

When it happens

Trigger: Calling render() or make_clip() where the piped ffmpeg decoder/encoder produced zero bytes (e.g. empty/corrupt source, invalid filter chain, ffmpeg exiting immediately after the temp file was created).

Common situations: ffmpeg not able to decode the input (bad codec, truncated file); a seek/start beyond the end of the media; a filter graph yielding no output frames; disk full mid-write or stderr suppressed hiding ffmpeg's real failure.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/9f2a59c08ed1dd0b. Report an issue: GitHub.

Appendix: source

Thrown at skills/taste-application/scripts/tasteforge/media/common.py:32

    if width != int(width) or height != int(height) or width % 2 or height % 2:
        raise ValueError("Width and height must be even integers")


@contextmanager
def output_file(destination, overwrite=False):
    destination = Path(destination)
    if os.path.lexists(destination) and not overwrite:
        raise FileExistsError(destination)
    destination.parent.mkdir(parents=True, exist_ok=True)
    fd, filename = tempfile.mkstemp(
        prefix=".media-", suffix=destination.suffix, dir=destination.parent
    )
    os.close(fd)
    temporary = Path(filename)
    try:
        yield temporary
        if temporary.stat().st_size == 0:
            raise RuntimeError("Media command produced an empty output")
        if overwrite:
            os.replace(temporary, destination)
        else:
            os.link(temporary, destination)
    finally:
        temporary.unlink(missing_ok=True)

View on GitHub (pinned to 8321021c54)