Skip to content

Commit da7be78

Browse files
committed
Sync alphalib
1 parent 8e1ff50 commit da7be78

File tree

11 files changed

+100
-18
lines changed

11 files changed

+100
-18
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,8 @@ export const bitrateSchema = z.number().int().min(1)
387387
export const sampleRateSchema = z.number().int().min(1)
388388

389389
export const optimize_priority = z
390-
.enum(['compression-ratio', 'conversation-speed'])
391-
.default('compression-ratio')
390+
.enum(['compression-ratio', 'conversion-speed'])
391+
.default('conversion-speed')
392392

393393
export const imagemagickStackVersionSchema = z.enum(['v2.0.10', 'v3.0.1']).default('v2.0.10')
394394
export type ImagemagickStackVersion = z.infer<typeof imagemagickStackVersionSchema>

src/alphalib/types/robots/file-hash.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ export const meta: RobotMeta = {
3434

3535
export const robotFileHashInstructionsSchema = z
3636
.object({
37+
robot: z.literal('/file/hash').describe(`
38+
This <dfn>Robot</dfn> allows you to hash any file as part of the <dfn>Assembly</dfn> execution process. This can be useful for verifying the integrity of a file for example.
39+
`),
3740
result: z
3841
.boolean()
3942
.optional()
4043
.describe(`Whether the results of this Step should be present in the Assembly Status JSON`),
41-
robot: z.literal('/file/hash'),
4244
use: useParamSchema,
4345
algorithm: z
4446
.enum(['b2', 'md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512'])

src/alphalib/types/robots/file-preview.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,17 @@ export const meta: RobotMeta = {
4646

4747
export const robotFilePreviewInstructionsInterpolatedSchema = z
4848
.object({
49+
robot: z.literal('/file/preview').describe(`
50+
This <dfn>Robot</dfn>'s purpose is to generate a meaningful preview image for any file, in such a way that the resulting thumbnail highlights the file's content. The goal is not to losslessly present the original media in a smaller way. Instead, it is to maximize the chance of a person recognizing the media at a glance, while being visually pleasing and consistent with other previews. The generation process depends on the file type. For example, the <dfn>Robot</dfn> can extract artwork from media files, frames from videos, generate a waveform for audio files, and preview the content of documents and images. The details of all available strategies are provided in the next section.
51+
52+
If no file-specific thumbnail can be generated because the file type is not supported, a generic icon containing the file extension will be generated.
53+
54+
The default parameters ensure that the <dfn>Robot</dfn> always generates a preview image with the predefined dimensions and formats, to allow an easy integration into your application's UI. In addition, the generated preview images are optimized by default to reduce their file size while keeping their quality.
55+
`),
4956
result: z
5057
.boolean()
5158
.optional()
5259
.describe(`Whether the results of this Step should be present in the Assembly Status JSON`),
53-
robot: z.literal('/file/preview'),
5460
use: useParamSchema,
5561
format: z.enum(['gif', 'jpg', 'png']).default('png').describe(`
5662
The output format for the generated thumbnail image. If a short video clip is generated using the \`clip\` strategy, its format is defined by \`clip_format\`.
@@ -65,6 +71,9 @@ Height of the thumbnail, in pixels.
6571
To achieve the desired dimensions of the preview thumbnail, the <dfn>Robot</dfn> might have to resize the generated image. This happens, for example, when the dimensions of a frame extracted from a video do not match the chosen \`width\` and \`height\` parameters.
6672
6773
See the list of available [resize strategies](/docs/transcoding/image-manipulation/image-resize/#resize-strategies) for more details.
74+
`),
75+
background: color_with_optional_alpha.default('#ffffffff').describe(`
76+
The hexadecimal code of the color used to fill the background (only used for the pad resize strategy). The format is \`#rrggbb[aa]\` (red, green, blue, alpha). Use \`#00000000\` for a transparent padding.
6877
`),
6978
strategy: z
7079
.object({

src/alphalib/types/robots/image-generate.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,28 @@ export const robotImageGenerateInstructionsSchema = z
99
.optional()
1010
.describe(`Whether the results of this Step should be present in the Assembly Status JSON`),
1111
robot: z.literal('/image/generate'),
12+
model: z.string(),
1213
prompt: z.string().describe('The prompt describing the desired image content.'),
1314
format: z
1415
.enum(['jpeg', 'png', 'gif', 'webp'])
1516
.optional()
1617
.describe('Format of the generated image.'),
18+
seed: z.number().optional().describe('Seed for the random number generator.'),
19+
aspectRatio: z.string().optional().describe('Aspect ratio of the generated image.'),
20+
height: z.number().optional().describe('Height of the generated image.'),
21+
width: z.number().optional().describe('Width of the generated image.'),
22+
style: z.string().optional().describe('Style of the generated image.'),
1723
output_meta: outputMetaParamSchema.optional(),
1824
use: useParamSchema,
1925
})
2026
.strict()
2127

28+
export const robotImageGenerateInstructionsWithHiddenFields =
29+
robotImageGenerateInstructionsSchema.extend({
30+
provider: z.string().optional().describe('Provider for generating the image.'),
31+
})
32+
2233
export type RobotImageGenerateInstructions = z.infer<typeof robotImageGenerateInstructionsSchema>
34+
export type RobotImageGenerateInstructionsWithHiddenFields = z.infer<
35+
typeof robotImageGenerateInstructionsWithHiddenFields
36+
>

src/alphalib/types/robots/media-playlist.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useParamSchema } from './_instructions-primitives.ts'
55

66
export const meta: RobotMeta = {
77
allowed_for_url_transform: true,
8-
bytescount: 20,
8+
bytescount: 10,
99
discount_factor: 0.1,
1010
discount_pct: 90,
1111
minimum_charge: 0,
@@ -29,7 +29,7 @@ export const robotMediaPlaylistInstructionsSchema = z
2929
.optional()
3030
.describe(`Whether the results of this Step should be present in the Assembly Status JSON`),
3131
robot: z.literal('/media/playlist').describe(`
32-
🤖/media/playlist is deprecated and will be removed! Please use [🤖/video/adaptive](/docs/transcoding/video-encoding/video-adaptive/) for all your HLS and MPEG-Dash needs instead.
32+
**Warning:** 🤖/media/playlist is deprecated and will be removed! Please use [🤖/video/adaptive](/docs/transcoding/video-encoding/video-adaptive/) for all your HLS and MPEG-Dash needs instead.
3333
`),
3434
use: useParamSchema,
3535
name: z.string().default('playlist.m3u8').describe(`
@@ -41,10 +41,10 @@ URL prefixes to use in the playlist file. Example: \`"/234p/"\`
4141
resolution: z.string().optional().describe(`
4242
The resolution reported in the playlist file. Example: \`"416×234"\`. [More info](https://developer.apple.com/library/ios/technotes/tn2224/_index.html#//apple_ref/doc/uid/DTS40009745-CH1-DECIDEONYOURVARIANTS-DEVICE_CAPABILITIES).
4343
`),
44-
codes: z.string().optional().describe(`
44+
codecs: z.string().optional().describe(`
4545
The codecs reported in the playlist file. Example: \`"avc1.42001e,mp4a.40.34"\`. [More info](https://developer.apple.com/library/ios/technotes/tn2224/_index.html#//apple_ref/doc/uid/DTS40009745-CH1-DECIDEONYOURVARIANTS-DEVICE_CAPABILITIES).
4646
`),
47-
bandwidth: z.union([z.literal('auto'), z.number()]).default('auto').describe(`
47+
bandwidth: z.union([z.literal('auto'), z.number().int()]).default('auto').describe(`
4848
The bandwidth reported in the playlist file. Example: \`2560000\`. [More info](https://developer.apple.com/library/ios/technotes/tn2224/_index.html#//apple_ref/doc/uid/DTS40009745-CH1-DECIDEONYOURVARIANTS-DEVICE_CAPABILITIES). This value is expressed in bits per second.
4949
`),
5050
closed_captions: z.boolean().default(true).describe(`

src/alphalib/types/robots/meta-write.ts

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

3-
import { ffmpegStackVersionSchema, useParamSchema } from './_instructions-primitives.ts'
3+
import {
4+
ffmpegAudioInstructions,
5+
ffmpegStackVersionSchema,
6+
useParamSchema,
7+
} from './_instructions-primitives.ts'
48
import type { RobotMeta } from './_instructions-primitives.ts'
59

610
export const meta: RobotMeta = {
@@ -42,13 +46,16 @@ export const robotMetaWriteInstructionsSchema = z
4246
.boolean()
4347
.optional()
4448
.describe(`Whether the results of this Step should be present in the Assembly Status JSON`),
45-
robot: z.literal('/meta/write'),
49+
robot: z.literal('/meta/write').describe(`
50+
**Note:** This <dfn>Robot</dfn> currently accepts images, videos and audio files.
51+
`),
4652
use: useParamSchema,
4753
data_to_write: z.object({}).passthrough().default({}).describe(`
4854
A key/value map defining the metadata to write into the file.
4955
5056
Valid metadata keys can be found [here](https://exiftool.org/TagNames/EXIF.html). For example: \`ProcessingSoftware\`.
5157
`),
58+
ffmpeg: ffmpegAudioInstructions.optional(),
5259
ffmpeg_stack: ffmpegStackVersionSchema.optional(),
5360
})
5461
.strict()

src/alphalib/types/robots/video-adaptive.ts

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { RobotMeta } from './_instructions-primitives.ts'
66
export const meta: RobotMeta = {
77
allowed_for_free_plans: true,
88
allowed_for_url_transform: false,
9-
bytescount: 0,
9+
bytescount: Infinity,
1010
discount_factor: 1,
1111
discount_pct: 0,
1212
example_code: {
@@ -66,11 +66,51 @@ export const meta: RobotMeta = {
6666

6767
export const robotVideoAdaptiveInstructionsSchema = z
6868
.object({
69+
robot: z.literal('/video/adaptive').describe(`
70+
This <dfn>Robot</dfn> accepts all types of video files and audio files. Do not forget to use <dfn>Step</dfn> bundling in your \`use\` parameter to make the <dfn>Robot</dfn> work on several input files at once.
71+
72+
This <dfn>Robot</dfn> is normally used in combination with [🤖/video/encode](/docs/transcoding/video-encoding/video-encode/). We have implemented video and audio encoding presets specifically for MPEG-Dash and HTTP Live Streaming support. These presets are prefixed with \`"dash/"\` and \`"hls/"\`. [View a HTTP Live Streaming demo here](/demos/video-encoding/implement-http-live-streaming/).
73+
74+
### Required CORS settings for MPEG-Dash and HTTP Live Streaming
75+
76+
Playing back MPEG-Dash Manifest or HLS playlist files requires a proper CORS setup on the server-side. The file-serving server should be configured to add the following header fields to responses:
77+
78+
\`\`\`
79+
Access-Control-Allow-Origin: *
80+
Access-Control-Allow-Methods: GET
81+
Access-Control-Allow-Headers: *
82+
\`\`\`
83+
84+
If the files are stored in an Amazon S3 Bucket, you can use the following [CORS definition](https://docs.aws.amazon.com/AmazonS3/latest/userguide/ManageCorsUsing.html) to ensure the CORS header fields are set correctly:
85+
86+
\`\`\`json
87+
[
88+
{
89+
"AllowedHeaders": ["*"],
90+
"AllowedMethods": ["GET"],
91+
"AllowedOrigins": ["*"],
92+
"ExposeHeaders": []
93+
}
94+
]
95+
\`\`\`
96+
97+
To set up CORS for your S3 bucket:
98+
99+
1. Visit <https://s3.console.aws.amazon.com/s3/buckets/>
100+
1. Click on your bucket
101+
1. Click "Permissions"
102+
1. Edit "Cross-origin resource sharing (CORS)"
103+
104+
### Storing Segments and Playlist files
105+
106+
The <dfn>Robot</dfn> gives its result files (segments, initialization segments, MPD manifest files and M3U8 playlist files) the right metadata property \`relative_path\`, so that you can store them easily using one of our storage <dfn>Robots</dfn>.
107+
108+
In the \`path\` parameter of the storage <dfn>Robot</dfn> of your choice, use the <dfn>Assembly Variable</dfn> \`\${file.meta.relative_path}\` to store files in the proper paths to make the playlist files work.
109+
`),
69110
result: z
70111
.boolean()
71112
.optional()
72113
.describe(`Whether the results of this Step should be present in the Assembly Status JSON`),
73-
robot: z.literal('/video/adaptive'),
74114
use: useParamSchema,
75115
technique: z.enum(['dash', 'hls']).default('dash').describe(`
76116
Determines which streaming technique should be used. Currently supports \`"dash"\` for MPEG-Dash and \`"hls"\` for HTTP Live Streaming.

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,18 @@ export const meta: RobotMeta = {
4646

4747
export const robotVideoConcatInstructionsSchema = z
4848
.object({
49+
robot: z.literal('/video/concat').describe(`
50+
**Warning:** All videos you concatenate must have the same dimensions (width and height) and the same streams (audio and video streams), otherwise you will run into errors. If your videos donʼt have the desired dimensions when passing them to [🤖/video/concat](/docs/transcoding/video-encoding/video-concat/), encode them first with [🤖/video/encode](/docs/transcoding/video-encoding/video-encode/). [{.alert .alert-warning}]
51+
52+
Itʼs possible to concatenate a virtually infinite number of video files using [🤖/video/concat](/docs/transcoding/video-encoding/video-concat/).
53+
`),
4954
result: z
5055
.boolean()
5156
.optional()
5257
.describe(`Whether the results of this Step should be present in the Assembly Status JSON`),
53-
robot: z.literal('/video/concat'),
5458
use: useParamSchema,
5559
output_meta: outputMetaParamSchema,
56-
preset: preset.optional().describe(`
60+
preset: preset.default('flash').optional().describe(`
5761
Performs conversion using pre-configured settings.
5862
5963
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 \`"flash"\` preset is not applied. This is to prevent you from having to override each of the flash preset's values manually.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type { RobotMeta } from './_instructions-primitives.ts'
1313

1414
export const meta: RobotMeta = {
1515
allowed_for_url_transform: false,
16-
bytescount: 0,
16+
bytescount: 1,
1717
discount_factor: 1,
1818
discount_pct: 0,
1919
minimum_charge: 0,

src/alphalib/types/robots/video-subtitle.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,13 @@ export const meta: RobotMeta = {
5252

5353
export const robotVideoSubtitleInstructionsSchema = z
5454
.object({
55+
robot: z.literal('/video/subtitle').describe(`
56+
This <dfn>Robot</dfn> supports both SRT and VTT subtitle files.
57+
`),
5558
result: z
5659
.boolean()
5760
.optional()
5861
.describe(`Whether the results of this Step should be present in the Assembly Status JSON`),
59-
robot: z.literal('/video/subtitle'),
6062
use: useParamSchema,
6163
output_meta: outputMetaParamSchema,
6264
preset: preset.default('empty').describe(`

0 commit comments

Comments
 (0)