DeepMedia logo
Open Source
Search...

Other versions of this page

Improve this page on GitHub

Search

Validators

Validators tell the engine whether the transcoding process should start or not based on the status of the audio and video track.

kotlin
Transcoder.into(filePath) .setValidator(validator) // ...

This can be used, for example, to:

  • avoid transcoding when video resolution is already OK with our needs
  • avoid operating on files without an audio/video stream
  • avoid operating on files with an audio/video stream

Validators should implement the validate(TrackStatus, TrackStatus) and inspect the status for video and audio tracks. When false is returned, transcoding will complete with the SUCCESS_NOT_NEEDED status code. The TrackStatus enum contains the following values:

ValueMeaning
TrackStatus.ABSENTThis track was absent in the source file.
TrackStatus.PASS_THROUGHThis track is about to be copied as-is in the target file.
TrackStatus.COMPRESSINGThis track is about to be processed and compressed in the target file.
TrackStatus.REMOVINGThis track will be removed in the target file.

The TrackStatus value depends on the track strategy that was used. We provide a few validators that can be injected for typical usage.

DefaultValidator

This is the default validator and it returns true when any of the track is COMPRESSING or REMOVING. In the other cases, transcoding is typically not needed so we abort the operation.

WriteAlwaysValidator

This validator always returns true and as such will always write to target file, no matter the track status, presence of tracks and so on. For instance, the output container file might have no tracks.

WriteVideoValidator

A Validator that gives priority to the video track. Transcoding will not happen if the video track does not need it, even if the audio track might need it. If reducing file size is your only concern, this can avoid compressing files that would not benefit so much from compressing the audio track only.

More

Subscribe to the DeepMedia Newsletter

The latest news about DeepMedia products, open source projects and software development at our company.

By clicking “Subscribe”, you agree that DeepMedia may use your email address to send you newsletters, including commercial communications, and to process your personal data for this purpose. You agree that DeepMedia may process said data using third-party services for this purpose in accordance with the DeepMedia Privacy Policy. You can revoke this consent at any time using the unsubscribe link included in each email or by writing at contact@deepmedia.io.