Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 57 additions & 30 deletions packages/discord-poster/post.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,68 @@
const DISCORD_MAX_LENGTH = 2000;

const latestRelease = await fetch(
"https://api.github.com/repos/remotion-dev/remotion/releases?per_page=1"
'https://api.github.com/repos/remotion-dev/remotion/releases?per_page=1',
);

const json = await latestRelease.json();

const markdown = [
`${json[0].tag_name} has been released!`,
`<:merge:909914451447259177> ${json[0].html_url}`,
...json[0].body.split("\n").map((s) => {
if (s.startsWith("## ")) {
return s.replace("## ", "**<:love:989990489824559104> ") + "**";
}
return s;
}),
`${json[0].tag_name} has been released!`,
`<:merge:909914451447259177> ${json[0].html_url}`,
...json[0].body.split('\n').map((s: string) => {
if (s.startsWith('## ')) {
return s.replace('## ', '**<:love:989990489824559104> ') + '**';
}
return s;
}),
]
.filter(Boolean)
.join("\n");

const res = await fetch(
`https://discord.com/api/channels/994527481598070815/messages`,
{
method: "post",
body: JSON.stringify({
content: markdown,
allowed_mentions: {},
flags: 1 << 2,
}),
headers: {
"Content-Type": "application/json",
Authorization: `Bot ${process.env.DISCORD_TOKEN}`,
},
}
);
.filter(Boolean)
.join('\n');

const splitIntoChunks = (text: string): string[] => {
const chunks: string[] = [];
let remaining = text;

while (remaining.length > 0) {
if (remaining.length <= DISCORD_MAX_LENGTH) {
chunks.push(remaining);
break;
}

const slice = remaining.slice(0, DISCORD_MAX_LENGTH);
const lastNewline = slice.lastIndexOf('\n');
const splitAt = lastNewline > 0 ? lastNewline : DISCORD_MAX_LENGTH;

chunks.push(remaining.slice(0, splitAt));
remaining = remaining.slice(splitAt).replace(/^\n/, '');
}

return chunks;
};

const chunks = splitIntoChunks(markdown);

for (const chunk of chunks) {
const res = await fetch(
`https://discord.com/api/channels/994527481598070815/messages`,
{
method: 'post',
body: JSON.stringify({
content: chunk,
allowed_mentions: {},
flags: 1 << 2,
}),
headers: {
'Content-Type': 'application/json',
Authorization: `Bot ${process.env.DISCORD_TOKEN}`,
},
},
);

if (res.status !== 200) {
console.log(await res.text());
process.exit(1);
if (res.status !== 200) {
console.log(await res.text());
process.exit(1);
}
}

export {};
4 changes: 3 additions & 1 deletion packages/docs/docs/renderer/TableOfContents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ export const TableOfContents: React.FC = () => {
<div>Create token to later cancel a render</div>
</TOCItem>
<TOCItem link="/docs/renderer/get-video-metadata">
<strong>getVideoMetadata()</strong>
<strong style={{textDecoration: 'line-through'}}>
getVideoMetadata()
</strong>
<div>Get metadata from a video file in Node.js</div>
</TOCItem>
<TOCItem link="/docs/renderer/get-silent-parts">
Expand Down
4 changes: 0 additions & 4 deletions packages/docs/docs/renderer/render-frames.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ If you want to render only a still image, use [renderStill()](/docs/renderer/ren
In Remotion 3.0, we added the [`renderMedia()`](/docs/renderer/render-media) API which combines `renderFrames()` and `stitchFramesToVideo()` into one simplified step and performs the render faster. Prefer `renderMedia()` if you can.
:::

:::info
Configuration in `remotion.config.ts` and CLI flags do not apply to this function. You must pass all options explicitly.
:::

## Arguments

Takes an object with the following keys:
Expand Down
71 changes: 37 additions & 34 deletions packages/docs/docs/renderer/render-media.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ title: renderMedia()
crumb: '@remotion/renderer'
---

_Part of the `@remotion/renderer` package._
# renderMedia()<AvailableFrom v="3.0" />

<AvailableFrom v="3.0" />
_Part of the `@remotion/renderer` package._

Render a video or an audio programmatically.

Expand All @@ -28,7 +28,6 @@ const composition = await selectComposition({
});

// ---cut---

await renderMedia({
composition,
serveUrl,
Expand All @@ -50,31 +49,27 @@ _string_

Either a local path pointing to a Remotion Webpack bundle generated by [`bundle()`](/docs/bundle) or a URL where the bundle is hosted.

### `port?`

Prefer a specific port that will be used to serve the Remotion project. If not specified, a random port will be used.

### `outputLocation?`

_string, since v3.0.26_

Where to save the output artifact to. Either an absolute path or a relative path that will be resolved relative to the current working directory. Must be a file path (not a folder).

If not specified or set to `null`, the file will be returned in-memory as a buffer.

### `composition`

_VideoConfig_

An object describing a composition using `id`, `width`, `height`, `fps` and `durationInFrames`, `defaultProps` and `props`.
An object describing a composition using `id`, `width`, `height`, `fps` and `durationInFrames`, `defaultProps` and `props`.
Call [`selectComposition()`](/docs/renderer/select-composition) or [`getCompositions()`](/docs/renderer/get-compositions) to get an array of possible configs.

### `codec`

_"h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif"_
_string_ <TsType type="Codec" source="@remotion/renderer" href="/docs/renderer/types#codec" />

Choose a suitable codec for your output media. Refer to the [Encoding guide](/docs/encoding) to find the best codec for your use case.

### `outputLocation?`

_string_

Where to save the output artifact to. Either an absolute path or a relative path that will be resolved relative to the current working directory. Must be a file path (not a folder).

If not specified or set to `null`, the file will be returned in-memory as a buffer.

### `inputProps?`

_object_
Expand All @@ -86,14 +81,22 @@ You may transform input props using [`calculateMetadata()`](/docs/calculate-meta

Make sure to also pass the same `inputProps` to [`selectComposition()`](/docs/renderer/select-composition) for this to work correctly.

### `port?`

_number_

Prefer a specific port that will be used to serve the Remotion project. If not specified, a random port will be used.

### `frameRange?`

_number | [number, number] | [number, null]_
_number | [number, number] | [number, null]_ <TsType type="FrameRange" source="@remotion/renderer" href="/docs/renderer/types#framerange" />

Specify a single frame (passing a `number`) or a range of frames (passing a tuple `[number, number]`) to be rendered. By passing `null` (default) all frames of a composition get rendered. Pass `[number, null]` to render from a frame to the end of the composition.<AvailableFrom v="4.0.421" inline />

### `concurrency?`

_number | string | null_ <TsType type="Concurrency" source="@remotion/renderer" href="/docs/renderer/types#concurrency" />

A `number` specifying how many render processes should be started in parallel, a `string` specifying the percentage of the CPU threads to use (e.g. `50%`), or `null` to let Remotion decide based on the CPU of the host machine. Default is half of the CPU threads available.

### `metadata?`<AvailableFrom v="4.0.216" />
Expand All @@ -108,11 +111,13 @@ _object_

### `onArtifact?`<AvailableFrom v="4.0.176" />

_function_ <TsType type="OnArtifact" source="@remotion/renderer" href="/docs/renderer/types#onartifact" />

[Handle an artifact](/docs/artifacts#using-rendermedia-renderstill-or-renderframes) that was emitted by the [`<Artifact>`](/docs/artifact) component.

### `audioCodec?`

_"pcm-16" | "aac" | "mp3" | "opus", available from v3.3.41_
_string_ <TsType type="AudioCodec" source="@remotion/renderer" href="/docs/renderer/types#audiocodec" />

Choose the encoding of your audio.

Expand All @@ -133,7 +138,7 @@ Refer to the [Encoding guide](/docs/encoding/#audio-codec) to see defaults and s

### `crf?`

_number | null_
_number | null_ <TsType type="Crf" source="@remotion/renderer" href="/docs/renderer/types#crf" />

The constant rate factor, controlling the quality. See: [Controlling quality using the CRF setting.](/docs/encoding/#controlling-quality-using-the-crf-setting)

Expand All @@ -151,7 +156,7 @@ If you enable [hardware acceleration](/docs/hardware-acceleration), you cannot s

### `imageFormat?`

_"jpeg" (default) | "png" | "none", since v3.2.27_
_string_ <TsType type="VideoImageFormat" source="@remotion/renderer" href="/docs/renderer/types#videoimageformat" />

In which image format the frames should be rendered.

Expand All @@ -173,7 +178,7 @@ Renders only every nth frame. For example only every second frame, every third f

### `pixelFormat?`

_string_
_string_ <TsType type="PixelFormat" source="@remotion/renderer" href="/docs/renderer/types#pixelformat" />

[A custom pixel format to use.](/docs/transparent-videos/) Usually used for special use cases like transparent videos.

Expand Down Expand Up @@ -231,12 +236,12 @@ If set to false, the output file will not be written if a file already exists.

### `onStart?`

_function_
_function_ <TsType type="OnStartData" source="@remotion/renderer" href="/docs/renderer/types#onstartdata" />

Callback function that gets called once the renderer has prepared to start rendering and has calculated the amount of frames that are going to be rendered:

```tsx twoslash
import {OnStartData} from '@remotion/renderer';
import type {OnStartData} from '@remotion/renderer';

const onStart = ({
frameCount,
Expand All @@ -255,20 +260,20 @@ const onStart = ({

### `onProgress?`

_function_
_function_ <TsType type="RenderMediaOnProgress" source="@remotion/renderer" href="/docs/renderer/types#rendermediaonprogress" />

React to render progress. The following callback function is similar to how Remotion displays render progress on it's CLI:

```tsx twoslash title="Simple example - Log overall progress"
import {RenderMediaOnProgress} from '@remotion/renderer';
import type {RenderMediaOnProgress} from '@remotion/renderer';

const onProgress: RenderMediaOnProgress = ({progress}) => {
console.log(`Rendering is ${progress * 100}% complete`);
};
```

```tsx twoslash title="Advanced example - Fine-grained progress values"
import {RenderMediaOnProgress} from '@remotion/renderer';
import type {RenderMediaOnProgress} from '@remotion/renderer';

const onProgress: RenderMediaOnProgress = ({renderedFrames, encodedFrames, encodedDoneIn, renderedDoneIn, stitchStage}) => {
if (stitchStage === 'encoding') {
Expand Down Expand Up @@ -300,12 +305,12 @@ The `progress` attribute is available from v3.2.17.

### `onDownload?`

_function_
_function_ <TsType type="RenderMediaOnDownload" source="@remotion/renderer" href="/docs/renderer/types#rendermediaondownload" />

If an audio (or a video with sound) is included in your project, Remotion needs to download it in order to use it's audio in the output file. You can use this callback to react to a download happening and progressing.

```tsx twoslash
import {RenderMediaOnDownload} from '@remotion/renderer';
import type {RenderMediaOnDownload} from '@remotion/renderer';

const onDownload: RenderMediaOnDownload = (src) => {
console.log(`Downloading ${src}...`);
Expand All @@ -323,8 +328,6 @@ const onDownload: RenderMediaOnDownload = (src) => {

### `proResProfile?`

_string_

Sets a ProRes profile. Only applies to videos rendered with `prores` codec. See [Encoding guide](/docs/encoding/#controlling-quality-using-prores-profile) for possible options.

### `x264Preset?`
Expand All @@ -335,12 +338,12 @@ _string_

### `onBrowserLog?`

_function_
_function_ <TsType type="BrowserLog" source="@remotion/renderer" href="/docs/renderer/types#browserlog" />

Catch a console message being printed. Example:

```tsx twoslash
import {BrowserLog} from '@remotion/renderer';
import type {BrowserLog} from '@remotion/renderer';

const onBrowserLog = (log: BrowserLog) => {
// `type` is the console.* method: `log`, `warn`, `error`, etc.
Expand Down Expand Up @@ -406,7 +409,7 @@ Lets you set a custom user agent that the headless Chrome browser assumes.

### `ffmpegOverride?`<AvailableFrom v="3.2.22" />

_function_
_function_ <TsType type="FfmpegOverrideFn" source="@remotion/renderer" href="/docs/renderer/types#ffmpegoverridefn" />

Modifies the FFMPEG command that Remotion uses under the hood. It works reducer-style, meaning that you pass a function that takes a command as an argument and returns a new command.

Expand Down
Loading
Loading