Spaces:
Running
Download docs/api-wide-output-validation.md from basyx/MediaRouter: direct link, hf CLI and curl.
- Browser
- Download file 1.64 kB
-
https://huggingface.co/spaces/basyx/MediaRouter/resolve/main/docs/api-wide-output-validation.md
- Command line
-
hf download hf://spaces/basyx/MediaRouter/docs/api-wide-output-validation.md
-
curl -L -o api-wide-output-validation.md https://huggingface.co/spaces/basyx/MediaRouter/resolve/main/docs/api-wide-output-validation.md
API-wide media output validation
Every file-producing operation that reaches MediaProcessor.finish_result now validates its final artifact before publication. This covers the shared execution path used by the standalone video, audio, image, conversion, and template APIs.
Validation sequence
- Verify that the output path exists and is a regular file.
- Reject zero-byte artifacts.
- For audio, video, and image MIME types, run FFprobe on the actual output file.
- Require a video stream for video outputs, an audio stream for audio outputs, and at least one decodable stream for image outputs.
- Apply the shared media-probe constraints and require a finite, positive duration for audio/video outputs.
- Publish only after validation succeeds.
A failed check raises a processing error; the file is not published as a successful response.
Response metadata
Successful file responses include metadata.output_validation:
valid,file_artifact,size_bytes, andmime_typeprobedindicates whether FFprobe rancontainer,duration_seconds,video_stream_count,audio_stream_count, andresolutionare populated when probing is applicable and successful
Text-like outputs such as SRT/VTT and JSON artifacts are checked for file existence and non-zero size, but are not sent through FFprobe. Responses without a file artifact are not subject to file-output validation.
Operational note
FFprobe validation adds work after each render. The output must be fully readable by FFprobe before the API publishes it. Automated tests and a live render should be run before merging this change request.