or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

asset-management.mdasset-tracks.mdcontent-delivery-streaming.mdcontent-protection.mdencoding-transforms.mdindex.mdlive-streaming.mdlocation-management.mdmedia-filters.mdmedia-services-management.mdnetwork-security.mdoperations-monitoring.md

encoding-transforms.mddocs/

0

# Encoding and Transforms

1

2

Comprehensive encoding and media processing capabilities through transforms (reusable job templates) and jobs (individual processing instances). This system enables video transcoding, audio processing, content analysis, thumbnail generation, and media format conversion with support for both built-in and custom encoding configurations.

3

4

## Capabilities

5

6

### Transform Management

7

8

Create and manage encoding transforms that serve as templates for media processing jobs.

9

10

```python { .api }

11

def list(resource_group_name: str, account_name: str) -> Iterable[Transform]:

12

"""

13

List all transforms in a media service account.

14

15

Parameters:

16

- resource_group_name: Name of the resource group (str)

17

- account_name: Name of the media service account (str)

18

19

Returns:

20

Iterable of Transform objects containing processing configurations

21

"""

22

23

def get(resource_group_name: str, account_name: str, transform_name: str) -> Transform:

24

"""

25

Get a specific transform with complete configuration.

26

27

Parameters:

28

- resource_group_name: Name of the resource group (str)

29

- account_name: Name of the media service account (str)

30

- transform_name: Name of the transform (str)

31

32

Returns:

33

Transform object with preset and output configurations

34

"""

35

36

def create_or_update(

37

resource_group_name: str,

38

account_name: str,

39

transform_name: str,

40

parameters: Transform

41

) -> Transform:

42

"""

43

Create or update a transform with encoding presets.

44

45

Parameters:

46

- resource_group_name: Name of the resource group (str)

47

- account_name: Name of the media service account (str)

48

- transform_name: Name of the transform (str)

49

- parameters: Transform configuration with presets (Transform)

50

51

Returns:

52

Created or updated Transform object

53

"""

54

55

def update(

56

resource_group_name: str,

57

account_name: str,

58

transform_name: str,

59

parameters: Transform

60

) -> Transform:

61

"""

62

Update an existing transform configuration.

63

64

Parameters:

65

- resource_group_name: Name of the resource group (str)

66

- account_name: Name of the media service account (str)

67

- transform_name: Name of the transform (str)

68

- parameters: Updated transform configuration (Transform)

69

70

Returns:

71

Updated Transform object

72

"""

73

74

def delete(resource_group_name: str, account_name: str, transform_name: str) -> None:

75

"""

76

Delete a transform.

77

78

Parameters:

79

- resource_group_name: Name of the resource group (str)

80

- account_name: Name of the media service account (str)

81

- transform_name: Name of the transform (str)

82

83

Returns:

84

None

85

"""

86

```

87

88

### Job Management

89

90

Create, monitor, and manage encoding jobs based on transform templates.

91

92

```python { .api }

93

def list(resource_group_name: str, account_name: str, transform_name: str) -> Iterable[Job]:

94

"""

95

List all jobs for a specific transform.

96

97

Parameters:

98

- resource_group_name: Name of the resource group (str)

99

- account_name: Name of the media service account (str)

100

- transform_name: Name of the transform (str)

101

102

Returns:

103

Iterable of Job objects with processing status and details

104

"""

105

106

def get(

107

resource_group_name: str,

108

account_name: str,

109

transform_name: str,

110

job_name: str

111

) -> Job:

112

"""

113

Get a specific job with detailed status and progress information.

114

115

Parameters:

116

- resource_group_name: Name of the resource group (str)

117

- account_name: Name of the media service account (str)

118

- transform_name: Name of the transform (str)

119

- job_name: Name of the job (str)

120

121

Returns:

122

Job object with current state, progress, and error information

123

"""

124

125

def create(

126

resource_group_name: str,

127

account_name: str,

128

transform_name: str,

129

job_name: str,

130

parameters: Job

131

) -> Job:

132

"""

133

Create a new encoding job from a transform.

134

135

Parameters:

136

- resource_group_name: Name of the resource group (str)

137

- account_name: Name of the media service account (str)

138

- transform_name: Name of the transform (str)

139

- job_name: Name for the new job (str)

140

- parameters: Job configuration with input and output (Job)

141

142

Returns:

143

Created Job object with initial status

144

"""

145

146

def update(

147

resource_group_name: str,

148

account_name: str,

149

transform_name: str,

150

job_name: str,

151

parameters: Job

152

) -> Job:

153

"""

154

Update job properties such as description or priority.

155

156

Parameters:

157

- resource_group_name: Name of the resource group (str)

158

- account_name: Name of the media service account (str)

159

- transform_name: Name of the transform (str)

160

- job_name: Name of the job (str)

161

- parameters: Updated job configuration (Job)

162

163

Returns:

164

Updated Job object

165

"""

166

167

def delete(

168

resource_group_name: str,

169

account_name: str,

170

transform_name: str,

171

job_name: str

172

) -> None:

173

"""

174

Delete a job.

175

176

Parameters:

177

- resource_group_name: Name of the resource group (str)

178

- account_name: Name of the media service account (str)

179

- transform_name: Name of the transform (str)

180

- job_name: Name of the job (str)

181

182

Returns:

183

None

184

"""

185

186

def cancel_job(

187

resource_group_name: str,

188

account_name: str,

189

transform_name: str,

190

job_name: str

191

) -> None:

192

"""

193

Cancel a running job.

194

195

Parameters:

196

- resource_group_name: Name of the resource group (str)

197

- account_name: Name of the media service account (str)

198

- transform_name: Name of the transform (str)

199

- job_name: Name of the job (str)

200

201

Returns:

202

None

203

"""

204

```

205

206

## Data Types

207

208

```python { .api }

209

class Transform:

210

"""Encoding transform template defining processing operations."""

211

name: str

212

description: str

213

outputs: List[TransformOutput]

214

created: str

215

last_modified: str

216

217

class TransformOutput:

218

"""Output configuration for a transform."""

219

preset: Preset

220

on_error: str # OnErrorType enum (StopProcessingJob, ContinueJob)

221

relative_priority: str # Priority enum (Low, Normal, High)

222

223

class Job:

224

"""Encoding or analysis job instance."""

225

name: str

226

description: str

227

input: JobInput

228

outputs: List[JobOutput]

229

priority: str # Priority enum

230

correlationData: dict

231

state: str # JobState enum

232

created: str

233

last_modified: str

234

start_time: str

235

end_time: str

236

237

class JobInput:

238

"""Base class for job inputs."""

239

pass

240

241

class JobInputAsset(JobInput):

242

"""Asset-based job input."""

243

asset_name: str

244

files: List[str]

245

start: str

246

end: str

247

label: str

248

249

class JobInputHttp(JobInput):

250

"""HTTP-based job input."""

251

base_uri: str

252

files: List[str]

253

start: str

254

end: str

255

label: str

256

257

class JobOutput:

258

"""Base class for job outputs."""

259

label: str

260

error: JobError

261

state: str # JobState enum

262

progress: int

263

264

class JobOutputAsset(JobOutput):

265

"""Asset-based job output."""

266

asset_name: str

267

268

# Encoding Presets

269

class Preset:

270

"""Base class for encoding presets."""

271

pass

272

273

class BuiltInStandardEncoderPreset(Preset):

274

"""Built-in encoding preset."""

275

preset_name: str # EncoderNamedPreset enum

276

configurations: PresetConfigurations

277

278

class StandardEncoderPreset(Preset):

279

"""Custom encoding preset."""

280

codecs: List[Codec]

281

formats: List[Format]

282

filters: Filters

283

284

class AudioAnalyzerPreset(Preset):

285

"""Audio analysis preset."""

286

audio_language: str

287

mode: str # AudioAnalysisMode enum

288

289

class VideoAnalyzerPreset(Preset):

290

"""Video analysis preset."""

291

audio_language: str

292

mode: str # VideoAnalysisMode enum

293

insights_to_extract: str # InsightsType enum

294

295

class FaceDetectorPreset(Preset):

296

"""Face detection preset."""

297

resolution: str # AnalysisResolution enum

298

mode: str # FaceDetectorMode enum

299

blur_type: str # BlurType enum

300

face_redactor_mode: str # FaceRedactorMode enum

301

302

# Codecs

303

class Codec:

304

"""Base class for codecs."""

305

label: str

306

307

class H264Video(Codec):

308

"""H.264 video codec."""

309

scene_change_detection: bool

310

complexity: str # H264Complexity enum

311

layers: List[H264Layer]

312

key_frame_interval: str

313

stretch_mode: str # StretchMode enum

314

sync_mode: str # VideoSyncMode enum

315

316

class H265Video(Codec):

317

"""H.265 video codec."""

318

scene_change_detection: bool

319

complexity: str # H265Complexity enum

320

layers: List[H265Layer]

321

key_frame_interval: str

322

stretch_mode: str # StretchMode enum

323

sync_mode: str # VideoSyncMode enum

324

325

class AacAudio(Codec):

326

"""AAC audio codec."""

327

channels: int

328

sampling_rate: int

329

bitrate: int

330

profile: str # AacAudioProfile enum

331

332

# Formats

333

class Format:

334

"""Base class for output formats."""

335

filename_pattern: str

336

337

class Mp4Format(Format):

338

"""MP4 container format."""

339

output_files: List[OutputFile]

340

341

class TransportStreamFormat(Format):

342

"""MPEG transport stream format."""

343

output_files: List[OutputFile]

344

345

class JpgFormat(Format):

346

"""JPEG image format."""

347

pass

348

349

class PngFormat(Format):

350

"""PNG image format."""

351

pass

352

```

353

354

## Usage Examples

355

356

### Create Transform with Built-in Preset

357

358

```python

359

from azure.mgmt.media import AzureMediaServices

360

from azure.mgmt.media.models import (

361

Transform, TransformOutput, BuiltInStandardEncoderPreset,

362

EncoderNamedPreset, Priority, OnErrorType

363

)

364

from azure.identity import DefaultAzureCredential

365

366

client = AzureMediaServices(

367

credential=DefaultAzureCredential(),

368

subscription_id="your-subscription-id"

369

)

370

371

# Create transform with built-in preset

372

preset = BuiltInStandardEncoderPreset(

373

preset_name=EncoderNamedPreset.ADAPTIVE_STREAMING

374

)

375

376

transform_output = TransformOutput(

377

preset=preset,

378

on_error=OnErrorType.STOP_PROCESSING_JOB,

379

relative_priority=Priority.NORMAL

380

)

381

382

transform = Transform(

383

description="Adaptive streaming transform",

384

outputs=[transform_output]

385

)

386

387

created_transform = client.transforms.create_or_update(

388

resource_group_name="my-resource-group",

389

account_name="my-media-service",

390

transform_name="adaptive-streaming-transform",

391

parameters=transform

392

)

393

394

print(f"Transform created: {created_transform.name}")

395

```

396

397

### Create and Monitor Encoding Job

398

399

```python

400

from azure.mgmt.media.models import (

401

Job, JobInputAsset, JobOutputAsset, Priority

402

)

403

import time

404

405

# Create job from transform

406

job_input = JobInputAsset(asset_name="input-asset")

407

job_output = JobOutputAsset(asset_name="output-asset")

408

409

job = Job(

410

description="Encode video for adaptive streaming",

411

input=job_input,

412

outputs=[job_output],

413

priority=Priority.NORMAL

414

)

415

416

created_job = client.jobs.create(

417

resource_group_name="my-resource-group",

418

account_name="my-media-service",

419

transform_name="adaptive-streaming-transform",

420

job_name="encoding-job-001",

421

parameters=job

422

)

423

424

print(f"Job created: {created_job.name}")

425

print(f"Initial state: {created_job.state}")

426

427

# Monitor job progress

428

while True:

429

job_status = client.jobs.get(

430

resource_group_name="my-resource-group",

431

account_name="my-media-service",

432

transform_name="adaptive-streaming-transform",

433

job_name="encoding-job-001"

434

)

435

436

print(f"Job state: {job_status.state}")

437

438

if job_status.outputs:

439

for output in job_status.outputs:

440

print(f"Output progress: {output.progress}%")

441

if output.error:

442

print(f"Output error: {output.error.message}")

443

444

if job_status.state in ["Finished", "Error", "Canceled"]:

445

break

446

447

time.sleep(10)

448

449

print(f"Job completed with state: {job_status.state}")

450

```

451

452

### Create Custom Encoding Transform

453

454

```python

455

from azure.mgmt.media.models import (

456

StandardEncoderPreset, H264Video, H264Layer, AacAudio,

457

Mp4Format, H264Complexity, AacAudioProfile

458

)

459

460

# Define video codec with multiple layers

461

h264_layers = [

462

H264Layer(

463

bitrate=3400000,

464

width="1920",

465

height="1080",

466

label="HD"

467

),

468

H264Layer(

469

bitrate=2000000,

470

width="1280",

471

height="720",

472

label="SD"

473

),

474

H264Layer(

475

bitrate=1000000,

476

width="640",

477

height="360",

478

label="Mobile"

479

)

480

]

481

482

h264_codec = H264Video(

483

complexity=H264Complexity.BALANCED,

484

layers=h264_layers,

485

key_frame_interval="PT2S",

486

scene_change_detection=True

487

)

488

489

# Define audio codec

490

aac_codec = AacAudio(

491

channels=2,

492

sampling_rate=48000,

493

bitrate=128000,

494

profile=AacAudioProfile.AAC_LC

495

)

496

497

# Define output format

498

mp4_format = Mp4Format(

499

filename_pattern="{Basename}_{Label}_{Bitrate}.mp4"

500

)

501

502

# Create custom preset

503

custom_preset = StandardEncoderPreset(

504

codecs=[h264_codec, aac_codec],

505

formats=[mp4_format]

506

)

507

508

# Create transform with custom preset

509

custom_transform_output = TransformOutput(

510

preset=custom_preset,

511

on_error=OnErrorType.CONTINUE_JOB,

512

relative_priority=Priority.HIGH

513

)

514

515

custom_transform = Transform(

516

description="Custom multi-bitrate encoding",

517

outputs=[custom_transform_output]

518

)

519

520

client.transforms.create_or_update(

521

resource_group_name="my-resource-group",

522

account_name="my-media-service",

523

transform_name="custom-encoding-transform",

524

parameters=custom_transform

525

)

526

527

print("Custom encoding transform created")

528

```