Skip to content

Commit

Permalink
feat(api): extend mp4 support (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Apr 5, 2024
1 parent 8895afd commit 5483c7f
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 21 deletions.
4 changes: 4 additions & 0 deletions src/resources/data/video-views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export interface AbridgedVideoView {

error_type_id: number | null;

playback_failure: boolean;

player_error_code: string | null;

player_error_message: string | null;
Expand Down Expand Up @@ -188,6 +190,8 @@ export namespace VideoViewResponse {

playback_business_exception_error_type_id: number;

playback_failure: boolean;

playback_failure_error_type_id: number;

playback_id: string | null;
Expand Down
91 changes: 73 additions & 18 deletions src/resources/video/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ export class Assets extends APIResource {

/**
* Allows you to add or remove mp4 support for assets that were created without it.
* Currently there are two values supported in this request, `standard` and `none`.
* `none` means that an asset _does not_ have mp4 support, so submitting a request
* with `mp4_support` set to `none` will delete the mp4 assets from the asset in
* question.
* The values supported are `capped-1080p`, `audio-only`,
* `audio-only,capped-1080p`, `standard`(deprecated), and `none`. `none` means that
* an asset _does not_ have mp4 support, so submitting a request with `mp4_support`
* set to `none` will delete the mp4 assets from the asset in question.
*/
updateMP4Support(
assetId: string,
Expand Down Expand Up @@ -240,7 +240,7 @@ export interface Asset {
*/
max_resolution_tier: '1080p' | '1440p' | '2160p';

mp4_support: 'standard' | 'none';
mp4_support: 'standard' | 'none' | 'capped-1080p' | 'audio-only' | 'audio-only,capped-1080p';

/**
* The status of the asset.
Expand Down Expand Up @@ -554,7 +554,7 @@ export namespace Asset {
*/
height?: number;

name?: 'low.mp4' | 'medium.mp4' | 'high.mp4' | 'audio.m4a';
name?: 'low.mp4' | 'medium.mp4' | 'high.mp4' | 'audio.m4a' | 'capped-1080p.mp4';

/**
* The width of the static rendition's file in pixels
Expand Down Expand Up @@ -594,14 +594,33 @@ export interface AssetOptions {
max_resolution_tier?: '1080p' | '1440p' | '2160p';

/**
* Specify what level (if any) of support for mp4 playback. In most cases you
* should use our default HLS-based streaming playback ({playback_id}.m3u8) which
* can automatically adjust to viewers' connection speeds, but an mp4 can be useful
* for some legacy devices or downloading for offline playback. See the
* Specify what level of support for mp4 playback.
*
* - The `capped-1080p` option produces a single MP4 file, called
* `capped-1080p.mp4`, with the video resolution capped at 1080p. This option
* produces an `audio.m4a` file for an audio-only asset.
* - The `audio-only` option produces a single M4A file, called `audio.m4a` for a
* video or an audio-only asset. MP4 generation will error when this option is
* specified for a video-only asset.
* - The `audio-only,capped-1080p` option produces both the `audio.m4a` and
* `capped-1080p.mp4` files. Only the `capped-1080p.mp4` file is produced for a
* video-only asset, while only the `audio.m4a` file is produced for an
* audio-only asset.
*
* The `standard`(deprecated) option produces up to three MP4 files with different
* levels of resolution (`high.mp4`, `medium.mp4`, `low.mp4`, or `audio.m4a` for an
* audio-only asset).
*
* MP4 files are not produced for `none` (default).
*
* In most cases you should use our default HLS-based streaming playback
* (`{playback_id}.m3u8`) which can automatically adjust to viewers' connection
* speeds, but an mp4 can be useful for some legacy devices or downloading for
* offline playback. See the
* [Download your videos guide](https://docs.mux.com/guides/enable-static-mp4-renditions)
* for more information.
*/
mp4_support?: 'none' | 'standard';
mp4_support?: 'none' | 'standard' | 'capped-1080p' | 'audio-only' | 'audio-only,capped-1080p';

/**
* Normalize the audio track loudness level. This parameter is only applicable to
Expand Down Expand Up @@ -1265,14 +1284,33 @@ export interface AssetCreateParams {
max_resolution_tier?: '1080p' | '1440p' | '2160p';

/**
* Specify what level (if any) of support for mp4 playback. In most cases you
* should use our default HLS-based streaming playback ({playback_id}.m3u8) which
* can automatically adjust to viewers' connection speeds, but an mp4 can be useful
* for some legacy devices or downloading for offline playback. See the
* Specify what level of support for mp4 playback.
*
* - The `capped-1080p` option produces a single MP4 file, called
* `capped-1080p.mp4`, with the video resolution capped at 1080p. This option
* produces an `audio.m4a` file for an audio-only asset.
* - The `audio-only` option produces a single M4A file, called `audio.m4a` for a
* video or an audio-only asset. MP4 generation will error when this option is
* specified for a video-only asset.
* - The `audio-only,capped-1080p` option produces both the `audio.m4a` and
* `capped-1080p.mp4` files. Only the `capped-1080p.mp4` file is produced for a
* video-only asset, while only the `audio.m4a` file is produced for an
* audio-only asset.
*
* The `standard`(deprecated) option produces up to three MP4 files with different
* levels of resolution (`high.mp4`, `medium.mp4`, `low.mp4`, or `audio.m4a` for an
* audio-only asset).
*
* MP4 files are not produced for `none` (default).
*
* In most cases you should use our default HLS-based streaming playback
* (`{playback_id}.m3u8`) which can automatically adjust to viewers' connection
* speeds, but an mp4 can be useful for some legacy devices or downloading for
* offline playback. See the
* [Download your videos guide](https://docs.mux.com/guides/enable-static-mp4-renditions)
* for more information.
*/
mp4_support?: 'none' | 'standard';
mp4_support?: 'none' | 'standard' | 'capped-1080p' | 'audio-only' | 'audio-only,capped-1080p';

/**
* Normalize the audio track loudness level. This parameter is only applicable to
Expand Down Expand Up @@ -1662,9 +1700,26 @@ export interface AssetUpdateMasterAccessParams {

export interface AssetUpdateMP4SupportParams {
/**
* String value for the level of mp4 support
* Specify what level of support for mp4 playback.
*
* - The `capped-1080p` option produces a single MP4 file, called
* `capped-1080p.mp4`, with the video resolution capped at 1080p. This option
* produces an `audio.m4a` file for an audio-only asset.
* - The `audio-only` option produces a single M4A file, called `audio.m4a` for a
* video or an audio-only asset. MP4 generation will error when this option is
* specified for a video-only asset.
* - The `audio-only,capped-1080p` option produces both the `audio.m4a` and
* `capped-1080p.mp4` files. Only the `capped-1080p.mp4` file is produced for a
* video-only asset, while only the `audio.m4a` file is produced for an
* audio-only asset.
*
* The `standard`(deprecated) option produces up to three MP4 files with different
* levels of resolution (`high.mp4`, `medium.mp4`, `low.mp4`, or `audio.m4a` for an
* audio-only asset).
*
* `none` will delete the MP4s from the asset in question.
*/
mp4_support: 'standard' | 'none';
mp4_support: 'standard' | 'none' | 'capped-1080p' | 'audio-only' | 'audio-only,capped-1080p';
}

export namespace Assets {
Expand Down
6 changes: 6 additions & 0 deletions src/resources/video/delivery-usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ export interface DeliveryReport {
*/
asset_duration: number;

/**
* The encoding tier that the asset was ingested at.
* [See the encoding tiers guide for more details.](https://docs.mux.com/guides/use-encoding-tiers)
*/
asset_encoding_tier: 'smart' | 'baseline';

/**
* Unique identifier for the asset.
*/
Expand Down
4 changes: 2 additions & 2 deletions tests/api-resources/video/assets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ describe('resource assets', () => {
});

test('updateMP4Support: only required params', async () => {
const responsePromise = mux.video.assets.updateMP4Support('string', { mp4_support: 'standard' });
const responsePromise = mux.video.assets.updateMP4Support('string', { mp4_support: 'capped-1080p' });
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -295,6 +295,6 @@ describe('resource assets', () => {
});

test('updateMP4Support: required and optional params', async () => {
const response = await mux.video.assets.updateMP4Support('string', { mp4_support: 'standard' });
const response = await mux.video.assets.updateMP4Support('string', { mp4_support: 'capped-1080p' });
});
});
2 changes: 1 addition & 1 deletion tests/api-resources/video/uploads.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe('resource uploads', () => {
playback_policy: ['public'],
per_title_encode: true,
passthrough: 'string',
mp4_support: 'none',
mp4_support: 'capped-1080p',
normalize_audio: true,
master_access: 'none',
test: true,
Expand Down

0 comments on commit 5483c7f

Please sign in to comment.