-
Notifications
You must be signed in to change notification settings - Fork 60
/
live-streams.ts
1021 lines (910 loc) · 37.6 KB
/
live-streams.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 LiveStreamsAPI from '@mux/mux-node/resources/video/live-streams';
import * as Shared from '@mux/mux-node/resources/shared';
import * as AssetsAPI from '@mux/mux-node/resources/video/assets';
import { BasePage, type BasePageParams } from '@mux/mux-node/pagination';
export class LiveStreams extends APIResource {
/**
* Creates a new live stream. Once created, an encoder can connect to Mux via the
* specified stream key and begin streaming to an audience.
*/
create(body: LiveStreamCreateParams, options?: Core.RequestOptions): Core.APIPromise<LiveStream> {
return (
this._client.post('/video/v1/live-streams', { body, ...options }) as Core.APIPromise<{
data: LiveStream;
}>
)._thenUnwrap((obj) => obj.data);
}
/**
* Retrieves the details of a live stream that has previously been created. Supply
* the unique live stream ID that was returned from your previous request, and Mux
* will return the corresponding live stream information. The same information is
* returned when creating a live stream.
*/
retrieve(liveStreamId: string, options?: Core.RequestOptions): Core.APIPromise<LiveStream> {
return (
this._client.get(`/video/v1/live-streams/${liveStreamId}`, options) as Core.APIPromise<{
data: LiveStream;
}>
)._thenUnwrap((obj) => obj.data);
}
/**
* Updates the parameters of a previously-created live stream. This currently
* supports a subset of variables. Supply the live stream ID and the updated
* parameters and Mux will return the corresponding live stream information. The
* information returned will be the same after update as for subsequent get live
* stream requests.
*/
update(
liveStreamId: string,
body: LiveStreamUpdateParams,
options?: Core.RequestOptions,
): Core.APIPromise<LiveStream> {
return (
this._client.patch(`/video/v1/live-streams/${liveStreamId}`, { body, ...options }) as Core.APIPromise<{
data: LiveStream;
}>
)._thenUnwrap((obj) => obj.data);
}
/**
* Lists the live streams that currently exist in the current environment.
*/
list(
query?: LiveStreamListParams,
options?: Core.RequestOptions,
): Core.PagePromise<LiveStreamsBasePage, LiveStream>;
list(options?: Core.RequestOptions): Core.PagePromise<LiveStreamsBasePage, LiveStream>;
list(
query: LiveStreamListParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.PagePromise<LiveStreamsBasePage, LiveStream> {
if (isRequestOptions(query)) {
return this.list({}, query);
}
return this._client.getAPIList('/video/v1/live-streams', LiveStreamsBasePage, { query, ...options });
}
/**
* Deletes a live stream from the current environment. If the live stream is
* currently active and being streamed to, ingest will be terminated and the
* encoder will be disconnected.
*/
delete(liveStreamId: string, options?: Core.RequestOptions): Core.APIPromise<void> {
return this._client.delete(`/video/v1/live-streams/${liveStreamId}`, {
...options,
headers: { Accept: '*/*', ...options?.headers },
});
}
/**
* (Optional) End the live stream recording immediately instead of waiting for the
* reconnect_window. `EXT-X-ENDLIST` tag is added to the HLS manifest which
* notifies the player that this live stream is over.
*
* Mux does not close the encoder connection immediately. Encoders are often
* configured to re-establish connections immediately which would result in a new
* recorded asset. For this reason, Mux waits for 60s before closing the connection
* with the encoder. This 60s timeframe is meant to give encoder operators a chance
* to disconnect from their end.
*/
complete(liveStreamId: string, options?: Core.RequestOptions): Core.APIPromise<void> {
return this._client.put(`/video/v1/live-streams/${liveStreamId}/complete`, {
...options,
headers: { Accept: '*/*', ...options?.headers },
});
}
/**
* Create a new playback ID for this live stream, through which a viewer can watch
* the streamed content of the live stream.
*/
createPlaybackId(
liveStreamId: string,
body: LiveStreamCreatePlaybackIDParams,
options?: Core.RequestOptions,
): Core.APIPromise<Shared.PlaybackID> {
return (
this._client.post(`/video/v1/live-streams/${liveStreamId}/playback-ids`, {
body,
...options,
}) as Core.APIPromise<{ data: Shared.PlaybackID }>
)._thenUnwrap((obj) => obj.data);
}
/**
* Create a simulcast target for the parent live stream. Simulcast target can only
* be created when the parent live stream is in idle state. Only one simulcast
* target can be created at a time with this API.
*/
createSimulcastTarget(
liveStreamId: string,
body: LiveStreamCreateSimulcastTargetParams,
options?: Core.RequestOptions,
): Core.APIPromise<SimulcastTarget> {
return (
this._client.post(`/video/v1/live-streams/${liveStreamId}/simulcast-targets`, {
body,
...options,
}) as Core.APIPromise<{ data: SimulcastTarget }>
)._thenUnwrap((obj) => obj.data);
}
/**
* Deletes the playback ID for the live stream. This will not disable ingest (as
* the live stream still exists). New attempts to play back the live stream will
* fail immediately. However, current viewers will be able to continue watching the
* stream for some period of time.
*/
deletePlaybackId(
liveStreamId: string,
playbackId: string,
options?: Core.RequestOptions,
): Core.APIPromise<void> {
return this._client.delete(`/video/v1/live-streams/${liveStreamId}/playback-ids/${playbackId}`, {
...options,
headers: { Accept: '*/*', ...options?.headers },
});
}
/**
* Delete the simulcast target using the simulcast target ID returned when creating
* the simulcast target. Simulcast Target can only be deleted when the parent live
* stream is in idle state.
*/
deleteSimulcastTarget(
liveStreamId: string,
simulcastTargetId: string,
options?: Core.RequestOptions,
): Core.APIPromise<void> {
return this._client.delete(
`/video/v1/live-streams/${liveStreamId}/simulcast-targets/${simulcastTargetId}`,
{ ...options, headers: { Accept: '*/*', ...options?.headers } },
);
}
/**
* Disables a live stream, making it reject incoming RTMP streams until re-enabled.
* The API also ends the live stream recording immediately when active. Ending the
* live stream recording adds the `EXT-X-ENDLIST` tag to the HLS manifest which
* notifies the player that this live stream is over.
*
* Mux also closes the encoder connection immediately. Any attempt from the encoder
* to re-establish connection will fail till the live stream is re-enabled.
*/
disable(liveStreamId: string, options?: Core.RequestOptions): Core.APIPromise<void> {
return this._client.put(`/video/v1/live-streams/${liveStreamId}/disable`, {
...options,
headers: { Accept: '*/*', ...options?.headers },
});
}
/**
* Enables a live stream, allowing it to accept an incoming RTMP stream.
*/
enable(liveStreamId: string, options?: Core.RequestOptions): Core.APIPromise<void> {
return this._client.put(`/video/v1/live-streams/${liveStreamId}/enable`, {
...options,
headers: { Accept: '*/*', ...options?.headers },
});
}
/**
* Reset a live stream key if you want to immediately stop the current stream key
* from working and create a new stream key that can be used for future broadcasts.
*/
resetStreamKey(liveStreamId: string, options?: Core.RequestOptions): Core.APIPromise<LiveStream> {
return (
this._client.post(
`/video/v1/live-streams/${liveStreamId}/reset-stream-key`,
options,
) as Core.APIPromise<{ data: LiveStream }>
)._thenUnwrap((obj) => obj.data);
}
/**
* Fetches information about a live stream's playback ID, through which a viewer
* can watch the streamed content from this live stream.
*/
retrievePlaybackId(
liveStreamId: string,
playbackId: string,
options?: Core.RequestOptions,
): Core.APIPromise<Shared.PlaybackID> {
return (
this._client.get(
`/video/v1/live-streams/${liveStreamId}/playback-ids/${playbackId}`,
options,
) as Core.APIPromise<{ data: Shared.PlaybackID }>
)._thenUnwrap((obj) => obj.data);
}
/**
* Retrieves the details of the simulcast target created for the parent live
* stream. Supply the unique live stream ID and simulcast target ID that was
* returned in the response of create simulcast target request, and Mux will return
* the corresponding information.
*/
retrieveSimulcastTarget(
liveStreamId: string,
simulcastTargetId: string,
options?: Core.RequestOptions,
): Core.APIPromise<SimulcastTarget> {
return (
this._client.get(
`/video/v1/live-streams/${liveStreamId}/simulcast-targets/${simulcastTargetId}`,
options,
) as Core.APIPromise<{ data: SimulcastTarget }>
)._thenUnwrap((obj) => obj.data);
}
/**
* Configures a live stream to receive embedded closed captions. The resulting
* Asset's subtitle text track will have `closed_captions: true` set.
*/
updateEmbeddedSubtitles(
liveStreamId: string,
body: LiveStreamUpdateEmbeddedSubtitlesParams,
options?: Core.RequestOptions,
): Core.APIPromise<LiveStream> {
return (
this._client.put(`/video/v1/live-streams/${liveStreamId}/embedded-subtitles`, {
body,
...options,
}) as Core.APIPromise<{ data: LiveStream }>
)._thenUnwrap((obj) => obj.data);
}
/**
* Updates a live stream's automatic-speech-recognition-generated subtitle
* configuration. Automatic speech recognition subtitles can be removed by sending
* an empty array in the request payload.
*/
updateGeneratedSubtitles(
liveStreamId: string,
body: LiveStreamUpdateGeneratedSubtitlesParams,
options?: Core.RequestOptions,
): Core.APIPromise<LiveStream> {
return (
this._client.put(`/video/v1/live-streams/${liveStreamId}/generated-subtitles`, {
body,
...options,
}) as Core.APIPromise<{ data: LiveStream }>
)._thenUnwrap((obj) => obj.data);
}
}
export class LiveStreamsBasePage extends BasePage<LiveStream> {}
export interface LiveStream {
/**
* Unique identifier for the Live Stream. Max 255 characters.
*/
id: string;
/**
* Time the Live Stream was created, defined as a Unix timestamp (seconds since
* epoch).
*/
created_at: string;
/**
* Latency is the time from when the streamer transmits a frame of video to when
* you see it in the player. Set this as an alternative to setting low latency or
* reduced latency flags.
*/
latency_mode: 'low' | 'reduced' | 'standard';
/**
* The time in seconds a live stream may be continuously active before being
* disconnected. Defaults to 12 hours.
*/
max_continuous_duration: number;
/**
* `idle` indicates that there is no active broadcast. `active` indicates that
* there is an active broadcast and `disabled` status indicates that no future RTMP
* streams can be published.
*/
status: 'active' | 'idle' | 'disabled';
/**
* Unique key used for streaming to a Mux RTMP endpoint. This should be considered
* as sensitive as credentials, anyone with this stream key can begin streaming.
*/
stream_key: string;
/**
* The Asset that is currently being created if there is an active broadcast.
*/
active_asset_id?: string;
/**
* The protocol used for the active ingest stream. This is only set when the live
* stream is active.
*/
active_ingest_protocol?: 'rtmp' | 'srt';
/**
* The live stream only processes the audio track if the value is set to true. Mux
* drops the video track if broadcasted.
*/
audio_only?: boolean;
/**
* Describes the embedded closed caption configuration of the incoming live stream.
*/
embedded_subtitles?: Array<LiveStream.EmbeddedSubtitle>;
/**
* Configure the incoming live stream to include subtitles created with automatic
* speech recognition. Each Asset created from a live stream with
* `generated_subtitles` configured will automatically receive two text tracks. The
* first of these will have a `text_source` value of `generated_live`, and will be
* available with `ready` status as soon as the stream is live. The second text
* track will have a `text_source` value of `generated_live_final` and will contain
* subtitles with improved accuracy, timing, and formatting. However,
* `generated_live_final` tracks will not be available in `ready` status until the
* live stream ends. If an Asset has both `generated_live` and
* `generated_live_final` tracks that are `ready`, then only the
* `generated_live_final` track will be included during playback.
*/
generated_subtitles?: Array<LiveStream.GeneratedSubtitle>;
/**
* @deprecated: This field is deprecated. Please use `latency_mode` instead.
* Latency is the time from when the streamer transmits a frame of video to when
* you see it in the player. Setting this option will enable compatibility with the
* LL-HLS specification for low-latency streaming. This typically has lower latency
* than Reduced Latency streams, and cannot be combined with Reduced Latency.
*/
low_latency?: boolean;
new_asset_settings?: AssetsAPI.AssetOptions;
/**
* Arbitrary user-supplied metadata set for the asset. Max 255 characters.
*/
passthrough?: string;
/**
* 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 strings with the most recent Asset IDs that were created from this
* Live Stream. The most recently generated Asset ID is the last entry in the list.
*/
recent_asset_ids?: Array<string>;
/**
* The URL of the image file that Mux should download and use as slate media during
* interruptions of the live stream media. This file will be downloaded each time a
* new recorded asset is created from the live stream. If this is not set, the
* default slate media will be used.
*/
reconnect_slate_url?: string;
/**
* When live streaming software disconnects from Mux, either intentionally or due
* to a drop in the network, the Reconnect Window is the time in seconds that Mux
* should wait for the streaming software to reconnect before considering the live
* stream finished and completing the recorded asset. **Max**: 1800s (30 minutes).
*
* If not specified directly, Standard Latency streams have a Reconnect Window of
* 60 seconds; Reduced and Low Latency streams have a default of 0 seconds, or no
* Reconnect Window. For that reason, we suggest specifying a value other than zero
* for Reduced and Low Latency streams.
*
* Reduced and Low Latency streams with a Reconnect Window greater than zero will
* insert slate media into the recorded asset while waiting for the streaming
* software to reconnect or when there are brief interruptions in the live stream
* media. When using a Reconnect Window setting higher than 60 seconds with a
* Standard Latency stream, we highly recommend enabling slate with the
* `use_slate_for_standard_latency` option.
*/
reconnect_window?: number;
/**
* @deprecated: This field is deprecated. Please use `latency_mode` instead.
* Latency is the time from when the streamer transmits a frame of video to when
* you see it in the player. Set this if you want lower latency for your live
* stream. See the
* [Reduce live stream latency guide](https://docs.mux.com/guides/reduce-live-stream-latency)
* to understand the tradeoffs.
*/
reduced_latency?: boolean;
/**
* Each Simulcast Target contains configuration details to broadcast (or
* "restream") a live stream to a third-party streaming service.
* [See the Stream live to 3rd party platforms guide](https://docs.mux.com/guides/stream-live-to-3rd-party-platforms).
*/
simulcast_targets?: Array<SimulcastTarget>;
/**
* Unique key used for encrypting a stream to a Mux SRT endpoint.
*/
srt_passphrase?: string;
/**
* True means this live stream is a test live stream. Test live streams can be used
* to help evaluate the Mux Video APIs for free. There is no limit on the number of
* test live streams, but they are watermarked with the Mux logo, and limited to 5
* minutes. The test live stream is disabled after the stream is active for 5 mins
* and the recorded asset also deleted after 24 hours.
*/
test?: boolean;
/**
* By default, Standard Latency live streams do not have slate media inserted while
* waiting for live streaming software to reconnect to Mux. Setting this to true
* enables slate insertion on a Standard Latency stream.
*/
use_slate_for_standard_latency?: boolean;
}
export namespace LiveStream {
export interface EmbeddedSubtitle {
/**
* CEA-608 caption channel to read data from.
*/
language_channel: 'cc1' | 'cc2' | 'cc3' | 'cc4';
/**
* The language of the closed caption stream. Value must be BCP 47 compliant.
*/
language_code: string;
/**
* A name for this live stream closed caption track.
*/
name: string;
/**
* Arbitrary user-supplied metadata set for the live stream closed caption track.
* Max 255 characters.
*/
passthrough?: string;
}
export interface GeneratedSubtitle {
/**
* The language to generate subtitles in.
*/
language_code: 'en' | 'en-US';
/**
* A name for this live stream subtitle track.
*/
name: string;
/**
* Arbitrary metadata set for the live stream subtitle track. Max 255 characters.
*/
passthrough?: string;
/**
* Unique identifiers for existing Transcription Vocabularies to use while
* generating subtitles for the live stream. If the Transcription Vocabularies
* provided collectively have more than 1000 phrases, only the first 1000 phrases
* will be included.
*/
transcription_vocabulary_ids?: Array<string>;
}
}
export interface SimulcastTarget {
/**
* ID of the Simulcast Target
*/
id: string;
/**
* The current status of the simulcast target. See Statuses below for detailed
* description.
*
* - `idle`: Default status. When the parent live stream is in disconnected status,
* simulcast targets will be idle state.
* - `starting`: The simulcast target transitions into this state when the parent
* live stream transition into connected state.
* - `broadcasting`: The simulcast target has successfully connected to the third
* party live streaming service and is pushing video to that service.
* - `errored`: The simulcast target encountered an error either while attempting
* to connect to the third party live streaming service, or mid-broadcasting.
* When a simulcast target has this status it will have an `error_severity` field
* with more details about the error.
*/
status: 'idle' | 'starting' | 'broadcasting' | 'errored';
/**
* The RTMP(s) or SRT endpoint for a simulcast destination.
*
* - For RTMP(s) destinations, this should include the application name for the
* third party live streaming service, for example:
* `rtmp://live.example.com/app`.
* - For SRT destinations, this should be a fully formed SRT connection string, for
* example:
* `srt://srt-live.example.com:1234?streamid={stream_key}&passphrase={srt_passphrase}`.
*
* Note: SRT simulcast targets can only be used when an source is connected over
* SRT.
*/
url: string;
/**
* The severity of the error encountered by the simulcast target. This field is
* only set when the simulcast target is in the `errored` status. See the values of
* severities below and their descriptions.
*
* - `normal`: The simulcast target encountered an error either while attempting to
* connect to the third party live streaming service, or mid-broadcasting. A
* simulcast may transition back into the broadcasting state if a connection with
* the service can be re-established.
* - `fatal`: The simulcast target is incompatible with the current input to the
* parent live stream. No further attempts to this simulcast target will be made
* for the current live stream asset.
*/
error_severity?: 'normal' | 'fatal';
/**
* Arbitrary user-supplied metadata set when creating a simulcast target.
*/
passthrough?: string;
/**
* Stream Key represents a stream identifier on the third party live streaming
* service to send the parent live stream to. Only used for RTMP(s) simulcast
* destinations.
*/
stream_key?: string;
}
export interface LiveStreamCreateParams {
/**
* 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<LiveStreamCreateParams.AdvancedPlaybackPolicy>;
/**
* Force the live stream to only process the audio track when the value is set to
* true. Mux drops the video track if broadcasted.
*/
audio_only?: boolean;
/**
* Describe the embedded closed caption contents of the incoming live stream.
*/
embedded_subtitles?: Array<LiveStreamCreateParams.EmbeddedSubtitle>;
/**
* Configure the incoming live stream to include subtitles created with automatic
* speech recognition. Each Asset created from a live stream with
* `generated_subtitles` configured will automatically receive two text tracks. The
* first of these will have a `text_source` value of `generated_live`, and will be
* available with `ready` status as soon as the stream is live. The second text
* track will have a `text_source` value of `generated_live_final` and will contain
* subtitles with improved accuracy, timing, and formatting. However,
* `generated_live_final` tracks will not be available in `ready` status until the
* live stream ends. If an Asset has both `generated_live` and
* `generated_live_final` tracks that are `ready`, then only the
* `generated_live_final` track will be included during playback.
*/
generated_subtitles?: Array<LiveStreamCreateParams.GeneratedSubtitle>;
/**
* Latency is the time from when the streamer transmits a frame of video to when
* you see it in the player. Set this as an alternative to setting low latency or
* reduced latency flags.
*/
latency_mode?: 'low' | 'reduced' | 'standard';
/**
* This field is deprecated. Please use `latency_mode` instead. Latency is the time
* from when the streamer transmits a frame of video to when you see it in the
* player. Setting this option will enable compatibility with the LL-HLS
* specification for low-latency streaming. This typically has lower latency than
* Reduced Latency streams, and cannot be combined with Reduced Latency.
*/
low_latency?: boolean;
/**
* The time in seconds a live stream may be continuously active before being
* disconnected. Defaults to 12 hours.
*/
max_continuous_duration?: number;
new_asset_settings?: AssetsAPI.AssetOptions;
passthrough?: string;
playback_policy?: Array<Shared.PlaybackPolicy>;
/**
* The URL of the image file that Mux should download and use as slate media during
* interruptions of the live stream media. This file will be downloaded each time a
* new recorded asset is created from the live stream. If this is not set, the
* default slate media will be used.
*/
reconnect_slate_url?: string;
/**
* When live streaming software disconnects from Mux, either intentionally or due
* to a drop in the network, the Reconnect Window is the time in seconds that Mux
* should wait for the streaming software to reconnect before considering the live
* stream finished and completing the recorded asset. Defaults to 60 seconds on the
* API if not specified.
*
* If not specified directly, Standard Latency streams have a Reconnect Window of
* 60 seconds; Reduced and Low Latency streams have a default of 0 seconds, or no
* Reconnect Window. For that reason, we suggest specifying a value other than zero
* for Reduced and Low Latency streams.
*
* Reduced and Low Latency streams with a Reconnect Window greater than zero will
* insert slate media into the recorded asset while waiting for the streaming
* software to reconnect or when there are brief interruptions in the live stream
* media. When using a Reconnect Window setting higher than 60 seconds with a
* Standard Latency stream, we highly recommend enabling slate with the
* `use_slate_for_standard_latency` option.
*/
reconnect_window?: number;
/**
* This field is deprecated. Please use `latency_mode` instead. Latency is the time
* from when the streamer transmits a frame of video to when you see it in the
* player. Set this if you want lower latency for your live stream. Read more here:
* https://mux.com/blog/reduced-latency-for-mux-live-streaming-now-available/
*/
reduced_latency?: boolean;
simulcast_targets?: Array<LiveStreamCreateParams.SimulcastTarget>;
/**
* Marks the live stream as a test live stream when the value is set to true. A
* test live stream can help evaluate the Mux Video APIs without incurring any
* cost. There is no limit on number of test live streams created. Test live
* streams are watermarked with the Mux logo and limited to 5 minutes. The test
* live stream is disabled after the stream is active for 5 mins and the recorded
* asset also deleted after 24 hours.
*/
test?: boolean;
/**
* By default, Standard Latency live streams do not have slate media inserted while
* waiting for live streaming software to reconnect to Mux. Setting this to true
* enables slate insertion on a Standard Latency stream.
*/
use_slate_for_standard_latency?: boolean;
}
export namespace LiveStreamCreateParams {
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;
}
export interface EmbeddedSubtitle {
/**
* CEA-608 caption channel to read data from.
*/
language_channel?: 'cc1' | 'cc2' | 'cc3' | 'cc4';
/**
* The language of the closed caption stream. Value must be BCP 47 compliant.
*/
language_code?: string;
/**
* A name for this live stream closed caption track.
*/
name?: string;
/**
* Arbitrary user-supplied metadata set for the live stream closed caption track.
* Max 255 characters.
*/
passthrough?: string;
}
export interface GeneratedSubtitle {
/**
* The language to generate subtitles in.
*/
language_code?: 'en' | 'en-US';
/**
* A name for this live stream subtitle track.
*/
name?: string;
/**
* Arbitrary metadata set for the live stream subtitle track. Max 255 characters.
*/
passthrough?: string;
/**
* Unique identifiers for existing Transcription Vocabularies to use while
* generating subtitles for the live stream. If the Transcription Vocabularies
* provided collectively have more than 1000 phrases, only the first 1000 phrases
* will be included.
*/
transcription_vocabulary_ids?: Array<string>;
}
export interface SimulcastTarget {
/**
* The RTMP(s) or SRT endpoint for a simulcast destination.
*
* - For RTMP(s) destinations, this should include the application name for the
* third party live streaming service, for example:
* `rtmp://live.example.com/app`.
* - For SRT destinations, this should be a fully formed SRT connection string, for
* example:
* `srt://srt-live.example.com:1234?streamid={stream_key}&passphrase={srt_passphrase}`.
*
* Note: SRT simulcast targets can only be used when an source is connected over
* SRT.
*/
url: string;
/**
* Arbitrary user-supplied metadata set by you when creating a simulcast target.
*/
passthrough?: string;
/**
* Stream Key represents a stream identifier on the third party live streaming
* service to send the parent live stream to. Only used for RTMP(s) simulcast
* destinations.
*/
stream_key?: string;
}
}
export interface LiveStreamUpdateParams {
/**
* Latency is the time from when the streamer transmits a frame of video to when
* you see it in the player. Set this as an alternative to setting low latency or
* reduced latency flags.
*/
latency_mode?: 'low' | 'reduced' | 'standard';
/**
* The time in seconds a live stream may be continuously active before being
* disconnected. Defaults to 12 hours.
*/
max_continuous_duration?: number;
/**
* Updates the new asset settings to use to generate a new asset for this live
* stream. Only the `mp4_support` setting may be updated.
*/
new_asset_settings?: LiveStreamUpdateParams.NewAssetSettings;
/**
* Arbitrary user-supplied metadata set for the live stream. Max 255 characters. In
* order to clear this value, the field should be included with an empty-string
* value.
*/
passthrough?: string;
/**
* The URL of the image file that Mux should download and use as slate media during
* interruptions of the live stream media. This file will be downloaded each time a
* new recorded asset is created from the live stream. Set this to a blank string
* to clear the value so that the default slate media will be used.
*/
reconnect_slate_url?: string;
/**
* When live streaming software disconnects from Mux, either intentionally or due
* to a drop in the network, the Reconnect Window is the time in seconds that Mux
* should wait for the streaming software to reconnect before considering the live
* stream finished and completing the recorded asset.
*
* If not specified directly, Standard Latency streams have a Reconnect Window of
* 60 seconds; Reduced and Low Latency streams have a default of 0 seconds, or no
* Reconnect Window. For that reason, we suggest specifying a value other than zero
* for Reduced and Low Latency streams.
*
* Reduced and Low Latency streams with a Reconnect Window greater than zero will
* insert slate media into the recorded asset while waiting for the streaming
* software to reconnect or when there are brief interruptions in the live stream
* media. When using a Reconnect Window setting higher than 60 seconds with a
* Standard Latency stream, we highly recommend enabling slate with the
* `use_slate_for_standard_latency` option.
*/
reconnect_window?: number;
/**
* By default, Standard Latency live streams do not have slate media inserted while
* waiting for live streaming software to reconnect to Mux. Setting this to true
* enables slate insertion on a Standard Latency stream.
*/
use_slate_for_standard_latency?: boolean;
}
export namespace LiveStreamUpdateParams {
/**
* Updates the new asset settings to use to generate a new asset for this live
* stream. Only the `mp4_support` setting may be updated.
*/
export interface NewAssetSettings {
/**
* Specify what level of support for mp4 playback should be added to new assets
* generated from this live stream.
*
* - The `none` option disables MP4 support for new assets. MP4 files will not be
* produced for an asset generated from this live stream.
* - 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_support?: 'none' | 'standard' | 'capped-1080p' | 'audio-only' | 'audio-only,capped-1080p';
}
}
export interface LiveStreamListParams extends BasePageParams {
/**
* Filter response to return live streams with the specified status only
*/
status?: 'active' | 'idle' | 'disabled';
/**
* Filter response to return live stream for this stream key only
*/
stream_key?: string;
}
export interface LiveStreamCreatePlaybackIDParams {
/**
* 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;
}
export interface LiveStreamCreateSimulcastTargetParams {
/**
* The RTMP(s) or SRT endpoint for a simulcast destination.
*
* - For RTMP(s) destinations, this should include the application name for the
* third party live streaming service, for example:
* `rtmp://live.example.com/app`.
* - For SRT destinations, this should be a fully formed SRT connection string, for
* example:
* `srt://srt-live.example.com:1234?streamid={stream_key}&passphrase={srt_passphrase}`.
*
* Note: SRT simulcast targets can only be used when an source is connected over
* SRT.
*/
url: string;
/**
* Arbitrary user-supplied metadata set by you when creating a simulcast target.
*/
passthrough?: string;
/**
* Stream Key represents a stream identifier on the third party live streaming
* service to send the parent live stream to. Only used for RTMP(s) simulcast
* destinations.
*/
stream_key?: string;
}
export interface LiveStreamUpdateEmbeddedSubtitlesParams {
/**
* Describe the embedded closed caption contents of the incoming live stream.
*/
embedded_subtitles?: Array<LiveStreamUpdateEmbeddedSubtitlesParams.EmbeddedSubtitle>;
}
export namespace LiveStreamUpdateEmbeddedSubtitlesParams {
export interface EmbeddedSubtitle {
/**
* CEA-608 caption channel to read data from.
*/
language_channel?: 'cc1' | 'cc2' | 'cc3' | 'cc4';
/**
* The language of the closed caption stream. Value must be BCP 47 compliant.
*/
language_code?: string;
/**
* A name for this live stream closed caption track.
*/
name?: string;
/**
* Arbitrary user-supplied metadata set for the live stream closed caption track.
* Max 255 characters.
*/
passthrough?: string;
}
}
export interface LiveStreamUpdateGeneratedSubtitlesParams {
/**
* Update automated speech recognition subtitle configuration for a live stream. At
* most one subtitle track is allowed.
*/
generated_subtitles?: Array<LiveStreamUpdateGeneratedSubtitlesParams.GeneratedSubtitle>;
}
export namespace LiveStreamUpdateGeneratedSubtitlesParams {
export interface GeneratedSubtitle {
/**
* The language to generate subtitles in.
*/
language_code?: 'en' | 'en-US';
/**
* A name for this live stream subtitle track.
*/
name?: string;
/**
* Arbitrary metadata set for the live stream subtitle track. Max 255 characters.
*/
passthrough?: string;
/**