Skip to content

Commit a05fe7e

Browse files
committed
Sync alphalib
1 parent 6d4af31 commit a05fe7e

File tree

10 files changed

+162
-207
lines changed

10 files changed

+162
-207
lines changed

src/alphalib/types/robots/_instructions-primitives.ts

Lines changed: 144 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -313,127 +313,160 @@ Selects the FFmpeg stack version to use for encoding. These versions reflect rea
313313
`),
314314
})
315315

316+
function preprocessPreset(preset: unknown) {
317+
return typeof preset === 'string' ? preset.replaceAll('_', '-') : preset
318+
}
319+
320+
const audioPresets = [
321+
'aac',
322+
'alac',
323+
'audio/aac',
324+
'audio/alac',
325+
'audio/flac',
326+
'audio/mp3',
327+
'audio/ogg',
328+
'dash/32k-audio',
329+
'dash/64k-audio',
330+
'dash/128k-audio',
331+
'dash/256k-audio',
332+
'dash-32k-audio',
333+
'dash-64k-audio',
334+
'dash-128k-audio',
335+
'dash-256k-audio',
336+
'empty',
337+
'flac',
338+
'gif',
339+
'hg-transformers-audio',
340+
'mp3',
341+
'ogg',
342+
'opus',
343+
'speech',
344+
'wav',
345+
] as const
346+
347+
/**
348+
* A robot that uses FFmpeg to **output** audio.
349+
*/
316350
export type FFmpegAudio = z.infer<typeof robotFFmpegAudio>
317351
export const robotFFmpegAudio = robotFFmpeg
318352
.extend({
319-
preset: z
320-
.enum([
321-
'aac',
322-
'alac',
323-
'audio/aac',
324-
'audio/alac',
325-
'audio/flac',
326-
'audio/mp3',
327-
'audio/ogg',
328-
'dash/32k-audio',
329-
'dash/64k-audio',
330-
'dash/128k-audio',
331-
'dash/256k-audio',
332-
'dash-32k-audio',
333-
'dash-64k-audio',
334-
'dash-128k-audio',
335-
'dash-256k-audio',
336-
'empty',
337-
'flac',
338-
'gif',
339-
'hg-transformers-audio',
340-
'mp3',
341-
'ogg',
342-
'opus',
343-
'speech',
344-
'wav',
345-
])
346-
.optional(),
353+
preset: z.preprocess(preprocessPreset, z.enum(audioPresets)).optional().describe(`
354+
Performs conversion using pre-configured settings.
355+
356+
If you specify your own FFmpeg parameters using the <dfn>Robot</dfn>'s \`ffmpeg\` parameter and you have not specified a preset, then the default \`mp3\` preset is not applied. This is to prevent you from having to override each of the MP3 preset's values manually.
357+
358+
For a list of audio presets, see [audio presets](/docs/transcoding/audio-encoding/audio-presets/).
359+
`),
347360
})
348361
.strict()
349362

363+
/**
364+
* A robot that uses FFmpeg to **output** video.
365+
*/
350366
export type FFmpegVideo = z.infer<typeof robotFFmpegVideo>
351367
export const robotFFmpegVideo = robotFFmpeg
352368
.extend({
353-
width: z.number().nullish(),
354-
height: z.number().nullish(),
369+
width: z.number().int().min(1).nullish().describe(`
370+
Width of the new video, in pixels.
371+
372+
If the value is not specified and the \`preset\` parameter is available, the \`preset\`'s [supplied width](/docs/transcoding/video-encoding/video-presets/) will be implemented.
373+
`),
374+
height: z.number().int().min(1).nullish().describe(`
375+
Height of the new video, in pixels.
376+
377+
If the value is not specified and the \`preset\` parameter is available, the \`preset\`'s [supplied height](/docs/transcoding/video-encoding/video-presets/) will be implemented.
378+
`),
355379
preset: z
356-
.enum([
357-
'android-high',
358-
'android-low',
359-
'android',
360-
'dash/270p-video',
361-
'dash/360p-video',
362-
'dash/480p-video',
363-
'dash/540p-video',
364-
'dash/576p-video',
365-
'dash/720p-video',
366-
'dash/1080p-video',
367-
'dash-270p-video',
368-
'dash-360p-video',
369-
'dash-480p-video',
370-
'dash-540p-video',
371-
'dash-576p-video',
372-
'dash-720p-video',
373-
'dash-1080p-video',
374-
'flash',
375-
'hevc',
376-
'hls/270p',
377-
'hls/360p',
378-
'hls/480p',
379-
'hls/540p',
380-
'hls/720p',
381-
'hls/1080p',
382-
'hls/4k',
383-
'hls-1080p',
384-
'hls-360p',
385-
'hls-480p',
386-
'hls-540p',
387-
'hls-576p',
388-
'hls-720p',
389-
'hls-270p',
390-
'ipad-high',
391-
'ipad-low',
392-
'ipad',
393-
'iphone-high',
394-
'iphone-low',
395-
'iphone',
396-
'ogv',
397-
'vp9',
398-
'vp9-270p',
399-
'vp9-360p',
400-
'vp9-480p',
401-
'vp9-540p',
402-
'vp9-576p',
403-
'vp9-720p',
404-
'vp9-1080p',
405-
'web/mp4-x265/240p',
406-
'web/mp4-x265/360p',
407-
'web/mp4-x265/480p',
408-
'web/mp4-x265/720p',
409-
'web/mp4-x265/1080p',
410-
'web/mp4-x265/4k',
411-
'web/mp4-x265/8k',
412-
'web/mp4/240p',
413-
'web/mp4/360p',
414-
'web/mp4/480p',
415-
'web/mp4/540p',
416-
'web/mp4/720p',
417-
'web/mp4/1080p',
418-
'web/mp4/4k',
419-
'web/webm/240p',
420-
'web/webm/360p',
421-
'web/webm/480p',
422-
'web/webm/720p',
423-
'web/webm/1080p',
424-
'web/webm/4k',
425-
'web/webm/8k',
426-
'webm-270p',
427-
'webm-360p',
428-
'webm-480p',
429-
'webm-540p',
430-
'webm-576p',
431-
'webm-720p',
432-
'webm-1080p',
433-
'webm',
434-
'wmv',
435-
])
436-
.optional(),
380+
.preprocess(
381+
preprocessPreset,
382+
z.enum([
383+
'android-high',
384+
'android-low',
385+
'android',
386+
'dash/270p-video',
387+
'dash/360p-video',
388+
'dash/480p-video',
389+
'dash/540p-video',
390+
'dash/576p-video',
391+
'dash/720p-video',
392+
'dash/1080p-video',
393+
'dash-270p-video',
394+
'dash-360p-video',
395+
'dash-480p-video',
396+
'dash-540p-video',
397+
'dash-576p-video',
398+
'dash-720p-video',
399+
'dash-1080p-video',
400+
'empty',
401+
'flash',
402+
'hevc',
403+
'hls/270p',
404+
'hls/360p',
405+
'hls/480p',
406+
'hls/540p',
407+
'hls/720p',
408+
'hls/1080p',
409+
'hls/4k',
410+
'hls-1080p',
411+
'hls-360p',
412+
'hls-480p',
413+
'hls-540p',
414+
'hls-576p',
415+
'hls-720p',
416+
'hls-270p',
417+
'ipad-high',
418+
'ipad-low',
419+
'ipad',
420+
'iphone-high',
421+
'iphone-low',
422+
'iphone',
423+
'ogv',
424+
'vp9',
425+
'vp9-270p',
426+
'vp9-360p',
427+
'vp9-480p',
428+
'vp9-540p',
429+
'vp9-576p',
430+
'vp9-720p',
431+
'vp9-1080p',
432+
'web/mp4-x265/240p',
433+
'web/mp4-x265/360p',
434+
'web/mp4-x265/480p',
435+
'web/mp4-x265/720p',
436+
'web/mp4-x265/1080p',
437+
'web/mp4-x265/4k',
438+
'web/mp4-x265/8k',
439+
'web/mp4/240p',
440+
'web/mp4/360p',
441+
'web/mp4/480p',
442+
'web/mp4/540p',
443+
'web/mp4/720p',
444+
'web/mp4/1080p',
445+
'web/mp4/4k',
446+
'web/webm/240p',
447+
'web/webm/360p',
448+
'web/webm/480p',
449+
'web/webm/720p',
450+
'web/webm/1080p',
451+
'web/webm/4k',
452+
'web/webm/8k',
453+
'webm-270p',
454+
'webm-360p',
455+
'webm-480p',
456+
'webm-540p',
457+
'webm-576p',
458+
'webm-720p',
459+
'webm-1080p',
460+
'webm',
461+
'wmv',
462+
...audioPresets,
463+
]),
464+
)
465+
.optional().describe(`
466+
Converts a video according to [pre-configured settings](/docs/transcoding/video-encoding/video-presets/).
467+
468+
If you specify your own FFmpeg parameters using the <dfn>Robot</dfn>'s and/or do not not want Transloadit to set any encoding setting, starting \`ffmpeg_stack: "{{stacks.ffmpeg.recommended_version}}"\`, you can use the value \`'empty'\` here.
469+
`),
437470
})
438471
.strict()
439472

src/alphalib/types/robots/audio-concat.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ import { z } from 'zod'
22

33
import {
44
bitrateSchema,
5-
robotFFmpeg,
6-
preset,
75
robotBase,
86
robotUse,
97
sampleRateSchema,
8+
robotFFmpegAudio,
109
} from './_instructions-primitives.ts'
1110
import type { RobotMeta } from './_instructions-primitives.ts'
1211

@@ -49,21 +48,14 @@ export const meta: RobotMeta = {
4948

5049
export const robotAudioConcatInstructionsSchema = robotBase
5150
.merge(robotUse)
52-
.merge(robotFFmpeg)
51+
.merge(robotFFmpegAudio)
5352
.extend({
5453
result: z
5554
.boolean()
5655
.optional()
5756
.describe(`Whether the results of this Step should be present in the Assembly Status JSON`),
5857
robot: z.literal('/audio/concat').describe(`
5958
This Robot can concatenate an almost infinite number of audio files.
60-
`),
61-
preset: preset.optional().describe(`
62-
Performs conversion using pre-configured settings.
63-
64-
If you specify your own FFmpeg parameters using the <dfn>Robot</dfn>'s \`ffmpeg\` parameter and you have not specified a preset, then the default \`mp3\` preset is not applied. This is to prevent you from having to override each of the MP3 preset's values manually.
65-
66-
For a list of audio presets, see [audio presets](/docs/transcoding/audio-encoding/audio-presets/).
6759
`),
6860
bitrate: bitrateSchema.optional().describe(`
6961
Bit rate of the resulting audio file, in bits per second. If not specified will default to the bit rate of the input audio file.

src/alphalib/types/robots/audio-encode.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import { z } from 'zod'
22

33
import {
44
bitrateSchema,
5-
robotFFmpeg,
6-
preset,
5+
robotFFmpegAudio,
76
robotBase,
87
robotUse,
98
sampleRateSchema,
@@ -45,20 +44,13 @@ export const meta: RobotMeta = {
4544

4645
export const robotAudioEncodeInstructionsSchema = robotBase
4746
.merge(robotUse)
48-
.merge(robotFFmpeg)
47+
.merge(robotFFmpegAudio)
4948
.extend({
5049
result: z
5150
.boolean()
5251
.optional()
5352
.describe(`Whether the results of this Step should be present in the Assembly Status JSON`),
5453
robot: z.literal('/audio/encode'),
55-
preset: preset.default('mp3').describe(`
56-
Performs conversion using pre-configured settings.
57-
58-
If you specify your own FFmpeg parameters using the <dfn>Robot</dfn>'s \`ffmpeg\` parameter and you have not specified a preset, then the default \`mp3\` preset is not applied. This is to prevent you from having to override each of the \`mp3\` preset's values manually.
59-
60-
For a list of audio presets, see [audio presets](/docs/transcoding/audio-encoding/audio-presets/).
61-
`),
6254
bitrate: bitrateSchema.optional().describe(`
6355
Bit rate of the resulting audio file, in bits per second. If not specified will default to the bit rate of the input audio file.
6456
`),

src/alphalib/types/robots/audio-loop.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import { z } from 'zod'
22

33
import {
44
bitrateSchema,
5-
robotFFmpeg,
6-
preset,
5+
robotFFmpegAudio,
76
robotBase,
87
robotUse,
98
sampleRateSchema,
@@ -45,16 +44,9 @@ export const meta: RobotMeta = {
4544

4645
export const robotAudioLoopInstructionsSchema = robotBase
4746
.merge(robotUse)
48-
.merge(robotFFmpeg)
47+
.merge(robotFFmpegAudio)
4948
.extend({
5049
robot: z.literal('/audio/loop'),
51-
preset: preset.optional().describe(`
52-
Performs conversion using pre-configured settings.
53-
54-
If you specify your own FFmpeg parameters using the <dfn>Robot</dfn>'s \`ffmpeg\` parameter and you have not specified a preset, then the default \`mp3\` preset is not applied. This is to prevent you from having to override each of the \`mp3\` preset's values manually.
55-
56-
For a list of audio presets, see [audio presets](/docs/transcoding/audio-encoding/audio-presets/).
57-
`),
5850
bitrate: bitrateSchema.optional().describe(`
5951
Bit rate of the resulting audio file, in bits per second. If not specified will default to the bit rate of the input audio file.
6052
`),

src/alphalib/types/robots/audio-merge.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import { z } from 'zod'
22

33
import {
44
bitrateSchema,
5-
robotFFmpeg,
6-
preset,
5+
robotFFmpegAudio,
76
robotBase,
87
robotUse,
98
sampleRateSchema,
@@ -50,15 +49,9 @@ export const meta: RobotMeta = {
5049

5150
export const robotAudioMergeInstructionsSchema = robotBase
5251
.merge(robotUse)
53-
.merge(robotFFmpeg)
52+
.merge(robotFFmpegAudio)
5453
.extend({
5554
robot: z.literal('/audio/merge'),
56-
preset: preset.describe(`
57-
Performs conversion using pre-configured settings.
58-
59-
If you specify your own FFmpeg parameters using the <dfn>Robot</dfn>'s \`ffmpeg\` parameter and you have not specified a preset, then the default "mp3" preset is not applied. This is to prevent you from having to override each of the mp3 preset's values manually.
60-
61-
For a list of audio presets, see [audio presets](/docs/transcoding/audio-encoding/audio-presets/).`),
6255
bitrate: bitrateSchema.optional().describe(`
6356
Bit rate of the resulting audio file, in bits per second. If not specified will default to the bit rate of the input audio file.
6457
`),

0 commit comments

Comments
 (0)