Skip to content

Commit 57d6c79

Browse files
authored
fix: Renamed Encoding Tiers to Video Quality Levels (#437)
1 parent 12f2eb6 commit 57d6c79

File tree

9 files changed

+77
-51
lines changed

9 files changed

+77
-51
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ For reference, here's an example `mux.videoAsset` document:
122122
thumbTime: 65.82,
123123
// Full Mux asset data:
124124
data: {
125-
encoding_tier: 'smart',
125+
video_quality: 'plus',
126126
max_resolution_tier: '1080p',
127127
aspect_ratio: '16:9',
128128
created_at: '1706645034',
@@ -228,25 +228,25 @@ export default defineConfig({
228228

229229
When uploading new assets, editors can still choose a lower resolution for each video than configured globally. This option controls the maximum resolution encoded or processed for the uploaded video. The option is particularly important to manage costs when uploaded videos are higher than `1080p` resolution. More information on the feature is available on Mux's [docs](https://docs.mux.com/guides/stream-videos-in-4k). Also, read more on this feature announcement on Mux's [blog](https://www.mux.com/blog/more-pixels-fewer-problems-introducing-4k-support-for-mux-video).
230230

231-
### Encoding tier (smart or baseline)
231+
### Video Quality Level (plus or basic)
232232

233-
The [encoding tier](https://docs.mux.com/guides/use-encoding-tiers) informs the cost, quality, and available platform features for the asset. You can choose between `smart` and `baseline` at the plugin configuration. Defaults to `smart`.
233+
The [video quality level](https://docs.mux.com/guides/use-video-quality-levels) informs the cost, quality, and available platform features for the asset. You can choose between `plus` and `basic` at the plugin configuration. Defaults to `plus`.
234234

235235
```js
236236
import {muxInput} from 'sanity-plugin-mux-input'
237237

238238
export default defineConfig({
239-
plugins: [muxInput({encoding_tier: 'baseline'})],
239+
plugins: [muxInput({video_quality: 'basic'})],
240240
})
241241
```
242242

243-
If `encoding_tier: 'smart'`, editors can still choose to use the `baseline` encoding tier on a per-video basis when uploading new assets.
243+
If `video_quality: 'plus'`, editors can still choose to use the `basic` video quality level on a per-video basis when uploading new assets.
244244

245-
More information on the feature is available on Mux's [documentation](https://docs.mux.com/guides/use-encoding-tiers). Also, read more on the feature announcement on Mux's [blog](https://www.mux.com/blog/our-next-pricing-lever-baseline-on-demand-assets-with-free-video-encoding)
245+
More information on the feature is available on Mux's [documentation](https://www.mux.com/docs/guides/use-video-quality-levels). Also, read more on the feature announcement on Mux's [blog](https://www.mux.com/blog/our-next-pricing-lever-baseline-on-demand-assets-with-free-video-encoding)
246246

247247
### Auto-generated subtitles and captions
248248

249-
If you've enabled smart encoding, you can use Mux's [auto-generated subtitles](https://docs.mux.com/guides/video/auto-generated-subtitles) feature. Unless you pass `disableTextTrackConfig: true` to the configuration, users will be able to choose a language to auto-generate subtitles for uploaded videos. Refer to Mux's documentation for the list of supported languages.
249+
If you are using 'plus' video quality level, you can use Mux's [auto-generated subtitles](https://docs.mux.com/guides/video/auto-generated-subtitles) feature. Unless you pass `disableTextTrackConfig: true` to the configuration, users will be able to choose a language to auto-generate subtitles for uploaded videos. Refer to Mux's documentation for the list of supported languages.
250250

251251
You can also define a default language for the upload configuration form:
252252

@@ -256,7 +256,7 @@ import {muxInput} from 'sanity-plugin-mux-input'
256256
export default defineConfig({
257257
plugins: [
258258
muxInput({
259-
encoding_tier: 'smart',
259+
video_quality: 'plus',
260260
defaultAutogeneratedSubtitleLang: 'en', // choose from one of the supported languages
261261
}),
262262
],

example/sanity.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default defineConfig({
2323
// https://www.sanity.io/docs/the-vision-plugin
2424
visionTool({defaultApiVersion: apiVersion}),
2525
muxInput({
26-
encoding_tier: 'smart',
26+
video_quality: 'plus',
2727
max_resolution_tier: '2160p',
2828
mp4_support: 'standard',
2929
defaultAutogeneratedSubtitleLang: 'en',

example/sanity.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ export type MuxAssetData = {
207207
status?: string
208208
max_stored_resolution?: string
209209
passthrough?: string
210-
encoding_tier?: string
210+
video_quality?: string
211211
master_access?: string
212212
aspect_ratio?: string
213213
duration?: number

example/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,7 @@
11811181
},
11821182
"optional": true
11831183
},
1184-
"encoding_tier": {
1184+
"video_quality": {
11851185
"type": "objectAttribute",
11861186
"value": {
11871187
"type": "string"

sanity.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default defineConfig({
2828
plugins: [
2929
structureTool(),
3030
muxInput({
31-
encoding_tier: 'smart',
31+
video_quality: 'plus',
3232
max_resolution_tier: '2160p',
3333
mp4_support: 'standard',
3434
defaultAutogeneratedSubtitleLang: 'en',

src/_exports/index.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export type {VideoAssetDocument} from '../util/types'
88

99
export const defaultConfig: PluginConfig = {
1010
mp4_support: 'none',
11-
encoding_tier: 'smart',
11+
video_quality: 'plus',
1212
max_resolution_tier: '1080p',
1313
normalize_audio: false,
1414
defaultSigned: false,
@@ -17,6 +17,18 @@ export const defaultConfig: PluginConfig = {
1717
}
1818

1919
export const muxInput = definePlugin<Partial<PluginConfig> | void>((userConfig) => {
20+
// TODO: Remove this on next major version when we end support for encoding_tier
21+
if (typeof userConfig === 'object' && 'encoding_tier' in userConfig) {
22+
const deprecated_encoding_tier = userConfig.encoding_tier
23+
if (!userConfig.video_quality) {
24+
if (deprecated_encoding_tier === 'baseline') {
25+
userConfig.video_quality = 'basic'
26+
}
27+
if (deprecated_encoding_tier === 'smart') {
28+
userConfig.video_quality = 'plus'
29+
}
30+
}
31+
}
2032
const config: PluginConfig = {...defaultConfig, ...(userConfig || {})}
2133
return {
2234
name: 'mux-input',

src/components/UploadConfiguration.tsx

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,19 @@ import PlaybackPolicy from './uploadConfiguration/PlaybackPolicy'
2323
import type {StagedUpload} from './Uploader'
2424

2525
export type UploadConfigurationStateAction =
26-
| {action: 'encoding_tier'; value: UploadConfig['encoding_tier']}
26+
| {action: 'video_quality'; value: UploadConfig['video_quality']}
2727
| {action: 'max_resolution_tier'; value: UploadConfig['max_resolution_tier']}
2828
| {action: 'mp4_support'; value: UploadConfig['mp4_support']}
2929
| {action: 'normalize_audio'; value: UploadConfig['normalize_audio']}
3030
| {action: 'signed_policy'; value: UploadConfig['signed_policy']}
3131
| {action: 'public_policy'; value: UploadConfig['public_policy']}
3232
| TrackAction
3333

34-
const ENCODING_OPTIONS = [
35-
{value: 'smart', label: 'Smart'},
36-
{value: 'baseline', label: 'Baseline'},
37-
] as const satisfies {value: UploadConfig['encoding_tier']; label: string}[]
34+
const VIDEO_QUALITY_LEVELS = [
35+
{value: 'basic', label: 'Basic'},
36+
{value: 'plus', label: 'Plus'},
37+
{value: 'premium', label: 'Premium'},
38+
] as const satisfies {value: UploadConfig['video_quality']; label: string}[]
3839

3940
const RESOLUTION_TIERS = [
4041
{value: '1080p', label: '1080p'},
@@ -63,7 +64,7 @@ export default function UploadConfiguration({
6364
}) {
6465
const id = useId()
6566
const autoTextTracks = useRef<NonNullable<UploadConfig['text_tracks']>>(
66-
pluginConfig.encoding_tier === 'smart' && pluginConfig.defaultAutogeneratedSubtitleLang
67+
pluginConfig.video_quality === 'plus' && pluginConfig.defaultAutogeneratedSubtitleLang
6768
? [
6869
{
6970
_id: uuid(),
@@ -78,21 +79,21 @@ export default function UploadConfiguration({
7879
const [config, dispatch] = useReducer(
7980
(prev: UploadConfig, action: UploadConfigurationStateAction) => {
8081
switch (action.action) {
81-
case 'encoding_tier':
82-
// If encoding tier switches to baseline, remove smart-only features
83-
if (action.value === 'baseline') {
82+
case 'video_quality':
83+
// If video quality level switches to basic, remove plus-only features
84+
if (action.value === 'basic') {
8485
return Object.assign({}, prev, {
85-
encoding_tier: action.value,
86+
video_quality: action.value,
8687
mp4_support: 'none',
8788
max_resolution_tier: '1080p',
8889
text_tracks: prev.text_tracks?.filter(({type}) => type !== 'autogenerated'),
8990
public_policy: true,
9091
signed_policy: false,
9192
})
92-
// If encoding tier switches to smart, add back in default smart features
93+
// If video quality level switches to plus, add back in default plus features
9394
}
9495
return Object.assign({}, prev, {
95-
encoding_tier: action.value,
96+
video_quality: action.value,
9697
mp4_support: pluginConfig.mp4_support,
9798
max_resolution_tier: pluginConfig.max_resolution_tier,
9899
text_tracks: [...autoTextTracks, ...(prev.text_tracks || [])],
@@ -138,7 +139,7 @@ export default function UploadConfiguration({
138139
}
139140
},
140141
{
141-
encoding_tier: pluginConfig.encoding_tier,
142+
video_quality: pluginConfig.video_quality,
142143
max_resolution_tier: pluginConfig.max_resolution_tier,
143144
mp4_support: pluginConfig.mp4_support,
144145
signed_policy: secrets.enableSignedUrls && pluginConfig.defaultSigned,
@@ -159,6 +160,7 @@ export default function UploadConfiguration({
159160
}, [])
160161
if (skipConfig) return null
161162

163+
const basicConfig = config.video_quality !== 'plus' && config.video_quality !== 'premium'
162164
const maxSupportedResolution = RESOLUTION_TIERS.findIndex(
163165
(rt) => rt.value === pluginConfig.max_resolution_tier
164166
)
@@ -198,11 +200,11 @@ export default function UploadConfiguration({
198200
{!disableUploadConfig && (
199201
<Stack space={3} paddingBottom={2}>
200202
<FormField
201-
title="Encoding Tier"
203+
title="Video Quality Level"
202204
description={
203205
<>
204-
The encoding tier informs the cost, quality, and available platform features for
205-
the asset.{' '}
206+
The video quality level informs the cost, quality, and available platform features
207+
for the asset.{' '}
206208
<a
207209
href="https://docs.mux.com/guides/use-encoding-tiers"
208210
target="_blank"
@@ -214,17 +216,17 @@ export default function UploadConfiguration({
214216
}
215217
>
216218
<Flex gap={3}>
217-
{ENCODING_OPTIONS.map(({value, label}) => {
219+
{VIDEO_QUALITY_LEVELS.map(({value, label}) => {
218220
const inputId = `${id}--encodingtier-${value}`
219221
return (
220222
<Flex key={value} align="center" gap={2}>
221223
<Radio
222-
checked={config.encoding_tier === value}
224+
checked={config.video_quality === value}
223225
name="asset-encodingtier"
224226
onChange={(e) =>
225227
dispatch({
226-
action: 'encoding_tier' as const,
227-
value: e.currentTarget.value as UploadConfig['encoding_tier'],
228+
action: 'video_quality' as const,
229+
value: e.currentTarget.value as UploadConfig['video_quality'],
228230
})
229231
}
230232
value={value}
@@ -239,7 +241,7 @@ export default function UploadConfiguration({
239241
</Flex>
240242
</FormField>
241243

242-
{config.encoding_tier === 'smart' && maxSupportedResolution > 0 && (
244+
{!basicConfig && maxSupportedResolution > 0 && (
243245
<FormField
244246
title="Resolution Tier"
245247
description={
@@ -286,12 +288,12 @@ export default function UploadConfiguration({
286288
</FormField>
287289
)}
288290

289-
{config.encoding_tier === 'smart' && (
291+
{!basicConfig && (
290292
<FormField title="Additional Configuration">
291293
<Stack space={2}>
292294
<PlaybackPolicy id={id} config={config} secrets={secrets} dispatch={dispatch} />
293295

294-
{config.encoding_tier === 'smart' && (
296+
{!basicConfig && (
295297
<Flex align="center" gap={2} padding={[0, 2]}>
296298
<Checkbox
297299
id={`${id}--mp4_support`}
@@ -319,7 +321,7 @@ export default function UploadConfiguration({
319321
</Stack>
320322
)}
321323

322-
{!disableTextTrackConfig && config.encoding_tier === 'smart' && (
324+
{!disableTextTrackConfig && !basicConfig && (
323325
<TextTracksEditor
324326
tracks={config.text_tracks}
325327
dispatch={dispatch}
@@ -329,9 +331,7 @@ export default function UploadConfiguration({
329331

330332
<Box marginTop={4}>
331333
<Button
332-
disabled={
333-
config.encoding_tier === 'smart' && !config.public_policy && !config.signed_policy
334-
}
334+
disabled={!basicConfig && !config.public_policy && !config.signed_policy}
335335
icon={UploadIcon}
336336
text="Upload"
337337
tone="positive"
@@ -388,7 +388,7 @@ function formatUploadConfig(config: UploadConfig): MuxNewAssetSettings {
388388
mp4_support: config.mp4_support,
389389
playback_policy: setPlaybackPolicy(config),
390390
max_resolution_tier: config.max_resolution_tier,
391-
encoding_tier: config.encoding_tier,
391+
video_quality: config.video_quality,
392392
normalize_audio: config.normalize_audio,
393393
}
394394
}

src/schema.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ const muxAssetData = {
9898
type: 'string',
9999
name: 'encoding_tier',
100100
},
101+
{
102+
type: 'string',
103+
name: 'video_quality',
104+
},
101105
{
102106
type: 'string',
103107
name: 'master_access',

src/util/types.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,35 @@ import type {PartialDeep} from 'type-fest'
44
export interface MuxInputConfig {
55
/**
66
* Enable static renditions by setting this to 'standard'. Can be overwritten on a per-asset basis.
7-
* Requires `"encoding_tier": "smart"`
7+
* Requires `"video_quality": "plus"`
88
* @see {@link https://docs.mux.com/guides/video/enable-static-mp4-renditions#why-enable-mp4-support}
99
* @defaultValue 'none'
1010
*/
1111
mp4_support: 'none' | 'standard'
1212

1313
/**
1414
* Max resolution tier can be used to control the maximum resolution_tier your asset is encoded, stored, and streamed at.
15-
* Requires `"encoding_tier": "smart"`
15+
* Requires `"video_quality": "plus"`
1616
* @see {@link https://docs.mux.com/guides/stream-videos-in-4k}
1717
* @defaultValue '1080p'
1818
*/
1919
max_resolution_tier: '2160p' | '1440p' | '1080p'
2020

2121
/**
22+
* @deprecated Use {@link video_quality}
23+
* <br>
2224
* The encoding tier informs the cost, quality, and available platform features for the asset.
2325
* @see {@link https://docs.mux.com/guides/use-encoding-tiers}
2426
* @defaultValue 'smart'
2527
*/
26-
encoding_tier: 'baseline' | 'smart'
28+
encoding_tier?: 'baseline' | 'smart'
29+
30+
/**
31+
* The video quality level informs the cost, quality, and available platform features for the asset.
32+
* @see {@link https://www.mux.com/docs/guides/use-video-quality-levels}
33+
* @defaultValue 'plus'
34+
*/
35+
video_quality: 'basic' | 'plus' | 'premium'
2736

2837
/**
2938
* Normalize the audio track loudness level.
@@ -41,7 +50,7 @@ export interface MuxInputConfig {
4150

4251
/**
4352
* Auto-generate captions for these languages by default.
44-
* Requires `"encoding_tier": "smart"`
53+
* Requires `"video_quality": "plus"`
4554
*
4655
* @see {@link https://docs.mux.com/guides/add-autogenerated-captions-and-use-transcripts}
4756
* @deprecated use `defaultAutogeneratedSubtitleLang` instead. Only a single autogenerated
@@ -50,7 +59,7 @@ export interface MuxInputConfig {
5059

5160
/**
5261
* Auto-generate captions for this language by default. Users can still
53-
* Requires `"encoding_tier": "smart"`
62+
* Requires `"video_quality": "plus"`
5463
*
5564
* @see {@link https://docs.mux.com/guides/add-autogenerated-captions-and-use-transcripts}
5665
*/
@@ -123,9 +132,10 @@ export const SUPPORTED_MUX_LANGUAGES = [
123132
{label: 'Bulgarian', code: 'bg', state: 'Beta'},
124133
] as const
125134

126-
export const ENCODING_TIERS = [
127-
{label: 'Baseline', value: 'baseline'},
128-
{label: 'Smart', value: 'smart'},
135+
export const VIDEO_QUALITY_LEVELS = [
136+
{label: 'Basic', value: 'basic'},
137+
{label: 'Plus', value: 'plus'},
138+
{label: 'Premium', value: 'premium'},
129139
] as const
130140

131141
export const SUPPORTED_MUX_LANGUAGES_VALUES = SUPPORTED_MUX_LANGUAGES.map((l) => l.code)
@@ -168,7 +178,7 @@ export type UploadTextTrack = AutogeneratedTextTrack | CustomTextTrack
168178
export interface UploadConfig
169179
extends Pick<
170180
MuxInputConfig,
171-
'encoding_tier' | 'max_resolution_tier' | 'mp4_support' | 'normalize_audio'
181+
'max_resolution_tier' | 'mp4_support' | 'normalize_audio' | 'video_quality'
172182
> {
173183
text_tracks: UploadTextTrack[]
174184
signed_policy: boolean
@@ -182,7 +192,7 @@ export interface UploadConfig
182192
export interface MuxNewAssetSettings
183193
extends Pick<
184194
MuxInputConfig,
185-
'encoding_tier' | 'max_resolution_tier' | 'mp4_support' | 'normalize_audio'
195+
'max_resolution_tier' | 'mp4_support' | 'normalize_audio' | 'video_quality'
186196
> {
187197
/** An array of objects that each describe an input file to be used to create the asset.*/
188198
input?: {

0 commit comments

Comments
 (0)