deploySite()
Cloud Run 处于 Alpha 状态,且尚未积极开发。
获取一个 Remotion 项目,将其打包并上传到云存储桶。一旦上传,Cloud Run 服务可以通过指定 URL 来渲染 Remotion 项目中的任何组合。
🌐 Takes a Remotion project, bundles it and uploads it to an Cloud Storage bucket. Once uploaded, a Cloud Run service can render any composition in the Remotion project by specifying the URL.
- 如果你在本地进行更改,需要重新部署网站。你可以使用
siteName来覆盖之前的网站。 - 请注意,Remotion 项目将部署到子目录,而不是域的根目录。因此,你必须确保如果在 Remotion 项目中指定了路径,它们能够处理这种情况。
- 在调用此函数之前,你应该创建一个存储桶,参见
getOrCreateBucket()。
示例
🌐 Example
import {deploySite } from '@remotion/cloudrun';
import path from 'path';
const {serveUrl } = await deploySite ({
entryPoint : path .resolve (process .cwd (), 'src/index.ts'),
bucketName : 'remotioncloudrun-c7fsl3d',
options : {
onBundleProgress : (progress ) => {
// Progress is between 0 and 100
console .log (`Bundle progress: ${progress }%`);
},
onUploadProgress : ({totalFiles , filesUploaded , totalSize , sizeUploaded }) => {
console .log (`Upload progress: Total files ${totalFiles }, Files uploaded ${filesUploaded }, Total size ${totalSize }, Size uploaded ${sizeUploaded }`);
},
},
});
console .log (serveUrl );参数
🌐 Arguments
一个具有以下属性的对象:
🌐 An object with the following properties:
entryPoint
指向你的 Remotion 项目入口点的绝对路径。通常你的 Remotion 项目的入口点存储在 src/entry.tsx。
🌐 An absolute path pointing to the entry point of your Remotion project. Usually the entry point in your Remotion project is stored at src/entry.tsx.
bucketName
网站将被部署到的桶。该桶必须由 Remotion Cloud Run 创建。
🌐 The bucket to where the website will be deployed. The bucket must have been created by Remotion Cloud Run.
siteName?
指定你希望网站部署到的云存储桶中的子文件夹。如果省略此属性,将创建一个带有随机名称的新子文件夹。如果已存在具有你提供名称的网站,该网站将被覆盖。只能包含以下字符:0-9、a-z、A-Z、-、!、_、.、*、'、(、)
🌐 Specify the subfolder in your Cloud Storage bucket that you want the site to deploy to. If you omit this property, a new subfolder with a random name will be created. If a site already exists with the name you passed, it will be overwritten. Can only contain the following characters: 0-9, a-z, A-Z, -, !, _, ., *, ', (, )
logLevel?v4.0.140
One of trace, verbose, info, warn, error.Determines how much info is being logged to the console.
Default
info.
options?
一个具有以下属性的对象:
🌐 An object with the following properties:
onBundleProgress?
当打包进度有更新时,Webpack 的回调函数会被触发。回调函数会接收一个介于 0 到 100 之间的数字,具体示例见页面顶部。
🌐 Callback from Webpack when the bundling has progressed. Passes a number between 0 and 100 to the callback, see example at the top of the page.
onUploadProgress?
当资源上传进度更新时调用的回调函数。将包含以下属性的对象传递给回调函数:
🌐 Callback function that gets called when uploading of the assets has progressed. Passes an object with the following properties to the callback:
totalFiles(数字):包中的文件总数。filesUploaded(数字):到目前为止已完全上传的文件数量。totalSize(数字): 打包包中所有文件的总大小(字节)。sizeUploaded(number):到目前为止上传的字节数。
webpackOverride?
允许传递自定义的 webpack 覆盖。更多信息请参见 bundle() -> webpackOverride。
🌐 Allows to pass a custom webpack override. See bundle() -> webpackOverride for more information.
enableCaching?
Enable or disable Webpack caching. This flag is enabled by default, use --bundle-cache=false to disable caching.
publicDir?
Define the location of the public/ directory. If not defined, Remotion will assume the location is the `public` folder in your Remotion root.
rootDir?
Remotion 项目所在的根目录。此目录应设置为包含安装 Remotion 的 package.json 的目录。默认情况下,它是当前工作目录。
🌐 The directory in which the Remotion project is rooted in. This should be set to the directory that contains the package.json which installs Remotion. By default, it is the current working directory.
当前工作目录是程序执行时所在的目录。它与调用 bundle() 的文件所在的目录不同。
ignoreRegisterRootWarning?
如果传入的入口文件不包含 registerRoot,则忽略抛出的错误。
🌐 Ignore an error that gets thrown if you pass an entry point file which does not contain registerRoot.
keyboardShortcutsEnabled?v4.0.407
Enable or disable keyboard shortcuts in the Remotion Studio.
askAIEnabled?v4.0.407
If the Cmd + I shortcut of the Ask AI modal conflicts with your Studio, you can disable it using this.
experimentalClientSideRenderingEnabled?v4.0.407
Enable WIP client-side rendering in the Remotion Studio. See https://www.remotion.dev/docs/client-side-rendering/ for notes.
rspack?v4.0.426
Uses Rspack instead of Webpack as the bundler for the Studio or bundle.
返回值
🌐 Return value
一个具有以下值的对象:
🌐 An object with the following values:
serveUrl
string
一个像 https://storage.googleapis.com/remotioncloudrun-123asd321/sites/abcdefgh/index.html 这样的网址。
🌐 An URL such as https://storage.googleapis.com/remotioncloudrun-123asd321/sites/abcdefgh/index.html.
你可以使用这个 “Serve URL” 在 Remotion Cloud Run 上渲染视频,使用方式如下:
🌐 You can use this "Serve URL" to render a video on Remotion Cloud Run using:
[npx remotion cloudrun render](/docs/cloudrun/cli/render)命令[renderMediaOnCloudrun()](/docs/cloudrun/rendermediaoncloudrun)和[renderStillOnCloudrun()](/docs/cloudrun/renderstilloncloudrun)函数。- 本地使用
renderMedia()和renderStill()函数。 - 本地使用
npx remotion render和npx remotion still命令
如果你在 Cloud Run 上进行渲染,你也可以将站点名称(在此情况下为 abcdefgh)作为缩写传递。
🌐 If you are rendering on Cloud Run, you can also pass the site name (in this case abcdefgh) as an abbreviation.
siteName
string
给定的网站标识符。要么是你传入此函数的网站名称,要么是在未传入网站名称时生成的随机字符串。
🌐 The identifier of the site that was given. Is either the site name that you have passed into this function, or a random string that was generated if you didn't pass a site name.
stats
一个包含 3 个条目的对象:
🌐 An object with 3 entries:
uploadedFilesdeletedFilesuntouchedFiles
每一个都是一个 number。
🌐 Each one is a number.
另请参阅
🌐 See also