A successful upload tells you one thing: the bytes arrived. It does not guarantee that the video will play correctly, include an audio track, or match the resolution your player expects.
A video might upload successfully but fail during playback because of an unsupported codec, missing audio, incorrect metadata, or a corrupted file.
For developers building video platforms, catching these problems before publication is important. Instead of relying entirely on manual playback checks, you can introduce an automated validation step into your video processing workflow.
This article explains how to build a basic validation process using FFprobe, FFmpeg, and Node.js, without creating an unnecessarily complicated system.
Why Video Quality Checks Matter
Publishing errors usually fall into a few common categories:
- Playback failures: The container or codec is not supported by the player or target devices.
- Missing audio: The file contains a video stream but no audio stream.
- Incorrect resolution: A low-resolution file is uploaded where 1080p content is expected.
- Metadata problems: Duration, dimensions, or stream information are missing or incorrect.
- Corrupted files: An upload may be incomplete or contain damaged frames.
These problems are easier to identify before publication than after viewers report them.
Automated checks also make video quality assurance more consistent. Every uploaded file can pass through the same validation rules rather than depending on someone manually reviewing each video.
What Should Be Checked Before Publishing?
Before implementing validation, define what an acceptable video looks like for your platform.
Here are the main properties to check:
| Property | What to Validate |
|---|---|
| Container | Whether the file format is supported |
| Video codec | Whether the codec works with target devices |
| Audio codec | Whether the audio format is supported |
| Resolution | Whether dimensions meet minimum requirements |
| Frame rate | Whether the frame rate is within the expected range |
| Bitrate | Whether the bitrate is suitable for the intended playback |
| Audio stream | Whether an audio track is present when required |
| Duration | Whether the file has a valid duration |
| File integrity | Whether the file can be decoded successfully |
For example, H.264 video with AAC audio is a common combination for web playback. However, supported formats should always be determined by the actual devices and players your platform serves.
If terms such as codec, container, and bitrate are unfamiliar, this overview of video encoding and streaming terminology provides useful background.
Technical Validation Is Not Visual Quality Testing
There is an important difference between checking a video's technical properties and evaluating how it looks.
Technical validation can confirm that a file has the expected codec, resolution, audio stream, and duration. It cannot determine whether the video looks blurry, has visible compression artifacts, or contains poorly synchronized audio.
Subjective video quality testing requires human review or specialized perceptual quality tools.
A video can pass every metadata check and still deliver a poor viewing experience. Keep these two types of testing separate.
Building a Basic Video Validation Workflow
A simple automated workflow can follow these steps:
- Upload: Store the incoming file in temporary storage.
- Probe: Extract its technical metadata.
- Validate: Compare the metadata against predefined rules.
- Decode: Check whether the file can be processed without errors.
- Decide: Mark the file as validated or rejected.
- Publish: Allow only validated files to continue through the publishing process.
The important part is to keep uploaded videos unavailable to viewers until validation is complete.
Extracting Video Metadata with FFprobe
FFprobe is included with FFmpeg and can inspect video files without requiring a full decode.
You can use the following command to retrieve technical information in JSON format:
ffprobe -v error -print_format json -show_format -show_streams input.mp4
The output contains information about:
- Video and audio streams
- Codec names
- Width and height
- Frame rate
- Duration
- File format and bitrate
For example, a backend service can read this JSON output and determine whether a video contains an audio stream or meets the platform's minimum resolution.
This process is also useful when inspecting existing video libraries. During a migration, checking metadata before moving files can help identify inconsistent or unsupported content. The same principle applies to OTT content migration.
One important limitation: metadata inspection does not prove that every frame can be decoded. It should be treated as an initial validation step rather than a complete integrity test.
Automating Video Checks with Node.js
Once FFprobe extracts the metadata, a backend application can compare the results against predefined rules.
For example, a platform might require:
- H.264 video
- AAC audio
- Minimum resolution of 1280 × 720
- A valid duration
- At least one audio stream
A simplified Node.js validation function could look like this:
function validateVideo(info) {
const video = info.streams.find(s => s.codec_type === "video");
const audio = info.streams.find(s => s.codec_type === "audio");
const errors = [];
if (!video) errors.push("Missing video stream");
if (video && video.codec_name !== "h264")
errors.push("Unsupported video codec");
if (!audio) errors.push("Missing audio stream");
if (audio && audio.codec_name !== "aac")
errors.push("Unsupported audio codec");
if (video && (video.width < 1280 || video.height < 720))
errors.push("Resolution is too low");
return errors;
}
This example demonstrates the validation logic rather than a complete production implementation. In an actual application, the metadata would come from an FFprobe process, and the backend would also validate duration, file size, frame rate, and other requirements.
Collecting errors in an array is useful because the uploader receives a list of problems instead of having to fix them one at a time.
Checking File Integrity with FFmpeg
FFprobe can inspect metadata, but it does not necessarily detect every damaged frame.
For a deeper integrity check, FFmpeg can attempt to decode the entire file without generating an output video:
ffmpeg -v error -i input.mp4 -f null -
If decoding errors occur, they can be captured from the process output and recorded against the uploaded file.
This check takes longer because it processes the video rather than only reading its metadata.
For that reason, a practical approach is to run inexpensive metadata checks first and perform a full decode check when the file passes the initial validation.
Automated file validation is one part of a broader OTT workflow. Developers should also consider content processing and failed-job handling when evaluating the architecture of a streaming platform.
Handling Failed Validation
A useful validation system should explain why a video failed.
Returning only an error such as Invalid video file does not give developers or uploaders enough information to resolve the problem.
Consider these practices:
- Store specific error messages: Record whether the issue is an unsupported codec, missing audio, or incorrect resolution.
-
Use clear processing states: Maintain statuses such as
uploaded,validating,validated,rejected, anderror. - Separate rejection from system failure: An unsupported file should be rejected, while a crashed validation worker may need a retry.
- Log processing details: Record the video ID, validation rules, FFmpeg version, and relevant error output.
- Retry carefully: Use retry limits and backoff for temporary infrastructure failures.
These practices make the processing pipeline easier to monitor and troubleshoot.
Integrating Validation into a Video Processing Pipeline
Validation should happen after upload but before transcoding and publication.
A typical workflow looks like this:
Upload → Validate → Transcode → Store → Publish
Running validation before transcoding helps avoid spending processing resources on files that already violate the platform's requirements.
You can also validate transcoded output. For example, if a source video is converted into multiple resolutions, the resulting files should be checked to confirm that the expected codecs, dimensions, and audio streams are present.
Publication should happen only after the required processing stages have completed successfully.
For developers planning the broader system, an overview of the OTT platform development workflow helps explain how video processing fits into a complete streaming platform.
Best Practices for Reliable Video Quality Assurance
A few additional practices can make automated validation more reliable:
- Keep validation rules configurable: Store codec lists, resolution limits, and other requirements outside the main application logic.
- Use device-specific requirements: Base supported formats on the actual devices and players your platform targets.
- Maintain test files: Keep sample files containing missing audio, unsupported codecs, unusual resolutions, and corrupted data.
- Add regression tests: When a new upload problem appears, add a test case to prevent it from happening again.
- Monitor validation results: Track rejection reasons and processing failures to identify recurring issues.
- Protect processing resources: Apply file-size limits, timeouts, and resource restrictions when processing uploaded files.
There are also limitations to a basic validation script. It may not handle multiple audio tracks, variable frame rates, unusual rotation metadata, or very large files correctly without additional logic.
More importantly, uploaded media should be treated as untrusted input. Production systems need appropriate input validation, isolated processing environments, and resource limits before exposing file-processing functionality to users.
Conclusion
Automated video validation helps identify technical problems before a video becomes available to viewers.
FFprobe provides the metadata needed for initial checks, FFmpeg can help detect decoding problems, and a backend script can enforce the platform's publishing requirements.
Start with a small set of rules based on your supported devices and playback requirements. Record why files fail, test the validation process with different video formats, and expand it as new issues appear.
The goal is not to replace every form of video quality testing with code. It is to catch predictable technical problems early and make the publishing process more reliable.
Top comments (0)