# CremyX Drama Render (`andrew_babo/cremyx-drama-render`) Actor

FFmpeg render engine dành riêng cho CremyX Drama v2: ghép beat (video/ảnh + voice + BGM) thành MP4 rồi upload lên signed URL hoặc key-value store.

- **URL**: https://apify.com/andrew\_babo/cremyx-drama-render.md
- **Developed by:** [Andrew Babo](https://apify.com/andrew_babo) (community)
- **Stats:** 3 total users, 3 monthly users, 17.6% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## CremyX Drama Render (Apify actor)

Actor render **dành riêng cho CremyX Drama v2**. Tách khỏi `cremyx-render-engine`
(actor đó do Super Clipping đang dùng và build song song) để hai bên không giẫm
chân nhau khi deploy.

- Actor ID: `andrew_babo~cremyx-drama-render`
- Code render giữ nguyên từ `apify-render-engine/` tại thời điểm tách.
- Gọi qua proxy CremyX (`https://api.cremyx.app/functions/v1/apify-proxy/v2`)
  với pool key `APIFY_CREMYX_KEY`, không gọi thẳng `api.apify.com`.
- Trong app, actor ID đọc từ env `DRAMA_RENDER_ACTOR_ID`
  (mặc định `andrew_babo~cremyx-drama-render`) — xem `src/lib/drama-compose.server.ts`.

### Modes

| mode | dùng khi |
|---|---|
| `concat` | ghép nhiều beat (video + voice) theo thứ tự, có BGM tuỳ chọn |
| `kenburns` | beat chỉ có ảnh tĩnh + voice |
| `editplan` | render theo EditPlan (giữ lại từ bản gốc, Drama chưa dùng) |

### Build / push

```bash
cd apify-drama-render
APIFY_TOKEN=$APIFY_BUILD_TOKEN apify push
```

Sau khi build xong, đặt actor ở chế độ **Public** để các key khác trong pool
gọi được (pool key xoay account, tên trần sẽ trả `Actor was not found`).

### Cấm

- Không sửa/xoá/build actor `cremyx-render-engine`.
- Không dùng `APIFY_BUILD_TOKEN` làm key runtime của app; nó chỉ để push/build.

# Actor input Schema

## `mode` (type: `string`):

concat = stitch scene clips; kenburns = animate still images; editplan = render a Juhe/Velorn EditPlan JSON.

## `edit_plan` (type: `object`):

A schemas.juhe.ai/editplan/1.0 document. Alternatively pass edit\_plan\_url.

## `edit_plan_url` (type: `string`):

HTTP(S) URL of the \*.editplan.json file.

## `source_map` (type: `object`):

Maps each plan source id (or its original uri) to an http(s) URL, e.g. { "src\_main": "https://…/source.mp4" }. Required whenever the plan points at local file:// paths.

## `ignore_capabilities` (type: `boolean`):

Render even when the plan asks for features this actor cannot do yet (they get approximated or dropped).

## `scenes` (type: `array`):

concat/kenburns modes only. Ordered scenes; each needs video\_url (concat) or image\_url (kenburns). voice\_url is optional but drives scene duration when present.

## `video` (type: `object`):

width, height, fps, crf, preset. Omit in editplan mode — the plan's canvas wins. Defaults (code-level): 1920x1080@30, crf 20, preset fast.

## `audio` (type: `object`):

voice\_gain\_db, source\_gain, bgm\_url, bgm\_gain\_db, loudnorm.

## `output` (type: `object`):

signed\_upload\_url (HTTP PUT target) and/or fallback\_kv\_key for the key-value store.

## `callback` (type: `object`):

Optional webhook: { url, secret\_header: { name, value } }.

## `options` (type: `object`):

Encoder and scheduling knobs. profile: quality|balanced|fast|draft (balanced is the editplan default). preset/crf override the profile. workers/threads override the vCPU-derived pool. shard\_sec forces the straggler-splitting length (0 disables sharding).

## Actor input object example

```json
{
  "mode": "concat",
  "ignore_capabilities": false,
  "audio": {
    "voice_gain_db": 4,
    "source_gain": 0.1,
    "bgm_url": null,
    "bgm_gain_db": -22,
    "loudnorm": true
  },
  "output": {
    "signed_upload_url": null,
    "fallback_kv_key": "output.mp4"
  },
  "callback": {
    "url": null,
    "secret_header": null
  },
  "options": {
    "profile": "balanced"
  }
}
```

# Actor output Schema

## `results` (type: `string`):

Full run result JSON: status, mode/op, artifacts \[{name, kv\_key, url, bytes}], meta, timings, errors.

## `resultRecord` (type: `string`):

The same result JSON stored as the RESULT record of the default key-value store.

## `renderedVideo` (type: `string`):

The rendered MP4 record in the default key-value store (when the run keeps artifacts in-store).

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "options": {
        "profile": "balanced"
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("andrew_babo/cremyx-drama-render").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "options": { "profile": "balanced" } }

# Run the Actor and wait for it to finish
run = client.actor("andrew_babo/cremyx-drama-render").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "options": {
    "profile": "balanced"
  }
}' |
apify call andrew_babo/cremyx-drama-render --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,andrew_babo/cremyx-drama-render"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/cEHhmgmqzjKrPLhLW/builds/XpnbORGYo0LnG5TrT/openapi.json
