-
Notifications
You must be signed in to change notification settings - Fork 60
/
assets.ts
1806 lines (1596 loc) · 64.5 KB
/
assets.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import * as Core from '@mux/mux-node/core';
import { APIResource } from '@mux/mux-node/resource';
import { isRequestOptions } from '@mux/mux-node/core';
import * as AssetsAPI from '@mux/mux-node/resources/video/assets';
import * as Shared from '@mux/mux-node/resources/shared';
import { BasePage, type BasePageParams } from '@mux/mux-node/pagination';
export class Assets extends APIResource {
/**
* Create a new Mux Video asset.
*/
create(body: AssetCreateParams, options?: Core.RequestOptions): Core.APIPromise<Asset> {
return (
this._client.post('/video/v1/assets', { body, ...options }) as Core.APIPromise<{ data: Asset }>
)._thenUnwrap((obj) => obj.data);
}
/**
* Retrieves the details of an asset that has previously been created. Supply the
* unique asset ID that was returned from your previous request, and Mux will
* return the corresponding asset information. The same information is returned
* when creating an asset.
*/
retrieve(assetId: string, options?: Core.RequestOptions): Core.APIPromise<Asset> {
return (
this._client.get(`/video/v1/assets/${assetId}`, options) as Core.APIPromise<{ data: Asset }>
)._thenUnwrap((obj) => obj.data);
}
/**
* Updates the details of an already-created Asset with the provided Asset ID. This
* currently supports only the `passthrough` field.
*/
update(assetId: string, body: AssetUpdateParams, options?: Core.RequestOptions): Core.APIPromise<Asset> {
return (
this._client.patch(`/video/v1/assets/${assetId}`, { body, ...options }) as Core.APIPromise<{
data: Asset;
}>
)._thenUnwrap((obj) => obj.data);
}
/**
* List all Mux assets.
*/
list(query?: AssetListParams, options?: Core.RequestOptions): Core.PagePromise<AssetsBasePage, Asset>;
list(options?: Core.RequestOptions): Core.PagePromise<AssetsBasePage, Asset>;
list(
query: AssetListParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.PagePromise<AssetsBasePage, Asset> {
if (isRequestOptions(query)) {
return this.list({}, query);
}
return this._client.getAPIList('/video/v1/assets', AssetsBasePage, { query, ...options });
}
/**
* Deletes a video asset and all its data.
*/
delete(assetId: string, options?: Core.RequestOptions): Core.APIPromise<void> {
return this._client.delete(`/video/v1/assets/${assetId}`, {
...options,
headers: { Accept: '*/*', ...options?.headers },
});
}
/**
* Creates a playback ID that can be used to stream the asset to a viewer.
*/
createPlaybackId(
assetId: string,
body: AssetCreatePlaybackIDParams,
options?: Core.RequestOptions,
): Core.APIPromise<Shared.PlaybackID> {
return (
this._client.post(`/video/v1/assets/${assetId}/playback-ids`, { body, ...options }) as Core.APIPromise<{
data: Shared.PlaybackID;
}>
)._thenUnwrap((obj) => obj.data);
}
/**
* Adds an asset track (for example, subtitles, or an alternate audio track) to an
* asset.
*/
createTrack(
assetId: string,
body: AssetCreateTrackParams,
options?: Core.RequestOptions,
): Core.APIPromise<Track> {
return (
this._client.post(`/video/v1/assets/${assetId}/tracks`, { body, ...options }) as Core.APIPromise<{
data: Track;
}>
)._thenUnwrap((obj) => obj.data);
}
/**
* Deletes a playback ID, rendering it nonfunctional for viewing an asset's video
* content. Please note that deleting the playback ID removes access to the
* underlying asset; a viewer who started playback before the playback ID was
* deleted may be able to watch the entire video for a limited duration.
*/
deletePlaybackId(
assetId: string,
playbackId: string,
options?: Core.RequestOptions,
): Core.APIPromise<void> {
return this._client.delete(`/video/v1/assets/${assetId}/playback-ids/${playbackId}`, {
...options,
headers: { Accept: '*/*', ...options?.headers },
});
}
/**
* Removes a text track from an asset. Audio and video tracks on assets cannot be
* removed.
*/
deleteTrack(assetId: string, trackId: string, options?: Core.RequestOptions): Core.APIPromise<void> {
return this._client.delete(`/video/v1/assets/${assetId}/tracks/${trackId}`, {
...options,
headers: { Accept: '*/*', ...options?.headers },
});
}
/**
* Generates subtitles (captions) for a given audio track. This API can be used for
* up to 7 days after an asset is created.
*/
generateSubtitles(
assetId: string,
trackId: string,
body: AssetGenerateSubtitlesParams,
options?: Core.RequestOptions,
): Core.APIPromise<AssetGenerateSubtitlesResponse> {
return (
this._client.post(`/video/v1/assets/${assetId}/tracks/${trackId}/generate-subtitles`, {
body,
...options,
}) as Core.APIPromise<{ data: AssetGenerateSubtitlesResponse }>
)._thenUnwrap((obj) => obj.data);
}
/**
* Returns a list of the input objects that were used to create the asset along
* with any settings that were applied to each input.
*/
retrieveInputInfo(
assetId: string,
options?: Core.RequestOptions,
): Core.APIPromise<AssetRetrieveInputInfoResponse> {
return (
this._client.get(`/video/v1/assets/${assetId}/input-info`, options) as Core.APIPromise<{
data: AssetRetrieveInputInfoResponse;
}>
)._thenUnwrap((obj) => obj.data);
}
/**
* Retrieves information about the specified playback ID.
*/
retrievePlaybackId(
assetId: string,
playbackId: string,
options?: Core.RequestOptions,
): Core.APIPromise<Shared.PlaybackID> {
return (
this._client.get(`/video/v1/assets/${assetId}/playback-ids/${playbackId}`, options) as Core.APIPromise<{
data: Shared.PlaybackID;
}>
)._thenUnwrap((obj) => obj.data);
}
/**
* Allows you to add temporary access to the master (highest-quality) version of
* the asset in MP4 format. A URL will be created that can be used to download the
* master version for 24 hours. After 24 hours Master Access will revert to "none".
* This master version is not optimized for web and not meant to be streamed, only
* downloaded for purposes like archiving or editing the video offline.
*/
updateMasterAccess(
assetId: string,
body: AssetUpdateMasterAccessParams,
options?: Core.RequestOptions,
): Core.APIPromise<Asset> {
return (
this._client.put(`/video/v1/assets/${assetId}/master-access`, { body, ...options }) as Core.APIPromise<{
data: Asset;
}>
)._thenUnwrap((obj) => obj.data);
}
/**
* Allows you to add or remove mp4 support for assets that were created without it.
* 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,
body: AssetUpdateMP4SupportParams,
options?: Core.RequestOptions,
): Core.APIPromise<Asset> {
return (
this._client.put(`/video/v1/assets/${assetId}/mp4-support`, { body, ...options }) as Core.APIPromise<{
data: Asset;
}>
)._thenUnwrap((obj) => obj.data);
}
}
export class AssetsBasePage extends BasePage<Asset> {}
export interface Asset {
/**
* Unique identifier for the Asset. Max 255 characters.
*/
id: string;
/**
* Time the Asset was created, defined as a Unix timestamp (seconds since epoch).
*/
created_at: string;
/**
* The encoding tier informs the cost, quality, and available platform features for
* the asset. By default the `smart` encoding tier is used.
* [See the guide for more details.](https://docs.mux.com/guides/use-encoding-tiers)
*/
encoding_tier: 'smart' | 'baseline';
master_access: 'temporary' | 'none';
/**
* Max resolution tier can be used to control the maximum `resolution_tier` your
* asset is encoded, stored, and streamed at. If not set, this defaults to `1080p`.
*/
max_resolution_tier: '1080p' | '1440p' | '2160p';
mp4_support: 'standard' | 'none' | 'capped-1080p' | 'audio-only' | 'audio-only,capped-1080p';
/**
* The status of the asset.
*/
status: 'preparing' | 'ready' | 'errored';
/**
* The aspect ratio of the asset in the form of `width:height`, for example `16:9`.
*/
aspect_ratio?: string;
/**
* The duration of the asset in seconds (max duration for a single asset is 12
* hours).
*/
duration?: number;
/**
* Object that describes any errors that happened when processing this asset.
*/
errors?: Asset.Errors;
/**
* The type of ingest used to create the asset.
*/
ingest_type?: 'on_demand_url' | 'on_demand_direct_upload' | 'on_demand_clip' | 'live_rtmp' | 'live_srt';
/**
* Indicates whether the live stream that created this asset is currently `active`
* and not in `idle` state. This is an optional parameter added when the asset is
* created from a live stream.
*/
is_live?: boolean;
/**
* Unique identifier for the live stream. This is an optional parameter added when
* the asset is created from a live stream.
*/
live_stream_id?: string;
/**
* An object containing the current status of Master Access and the link to the
* Master MP4 file when ready. This object does not exist if `master_access` is set
* to `none` and when the temporary URL expires.
*/
master?: Asset.Master;
/**
* The maximum frame rate that has been stored for the asset. The asset may be
* delivered at lower frame rates depending on the device and bandwidth, however it
* cannot be delivered at a higher value than is stored. This field may return -1
* if the frame rate of the input cannot be reliably determined.
*/
max_stored_frame_rate?: number;
/**
* @deprecated: This field is deprecated. Please use `resolution_tier` instead. The
* maximum resolution that has been stored for the asset. The asset may be
* delivered at lower resolutions depending on the device and bandwidth, however it
* cannot be delivered at a higher value than is stored.
*/
max_stored_resolution?: 'Audio only' | 'SD' | 'HD' | 'FHD' | 'UHD';
/**
* An object containing one or more reasons the input file is non-standard. See
* [the guide on minimizing processing time](https://docs.mux.com/guides/minimize-processing-time)
* for more information on what a standard input is defined as. This object only
* exists on on-demand assets that have non-standard inputs, so if missing you can
* assume the input qualifies as standard.
*/
non_standard_input_reasons?: Asset.NonStandardInputReasons;
/**
* Normalize the audio track loudness level. This parameter is only applicable to
* on-demand (not live) assets.
*/
normalize_audio?: boolean;
/**
* Arbitrary user-supplied metadata set for the asset. Max 255 characters.
*/
passthrough?: string;
/**
* @deprecated
*/
per_title_encode?: boolean;
/**
* An array of Playback ID objects. Use these to create HLS playback URLs. See
* [Play your videos](https://docs.mux.com/guides/play-your-videos) for more
* details.
*/
playback_ids?: Array<Shared.PlaybackID>;
/**
* An array of individual live stream recording sessions. A recording session is
* created on each encoder connection during the live stream. Additionally any time
* slate media is inserted during brief interruptions in the live stream media or
* times when the live streaming software disconnects, a recording session
* representing the slate media will be added with a "slate" type.
*/
recording_times?: Array<Asset.RecordingTime>;
/**
* The resolution tier that the asset was ingested at, affecting billing for ingest
* & storage. This field also represents the highest resolution tier that the
* content can be delivered at, however the actual resolution may be lower
* depending on the device, bandwidth, and exact resolution of the uploaded asset.
*/
resolution_tier?: 'audio-only' | '720p' | '1080p' | '1440p' | '2160p';
/**
* Asset Identifier of the video used as the source for creating the clip.
*/
source_asset_id?: string;
/**
* An object containing the current status of any static renditions (mp4s). The
* object does not exist if no static renditions have been requested. See
* [Download your videos](https://docs.mux.com/guides/enable-static-mp4-renditions)
* for more information.
*/
static_renditions?: Asset.StaticRenditions;
/**
* True means this live stream is a test asset. A test asset can help evaluate the
* Mux Video APIs without incurring any cost. There is no limit on number of test
* assets created. Test assets are watermarked with the Mux logo, limited to 10
* seconds, and deleted after 24 hrs.
*/
test?: boolean;
/**
* The individual media tracks that make up an asset.
*/
tracks?: Array<Track>;
/**
* Unique identifier for the Direct Upload. This is an optional parameter added
* when the asset is created from a direct upload.
*/
upload_id?: string;
}
export namespace Asset {
/**
* Object that describes any errors that happened when processing this asset.
*/
export interface Errors {
/**
* Error messages with more details.
*/
messages?: Array<string>;
/**
* The type of error that occurred for this asset.
*/
type?: string;
}
/**
* An object containing the current status of Master Access and the link to the
* Master MP4 file when ready. This object does not exist if `master_access` is set
* to `none` and when the temporary URL expires.
*/
export interface Master {
status?: 'ready' | 'preparing' | 'errored';
/**
* The temporary URL to the master version of the video, as an MP4 file. This URL
* will expire after 24 hours.
*/
url?: string;
}
/**
* An object containing one or more reasons the input file is non-standard. See
* [the guide on minimizing processing time](https://docs.mux.com/guides/minimize-processing-time)
* for more information on what a standard input is defined as. This object only
* exists on on-demand assets that have non-standard inputs, so if missing you can
* assume the input qualifies as standard.
*/
export interface NonStandardInputReasons {
/**
* The audio codec used on the input file. Non-AAC audio codecs are non-standard.
*/
audio_codec?: string;
/**
* Audio Edit List reason indicates that the input file's audio track contains a
* complex Edit Decision List.
*/
audio_edit_list?: 'non-standard';
/**
* The video pixel aspect ratio of the input file.
*/
pixel_aspect_ratio?: string;
/**
* A catch-all reason when the input file in created with non-standard encoding
* parameters.
*/
unexpected_media_file_parameters?: 'non-standard';
/**
* The video pixel format, as a string, returned by libav. Considered non-standard
* if not one of yuv420p or yuvj420p.
*/
unsupported_pixel_format?: string;
/**
* The video bitrate of the input file is `high`. This parameter is present when
* the average bitrate of any key frame interval (also known as Group of Pictures
* or GOP) is higher than what's considered standard which typically is 16 Mbps.
*/
video_bitrate?: 'high';
/**
* The video codec used on the input file. For example, the input file encoded with
* `hevc` video codec is non-standard and the value of this parameter is `hevc`.
*/
video_codec?: string;
/**
* Video Edit List reason indicates that the input file's video track contains a
* complex Edit Decision List.
*/
video_edit_list?: 'non-standard';
/**
* The video frame rate of the input file. Video with average frames per second
* (fps) less than 5 or greater than 120 is non-standard. A `-1` frame rate value
* indicates Mux could not determine the frame rate of the video track.
*/
video_frame_rate?: string;
/**
* The video key frame Interval (also called as Group of Picture or GOP) of the
* input file is `high`. This parameter is present when the gop is greater than 20
* seconds.
*/
video_gop_size?: 'high';
/**
* The video resolution of the input file. Video resolution higher than 2048 pixels
* on any one dimension (height or width) is considered non-standard, The
* resolution value is presented as `width` x `height` in pixels.
*/
video_resolution?: string;
}
export interface RecordingTime {
/**
* The duration of the live stream recorded. The time value is in seconds.
*/
duration?: number;
/**
* The time at which the recording for the live stream started. The time value is
* Unix epoch time represented in ISO 8601 format.
*/
started_at?: string;
/**
* The type of media represented by the recording session, either `content` for
* normal stream content or `slate` for slate media inserted during stream
* interruptions.
*/
type?: 'content' | 'slate';
}
/**
* An object containing the current status of any static renditions (mp4s). The
* object does not exist if no static renditions have been requested. See
* [Download your videos](https://docs.mux.com/guides/enable-static-mp4-renditions)
* for more information.
*/
export interface StaticRenditions {
/**
* Array of file objects.
*/
files?: Array<StaticRenditions.File>;
/**
* Indicates the status of downloadable MP4 versions of this asset.
*/
status?: 'ready' | 'preparing' | 'disabled' | 'errored';
}
export namespace StaticRenditions {
export interface File {
/**
* The bitrate in bits per second
*/
bitrate?: number;
/**
* Extension of the static rendition file
*/
ext?: 'mp4' | 'm4a';
/**
* The file size in bytes
*/
filesize?: string;
/**
* The height of the static rendition's file in pixels
*/
height?: number;
name?: 'low.mp4' | 'medium.mp4' | 'high.mp4' | 'audio.m4a' | 'capped-1080p.mp4';
/**
* The width of the static rendition's file in pixels
*/
width?: number;
}
}
}
export interface AssetOptions {
/**
* An array of playback policy objects that you want applied to this asset and
* available through `playback_ids`. `advanced_playback_policy` must be used
* instead of `playback_policy` when creating a DRM playback ID.
*/
advanced_playback_policy?: Array<AssetOptions.AdvancedPlaybackPolicy>;
/**
* The encoding tier informs the cost, quality, and available platform features for
* the asset. By default the `smart` encoding tier is used.
* [See the guide for more details.](https://docs.mux.com/guides/use-encoding-tiers)
*/
encoding_tier?: 'smart' | 'baseline';
/**
* An array of objects that each describe an input file to be used to create the
* asset. As a shortcut, input can also be a string URL for a file when only one
* input file is used. See `input[].url` for requirements.
*/
input?: Array<AssetOptions.Input>;
/**
* Specify what level (if any) of support for master access. Master access can be
* enabled temporarily for your asset to be downloaded. See the
* [Download your videos guide](https://docs.mux.com/guides/enable-static-mp4-renditions)
* for more information.
*/
master_access?: 'none' | 'temporary';
/**
* Max resolution tier can be used to control the maximum `resolution_tier` your
* asset is encoded, stored, and streamed at. If not set, this defaults to `1080p`.
*/
max_resolution_tier?: '1080p' | '1440p' | '2160p';
/**
* 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' | 'capped-1080p' | 'audio-only' | 'audio-only,capped-1080p';
/**
* Normalize the audio track loudness level. This parameter is only applicable to
* on-demand (not live) assets.
*/
normalize_audio?: boolean;
/**
* Arbitrary user-supplied metadata that will be included in the asset details and
* related webhooks. Can be used to store your own ID for a video along with the
* asset. **Max: 255 characters**.
*/
passthrough?: string;
/**
* @deprecated
*/
per_title_encode?: boolean;
/**
* An array of playback policy names that you want applied to this asset and
* available through `playback_ids`. Options include:
*
* - `"public"` (anyone with the playback URL can stream the asset).
* - `"signed"` (an additional access token is required to play the asset).
*
* If no `playback_policy` is set, the asset will have no playback IDs and will
* therefore not be playable. For simplicity, a single string name can be used in
* place of the array in the case of only one playback policy.
*/
playback_policy?: Array<Shared.PlaybackPolicy>;
/**
* Marks the asset as a test asset when the value is set to true. A Test asset can
* help evaluate the Mux Video APIs without incurring any cost. There is no limit
* on number of test assets created. Test asset are watermarked with the Mux logo,
* limited to 10 seconds, deleted after 24 hrs.
*/
test?: boolean;
}
export namespace AssetOptions {
export interface AdvancedPlaybackPolicy {
/**
* The DRM configuration used by this playback ID. Must only be set when `policy`
* is set to `drm`.
*/
drm_configuration_id?: string;
/**
* - `public` playback IDs are accessible by constructing an HLS URL like
* `https://stream.mux.com/${PLAYBACK_ID}`
*
* - `signed` playback IDs should be used with tokens
* `https://stream.mux.com/${PLAYBACK_ID}?token={TOKEN}`. See
* [Secure video playback](https://docs.mux.com/guides/secure-video-playback) for
* details about creating tokens.
*/
policy?: Shared.PlaybackPolicy;
}
/**
* An array of objects that each describe an input file to be used to create the
* asset. As a shortcut, `input` can also be a string URL for a file when only one
* input file is used. See `input[].url` for requirements.
*/
export interface Input {
/**
* Indicates the track provides Subtitles for the Deaf or Hard-of-hearing (SDH).
* This optional parameter should be used for tracks with `type` of `text` and
* `text_type` set to `subtitles`.
*/
closed_captions?: boolean;
/**
* The time offset in seconds from the beginning of the video, indicating the
* clip's ending marker. The default value is the duration of the video when not
* included. This parameter is only applicable for creating clips when `input.url`
* has `mux://assets/{asset_id}` format.
*/
end_time?: number;
/**
* Generate subtitle tracks using automatic speech recognition with this
* configuration. This may only be provided for the first input object (the main
* input file). For direct uploads, this first input should omit the url parameter,
* as the main input file is provided via the direct upload. This will create
* subtitles based on the audio track ingested from that main input file. Note that
* subtitle generation happens after initial ingest, so the generated tracks will
* be in the `preparing` state when the asset transitions to `ready`.
*/
generated_subtitles?: Array<Input.GeneratedSubtitle>;
/**
* The language code value must be a valid
* [BCP 47](https://tools.ietf.org/html/bcp47) specification compliant value. For
* example, `en` for English or `en-US` for the US version of English. This
* parameter is required for `text` and `audio` track types.
*/
language_code?: string;
/**
* The name of the track containing a human-readable description. This value must
* be unique within each group of `text` or `audio` track types. The HLS manifest
* will associate a subtitle text track with this value. For example, the value
* should be "English" for a subtitle text track with `language_code` set to `en`.
* This optional parameter should be used only for `text` and `audio` type tracks.
* This parameter can be optionally provided for the first video input to denote
* the name of the muxed audio track if present. If this parameter is not included,
* Mux will auto-populate based on the `input[].language_code` value.
*/
name?: string;
/**
* An object that describes how the image file referenced in URL should be placed
* over the video (i.e. watermarking). Ensure that the URL is active and persists
* the entire lifespan of the video object.
*/
overlay_settings?: Input.OverlaySettings;
/**
* This optional parameter should be used tracks with `type` of `text` and
* `text_type` set to `subtitles`.
*/
passthrough?: string;
/**
* The time offset in seconds from the beginning of the video indicating the clip's
* starting marker. The default value is 0 when not included. This parameter is
* only applicable for creating clips when `input.url` has
* `mux://assets/{asset_id}` format.
*/
start_time?: number;
/**
* Type of text track. This parameter only supports subtitles value. For more
* information on Subtitles / Closed Captions,
* [see this blog post](https://mux.com/blog/subtitles-captions-webvtt-hls-and-those-magic-flags/).
* This parameter is required for `text` type tracks.
*/
text_type?: 'subtitles';
/**
* This parameter is required for `text` type tracks.
*/
type?: 'video' | 'audio' | 'text';
/**
* The URL of the file that Mux should download and use.
*
* - For the main input file, this should be the URL to the muxed file for Mux to
* download, for example an MP4, MOV, MKV, or TS file. Mux supports most
* audio/video file formats and codecs, but for fastest processing, you should
* [use standard inputs wherever possible](https://docs.mux.com/guides/minimize-processing-time).
* - For `audio` tracks, the URL is the location of the audio file for Mux to
* download, for example an M4A, WAV, or MP3 file. Mux supports most audio file
* formats and codecs, but for fastest processing, you should
* [use standard inputs wherever possible](https://docs.mux.com/guides/minimize-processing-time).
* - For `text` tracks, the URL is the location of subtitle/captions file. Mux
* supports [SubRip Text (SRT)](https://en.wikipedia.org/wiki/SubRip) and
* [Web Video Text Tracks](https://www.w3.org/TR/webvtt1/) formats for ingesting
* Subtitles and Closed Captions.
* - For Watermarking or Overlay, the URL is the location of the watermark image.
* The maximum size is 4096x4096.
* - When creating clips from existing Mux assets, the URL is defined with
* `mux://assets/{asset_id}` template where `asset_id` is the Asset Identifier
* for creating the clip from. The url property may be omitted on the first input
* object when providing asset settings for LiveStream and Upload objects, in
* order to configure settings related to the primary (live stream or direct
* upload) input.
*/
url?: string;
}
export namespace Input {
export interface GeneratedSubtitle {
/**
* The language to generate subtitles in.
*/
language_code?:
| 'en'
| 'es'
| 'it'
| 'pt'
| 'de'
| 'fr'
| 'pl'
| 'ru'
| 'nl'
| 'ca'
| 'tr'
| 'sv'
| 'uk'
| 'no'
| 'fi'
| 'sk'
| 'el'
| 'cs'
| 'hr'
| 'da'
| 'ro'
| 'bg';
/**
* A name for this subtitle track.
*/
name?: string;
/**
* Arbitrary metadata set for the subtitle track. Max 255 characters.
*/
passthrough?: string;
}
/**
* An object that describes how the image file referenced in URL should be placed
* over the video (i.e. watermarking). Ensure that the URL is active and persists
* the entire lifespan of the video object.
*/
export interface OverlaySettings {
/**
* How tall the overlay should appear. Can be expressed as a percent ("10%") or as
* a pixel value ("100px"). If both width and height are left blank the height will
* be the true pixels of the image, applied as if the video has been scaled to fit
* a 1920x1080 frame. If width is supplied with no height, the height will scale
* proportionally to the width.
*/
height?: string;
/**
* Where the horizontal positioning of the overlay/watermark should begin from.
*/
horizontal_align?: 'left' | 'center' | 'right';
/**
* The distance from the horizontal_align starting point and the image's closest
* edge. Can be expressed as a percent ("10%") or as a pixel value ("100px").
* Negative values will move the overlay offscreen. In the case of 'center', a
* positive value will shift the image towards the right and and a negative value
* will shift it towards the left.
*/
horizontal_margin?: string;
/**
* How opaque the overlay should appear, expressed as a percent. (Default 100%)
*/
opacity?: string;
/**
* Where the vertical positioning of the overlay/watermark should begin from.
* Defaults to `"top"`
*/
vertical_align?: 'top' | 'middle' | 'bottom';
/**
* The distance from the vertical_align starting point and the image's closest
* edge. Can be expressed as a percent ("10%") or as a pixel value ("100px").
* Negative values will move the overlay offscreen. In the case of 'middle', a
* positive value will shift the overlay towards the bottom and and a negative
* value will shift it towards the top.
*/
vertical_margin?: string;
/**
* How wide the overlay should appear. Can be expressed as a percent ("10%") or as
* a pixel value ("100px"). If both width and height are left blank the width will
* be the true pixels of the image, applied as if the video has been scaled to fit
* a 1920x1080 frame. If height is supplied with no width, the width will scale
* proportionally to the height.
*/
width?: string;
}
}
}
export interface AssetResponse {
data: Asset;
}
export interface InputInfo {
file?: InputInfo.File;
/**
* An array of objects that each describe an input file to be used to create the
* asset. As a shortcut, `input` can also be a string URL for a file when only one
* input file is used. See `input[].url` for requirements.
*/
settings?: InputInfo.Settings;
}
export namespace InputInfo {
export interface File {
container_format?: string;
tracks?: Array<File.Track>;
}
export namespace File {
export interface Track {
type: string;
channels?: number;
duration?: number;
encoding?: string;
frame_rate?: number;
height?: number;
sample_rate?: number;
sample_size?: number;
width?: number;
}
}
/**
* An array of objects that each describe an input file to be used to create the
* asset. As a shortcut, `input` can also be a string URL for a file when only one
* input file is used. See `input[].url` for requirements.
*/
export interface Settings {
/**
* Indicates the track provides Subtitles for the Deaf or Hard-of-hearing (SDH).
* This optional parameter should be used for tracks with `type` of `text` and
* `text_type` set to `subtitles`.
*/
closed_captions?: boolean;
/**
* The time offset in seconds from the beginning of the video, indicating the
* clip's ending marker. The default value is the duration of the video when not
* included. This parameter is only applicable for creating clips when `input.url`
* has `mux://assets/{asset_id}` format.
*/
end_time?: number;
/**
* Generate subtitle tracks using automatic speech recognition with this
* configuration. This may only be provided for the first input object (the main
* input file). For direct uploads, this first input should omit the url parameter,
* as the main input file is provided via the direct upload. This will create
* subtitles based on the audio track ingested from that main input file. Note that
* subtitle generation happens after initial ingest, so the generated tracks will
* be in the `preparing` state when the asset transitions to `ready`.
*/
generated_subtitles?: Array<Settings.GeneratedSubtitle>;
/**
* The language code value must be a valid
* [BCP 47](https://tools.ietf.org/html/bcp47) specification compliant value. For
* example, `en` for English or `en-US` for the US version of English. This
* parameter is required for `text` and `audio` track types.
*/
language_code?: string;
/**
* The name of the track containing a human-readable description. This value must
* be unique within each group of `text` or `audio` track types. The HLS manifest
* will associate a subtitle text track with this value. For example, the value
* should be "English" for a subtitle text track with `language_code` set to `en`.
* This optional parameter should be used only for `text` and `audio` type tracks.
* This parameter can be optionally provided for the first video input to denote
* the name of the muxed audio track if present. If this parameter is not included,
* Mux will auto-populate based on the `input[].language_code` value.
*/
name?: string;