{"record":{"id":"9f2a59c08ed1dd0b","repo":"affaan-m/ECC","slug":"media-command-produced-an-empty-output","errorCode":null,"errorMessage":"Media command produced an empty output","messagePattern":"Media command produced an empty output","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"skills/taste-application/scripts/tasteforge/media/common.py","lineNumber":32,"sourceCode":"    if width != int(width) or height != int(height) or width % 2 or height % 2:\n        raise ValueError(\"Width and height must be even integers\")\n\n\n@contextmanager\ndef output_file(destination, overwrite=False):\n    destination = Path(destination)\n    if os.path.lexists(destination) and not overwrite:\n        raise FileExistsError(destination)\n    destination.parent.mkdir(parents=True, exist_ok=True)\n    fd, filename = tempfile.mkstemp(\n        prefix=\".media-\", suffix=destination.suffix, dir=destination.parent\n    )\n    os.close(fd)\n    temporary = Path(filename)\n    try:\n        yield temporary\n        if temporary.stat().st_size == 0:\n            raise RuntimeError(\"Media command produced an empty output\")\n        if overwrite:\n            os.replace(temporary, destination)\n        else:\n            os.link(temporary, destination)\n    finally:\n        temporary.unlink(missing_ok=True)\n","sourceCodeStart":14,"sourceCodeEnd":39,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/taste-application/scripts/tasteforge/media/common.py#L14-L39","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Verify the source media is valid and non-empty: run ffmpeg -i source directly and check it decodes","Check the start/end parameters actually select frames within the media's duration","Capture and inspect the subprocess ffmpeg stderr for the underlying decode/encode failure","Ensure sufficient disk space; an interrupted write can leave an empty temp file"],"exampleFix":"// before\nmake_clip(src, start=9999, end=10000, out)  # seek past EOF -> empty output\n// after\nmake_clip(src, start=0, end=5, out)  # valid range within media duration","handlingStrategy":"validation","validationCode":"import subprocess\nprobe = subprocess.run(['ffprobe','-v','error','-select_streams','v:0','-show_entries','format=duration','-of','csv=p=0', src], capture_output=True)\nassert probe.returncode == 0 and probe.stdout.strip(), 'source not decodable'","typeGuard":null,"tryCatchPattern":"try:\n    make_clip(src, start, end, out)\nexcept RuntimeError as e:\n    if 'empty output' in str(e):\n        print('source undecodable or empty frame range:', e)","preventionTips":["Validate source media with ffprobe before processing","Ensure start/end lie within the media duration","Check ffmpeg is installed and supports the source codec","Monitor disk space on long renders"],"tags":["media","ffmpeg","empty-output"],"backgroundTag":"empty-result-set","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}