0
# Asset Tracks Management
1
2
Management of individual tracks within media assets including audio, video, and text tracks. Provides comprehensive track metadata handling, track data updates, and long-running track operations for detailed media content control.
3
4
## Capabilities
5
6
### Track Listing and Retrieval
7
8
List and retrieve individual tracks within media assets with detailed metadata.
9
10
```python { .api }
11
def list(
12
resource_group_name: str,
13
account_name: str,
14
asset_name: str
15
) -> Iterable[AssetTrack]:
16
"""
17
List all tracks in a media asset.
18
19
Parameters:
20
- resource_group_name: Name of the resource group (str)
21
- account_name: Name of the media service account (str)
22
- asset_name: Name of the asset (str)
23
24
Returns:
25
Iterable of AssetTrack objects with track metadata and properties
26
"""
27
28
def get(
29
resource_group_name: str,
30
account_name: str,
31
asset_name: str,
32
track_name: str
33
) -> AssetTrack:
34
"""
35
Get a specific asset track with complete metadata.
36
37
Parameters:
38
- resource_group_name: Name of the resource group (str)
39
- account_name: Name of the media service account (str)
40
- asset_name: Name of the asset (str)
41
- track_name: Name of the track (str)
42
43
Returns:
44
AssetTrack object with detailed track information
45
"""
46
```
47
48
### Track Creation and Updates
49
50
Create and update asset tracks with long-running operation support for comprehensive track management.
51
52
```python { .api }
53
def begin_create_or_update(
54
resource_group_name: str,
55
account_name: str,
56
asset_name: str,
57
track_name: str,
58
parameters: AssetTrack
59
) -> LROPoller[AssetTrack]:
60
"""
61
Create or update an asset track.
62
63
Parameters:
64
- resource_group_name: Name of the resource group (str)
65
- account_name: Name of the media service account (str)
66
- asset_name: Name of the asset (str)
67
- track_name: Name for the track (str)
68
- parameters: Track configuration and metadata (AssetTrack)
69
70
Returns:
71
LROPoller for tracking the creation/update operation
72
"""
73
74
def begin_update(
75
resource_group_name: str,
76
account_name: str,
77
asset_name: str,
78
track_name: str,
79
parameters: AssetTrack
80
) -> LROPoller[AssetTrack]:
81
"""
82
Update an existing asset track.
83
84
Parameters:
85
- resource_group_name: Name of the resource group (str)
86
- account_name: Name of the media service account (str)
87
- asset_name: Name of the asset (str)
88
- track_name: Name of the track (str)
89
- parameters: Updated track configuration (AssetTrack)
90
91
Returns:
92
LROPoller for tracking the update operation
93
"""
94
95
def begin_delete(
96
resource_group_name: str,
97
account_name: str,
98
asset_name: str,
99
track_name: str
100
) -> LROPoller[None]:
101
"""
102
Delete an asset track.
103
104
Parameters:
105
- resource_group_name: Name of the resource group (str)
106
- account_name: Name of the media service account (str)
107
- asset_name: Name of the asset (str)
108
- track_name: Name of the track (str)
109
110
Returns:
111
LROPoller for tracking the deletion operation
112
"""
113
```
114
115
### Track Data Management
116
117
Update track data and content with specialized operations for track content modification.
118
119
```python { .api }
120
def begin_update_track_data(
121
resource_group_name: str,
122
account_name: str,
123
asset_name: str,
124
track_name: str
125
) -> LROPoller[None]:
126
"""
127
Update track data content.
128
129
Parameters:
130
- resource_group_name: Name of the resource group (str)
131
- account_name: Name of the media service account (str)
132
- asset_name: Name of the asset (str)
133
- track_name: Name of the track (str)
134
135
Returns:
136
LROPoller for tracking the track data update operation
137
"""
138
```
139
140
## Data Types
141
142
```python { .api }
143
class AssetTrack:
144
"""Individual track within a media asset."""
145
name: str
146
track: TrackBase
147
provisioning_state: str
148
149
class TrackBase:
150
"""Base class for different track types."""
151
pass
152
153
class AudioTrack(TrackBase):
154
"""Audio track with audio-specific properties."""
155
file_name: str
156
display_name: str
157
language_code: str
158
hls_settings: HlsSettings
159
dash_settings: DashSettings
160
mpeg4_track_id: int
161
bitrate: int
162
163
class VideoTrack(TrackBase):
164
"""Video track with video-specific properties."""
165
file_name: str
166
display_name: str
167
hls_settings: HlsSettings
168
dash_settings: DashSettings
169
mpeg4_track_id: int
170
bitrate: int
171
172
class TextTrack(TrackBase):
173
"""Text/subtitle track with text-specific properties."""
174
file_name: str
175
display_name: str
176
language_code: str
177
hls_settings: HlsSettings
178
dash_settings: DashSettings
179
player_visibility: str # Visible or Hidden
180
181
class HlsSettings:
182
"""HLS-specific track settings."""
183
name: str
184
group_id: str
185
default: bool
186
forced: bool
187
characteristics: str
188
189
class DashSettings:
190
"""DASH-specific track settings."""
191
role: str
192
accessibility: str
193
```
194
195
## Usage Examples
196
197
### List Asset Tracks
198
199
```python
200
from azure.mgmt.media import AzureMediaServices
201
from azure.identity import DefaultAzureCredential
202
203
client = AzureMediaServices(
204
credential=DefaultAzureCredential(),
205
subscription_id="your-subscription-id"
206
)
207
208
# List all tracks in an asset
209
tracks = client.tracks.list(
210
resource_group_name="my-resource-group",
211
account_name="my-media-service",
212
asset_name="multi-track-asset"
213
)
214
215
for track in tracks:
216
print(f"Track: {track.name}")
217
218
if isinstance(track.track, AudioTrack):
219
audio_track = track.track
220
print(f" Type: Audio")
221
print(f" Language: {audio_track.language_code}")
222
print(f" Bitrate: {audio_track.bitrate}")
223
print(f" File: {audio_track.file_name}")
224
225
elif isinstance(track.track, VideoTrack):
226
video_track = track.track
227
print(f" Type: Video")
228
print(f" Bitrate: {video_track.bitrate}")
229
print(f" File: {video_track.file_name}")
230
231
elif isinstance(track.track, TextTrack):
232
text_track = track.track
233
print(f" Type: Text/Subtitle")
234
print(f" Language: {text_track.language_code}")
235
print(f" Visibility: {text_track.player_visibility}")
236
print(f" File: {text_track.file_name}")
237
```
238
239
### Create Text Track for Subtitles
240
241
```python
242
from azure.mgmt.media.models import (
243
AssetTrack, TextTrack, HlsSettings, DashSettings
244
)
245
246
# Configure HLS settings for subtitle track
247
hls_settings = HlsSettings(
248
name="English Subtitles",
249
group_id="subtitles",
250
default=True,
251
forced=False,
252
characteristics="public.accessibility.describes-video"
253
)
254
255
# Configure DASH settings
256
dash_settings = DashSettings(
257
role="subtitle",
258
accessibility="urn:tva:metadata:cs:AudioPurposeCS:2007:1"
259
)
260
261
# Create text track
262
text_track = TextTrack(
263
file_name="subtitles_en.vtt",
264
display_name="English Subtitles",
265
language_code="en-US",
266
hls_settings=hls_settings,
267
dash_settings=dash_settings,
268
player_visibility="Visible"
269
)
270
271
asset_track = AssetTrack(track=text_track)
272
273
# Create the track
274
create_operation = client.tracks.begin_create_or_update(
275
resource_group_name="my-resource-group",
276
account_name="my-media-service",
277
asset_name="video-asset",
278
track_name="english-subtitles",
279
parameters=asset_track
280
)
281
282
created_track = create_operation.result()
283
print(f"Text track created: {created_track.name}")
284
```