[object Object] Icon

Encoding
Learn how to create, start, manage and modify Encodings

[object Object] Icon

Player
Learn how to create, start, manage and modify Players

[object Object] Icon

Analytics
Learn how to create, start, manage and modify Analyticss

Docs Home
User shortcuts for search
Focus by pressing f
Hide results by pressing Esc
Navigate via   keys

Thu Feb 13 2020

Stream Conditions

Thu Feb 13 2020

IntroductionLink Icon

Stream conditions allow you to add conditional logic in your encoding configuration. They ensure that your workflow can automatically adapt to different types of input files and streams.

This page lists the attributes and values available when attaching stream conditions to Stream resources through its conditions parameter.

Use the tutorial for more information on how to use stream conditions.

Condition objectLink Icon

A Condition has three parameters:

attribute

Indicates what aspect of the input is being checked

operator

Indicates the logical operation to perform between source value and expected value. Possible operators are

1- "=="
2- "!="
3- "<="
4- "<"
5- ">"
6- ">="

Note that if you use our SDKs, the operators are exposed through a ConditionOperator enumeration:

1- "EQUAL" for "=="
2- "NOT_EQUAL" for "!="
3- "LESS_THAN_OR_EQUAL" for "<="
4- "LESS_THAN" for "<"
5- "GREATER_THAN" for ">"
6- "GREATER_THAN_OR_EQUAL" for ">="

value

Allows you to state what value to compare against the value extracted from the input file or stream.

All values (including numbers and booleans) should be provided as strings, and will be cast automatically into the appropriate type when the encoder performs the condition check.

Extracted valuesLink Icon

At times, you may find that the condition you configure does not seem to work. It may be that the file you are using does not conform to your expectations.

To troubleshoot this, you can verify the result of the analysis stage, by looking at the analysisDetails property of the Stream (or inputStreams.analysisDetails depending on your input configuration), which will be populated during the encoding.

We state below, for each attribute, which property in the analysisDetails object will reflect the value extracted from the source during analysis.

Note that the analysisDetails property is only available when you call the REST API directly, and is not currently exposed through the SDKs. You can for example use the REST client embedded in our API reference.

Input fileLink Icon

The following attributes are used to check the input file:

AttributeDescriptionExtracted Value
INPUTSTREAMchecks whether there is a stream to be found in the input file, at the position defined by the selectionMode parameter of the StreamInput resource attached to the Stream. You must use the EQUAL condition operator to test this conditiontrue or false
STREAMCOUNTchecks the number of streams (or tracks) present in the input fileanalysisDetails.numberOfStreams
VIDEOSTREAMCOUNTchecks specifically the number of video streams available in the input filesize of analysisDetails.videoStreams array
AUDIOSTREAMCOUNTchecks specifically the number of audio streams available in the input filesize of analysisDetails.audioStreams array
DURATIONchecks the duration of the input stream, and is expressed as a decimal representation in secondsanalysisDetails.videoStreams[0].duration or analysisDetails.duration

Video StreamLink Icon

In addition to the above, the following attributes are only available when evaluating conditions against video streams. Extracted values are compared against the property of the appropriate item in the analysisDetails.videoStreams array

AttributeDescriptionExtracted Value
HEIGHTin pixelsheight
WIDTHin pixelswidth
BITRATEexpressed as an integer in bits per second (bps)bitrate
FPSframe rate expressed as a number of frames per second and parsed to a decimal representation (ie. you can express it as fraction such as "3000/1001"fps
ASPECTRATIOas a decimal value. Therefore a value larger than 1 is therefore landscape, and lower than 1 portraitcalculated as width / height * par

Audio StreamLink Icon

The following attributes apply to audio input streams only. Extracted values are compared against the property of the appropriate item in the analysisDetails.audioStreams array

AttributeDescriptionExtracted Value
BITRATEexpressed as an integer in bits per second (bps)bitrate
LANGUAGEaudio language. If none is set in the input stream, the value will be "und"language
CHANNELFORMATused to check on the number of channels in the audio stream. For example, a stereo input track would have a value of 2, a input track with dolby digital would have 6channelFormat
CHANNELLAYOUTA tag describing the channel layout. See https://ffmpeg.org/ffprobe-all.html#Channel-Layout for a list of possible valueschannelLayout

Give us feedback