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
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,11 @@ re-encoding. Choose MP4 or MKV, keep the originals, follow progress, or cancel.
Open its **Operations** tab, or select two completed single-file downloads.
Configure FFmpeg in **Settings → Integration → Media Tools** first.

It is **not bundled with Motrix**. The first release requires a host containing
the manual merge interface, currently planned for `2.0.0-beta.47` or later.
It is **not bundled with Motrix** and has not been released. It requires
`>=2.0.0-beta.48 <3.0.0` with declarative plugin operations; beta.48 is the
planned first supporting host release. Raise this minimum before signing if
the host feature ships later. The published SDK 2.2.0 supplies the build-time
API and manifest schema; installing it does not add support to an older host.
Read the [plugin guide](plugins/motrix.media-merge/README.md) for compatibility,
Server file selection, logs, and release prerequisites.

Expand Down
2 changes: 1 addition & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@

按需安装的官方插件,将视频和音频合成为一个文件,无需重新编码。可以选择 MP4 或 MKV,保留源文件、查看进度或取消操作。从插件的 **操作** 页进入,也可以选中两个已完成的单文件下载。使用前先在 **设置 → 集成 → 媒体工具** 中配置 FFmpeg。

此插件 **默认不随 Motrix 安装**。首版需要包含手动合并界面的宿主,当前计划最低版本为 `2.0.0-beta.47`。版本要求、Server 文件选择、日志和发布前提见[插件指南](plugins/motrix.media-merge/README.zh-CN.md)。
此插件 **默认不随 Motrix 安装**,目前尚未发布。它要求宿主版本为 `>=2.0.0-beta.48 <3.0.0`,并包含声明式插件操作机制;beta.48 是计划中的首个支持版本。如果宿主功能延期,签名前必须提高最低版本。已发布的 SDK 2.2.0 提供构建所需的 API 和清单 schema,安装 SDK 不会让旧宿主获得新机制。版本要求、Server 文件选择、日志和发布前提见[插件指南](plugins/motrix.media-merge/README.zh-CN.md)。

## 在 Motrix 中使用

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
},
"devDependencies": {
"@biomejs/biome": "^2.5.4",
"@motrix/plugin-api": "^2.0.0",
"@motrix/plugin-manifest-schema": "^2.1.0",
"@motrix/plugin-api": "^2.2.0",
"@motrix/plugin-manifest-schema": "^2.2.0",
"esbuild": "^0.24.2",
"vitest": "^3",
"yauzl": "^3",
Expand Down
39 changes: 24 additions & 15 deletions plugins/motrix.media-merge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,24 @@ inputs. Unambiguously reversed inputs are detected and swapped automatically.

## Requirements

- Motrix `>=2.0.0-beta.47 <3.0.0` with the **manual media merge interface**. The host change is [Motrix PR #2308](https://github.com/agalwood/Motrix/pull/2308); confirm the minimum release contains it before publishing the plugin. The `.moext` alone does not add the interface to an older build.
- **Motrix 2.0.0-beta.48 or later, below 3.0.0**, with plugin operations v1, composable UI, selected-file grants and the scoped media capability. Beta.48 is the planned first supporting release; this mechanism and plugin remain unpublished. If the host feature ships later, raise the package and registry minimum together before signing. Beta.47 is rejected, including development builds still reporting that version.
- FFmpeg configured in **Settings → Integration → Media Tools**. Re-enable the
plugin after changing FFmpeg configuration.

## Use

After the signed release is published, install it from the [plugin directory](https://motrix.app/plugins/motrix.media-merge/) and enable it. For local builds, select `dist/artifacts/motrix.media-merge-0.1.0.moext` on the Plugins page.
After the signed release is published, install it from the [plugin directory](https://motrix.app/plugins/motrix.media-merge/) and enable it. Local archives using the `motrix.*` namespace also require a valid official signature before installation.
Then either select two completed single-file downloads and choose **Merge audio
and video**, or open this plugin's **Operations** tab to select local files.
The tab embeds the same form as the task-menu dialog and retains selections
when switching tabs. Select a new `.mp4` or `.mkv` output filename and click **Merge**.

**Merge another file** clears both inputs, the output location and the previous result,
while retaining the selected MP4/MKV format. Choose the new files explicitly; the
previous task selection is not filled in again.

The host owns progress, cancellation, temporary files and non-overwriting output
publication. Original files remain untouched. The destination filesystem must
support hard links. The Web UI reuses the server file browser to select inputs and a new output
publication. Original files remain untouched. The host snapshots selected inputs and publishes the output atomically without replacement. The destination filesystem must support private directories and native no-replace publication; unsupported filesystems are rejected. The Web UI reuses the server file browser to select inputs and a new output
filename, within its download directory policy. Files on the browser’s computer
are not uploaded.

Expand All @@ -48,14 +51,20 @@ pnpm lint
node scripts/pack.mjs motrix.media-merge
```

The only requested permission is `ffmpeg`. The plugin has no network permission
and registers no task lifecycle hooks. It exposes the existing public-command
contract `motrix.media-merge.mergeStreams` with `{ videoInput, audioInput,
output }` and returns `{ outputPath }` after the operation succeeds. Both the
launch call and its `result` are awaited for compatibility with the asynchronous
QuickJS handle transport.

This command is reserved for the host's manual merge interface. Its public
declaration enables provider discovery, not cross-plugin execution. The host
rejects generic and cross-plugin calls before the handler runs; do not invoke
it with `commands.execute` or bypass the host's selected-file context.
The plugin declares `contributes.operations` with a private command registered using
`commands.registerOperation`. It requests `ffmpeg`, `files.selected.read` and
`files.selected.write`. These declarations do not grant arbitrary file access:
the host binds opaque selected-file references to one authorized operation.
There is no network permission or download lifecycle hook.

The handler receives `{ videoInput, audioInput, format, output }`, probes the selected
inputs with `context.media.probe`, swaps clearly reversed tracks, and awaits
`context.media.mergeStreams`. It returns the granted output reference; the host
validates and publishes the file. Generic and cross-plugin command calls cannot
invoke this operation. The manifest owns the form, localized labels, entry
points and error messages; no media-specific renderer is required.

Inputs are limited to 8 GiB each and 16 GiB per operation. Snapshot and output
staging require free disk space. Cancelling stops host-owned work before temporary
resources are removed; closing the form keeps the job running. Host restarts
interrupt jobs and never replay a merge automatically.
28 changes: 17 additions & 11 deletions plugins/motrix.media-merge/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@

## 使用要求

- Motrix `>=2.0.0-beta.47 <3.0.0`,且包含 **手动媒体合并界面**。当前宿主功能见 [Motrix PR #2308](https://github.com/agalwood/Motrix/pull/2308);正式发布插件前必须确认最低版本已包含该功能。单独安装 `.moext` 不会为旧版本补上界面。
- **Motrix 2.0.0-beta.48 及以上、低于 3.0.0**,并具备插件操作 v1、可组合 UI、所选文件授权和操作上下文媒体能力。beta.48 是计划中的首个支持版本,机制和插件仍未发布;若宿主功能延期,签名前必须同步提高包与注册表的最低版本。beta.47 会被拒绝,包括版本号仍为 beta.47 的开发构建。
- 在 **设置 → 集成 → 媒体工具** 中配置 FFmpeg。修改 FFmpeg 配置后请重新启用插件。

## 使用方法

正式签名包发布后,可从 [插件目录](https://motrix.app/zh/plugins/motrix.media-merge/) 安装并启用。也可以在插件页面选择本仓库构建的 `dist/artifacts/motrix.media-merge-0.1.0.moext`。随后可以选中两个
正式签名包发布后,可从 [插件目录](https://motrix.app/zh/plugins/motrix.media-merge/) 安装并启用。使用 `motrix.*` 命名空间的本地包同样需要有效官方签名才能安装。随后可以选中两个
已完成的单文件下载任务,选择 **合并音频和视频**;也可以进入本插件详情的 **操作**
页,直接选择本地文件。操作页和任务菜单弹窗共用表单,切换 Tab 会保留选择。填写新的 `.mp4` 或 `.mkv` 输出文件名后点击 **合并**。

进度、取消、临时文件和不覆盖的输出保存由宿主管理。源文件保持不变,目标文件系统需
支持硬链接。Web UI 复用服务器文件浏览器选择输入和新的输出文件名,并受服务器下载目录策略约束;
点击 **再次合并** 会清空视频、音频、输出位置和上次结果,保留所选 MP4/MKV 格式。新一轮需要重新选择文件,不会再次填入上次选中的下载任务。

进度、取消、临时文件和不覆盖的输出保存由宿主管理。源文件保持不变,宿主先为所选输入建立快照,再以原子方式保存结果且不覆盖已有文件。目标文件系统必须支持私有目录和原生无覆盖发布;不满足保证时会拒绝执行。Web UI 复用服务器文件浏览器选择输入和新的输出文件名,并受服务器下载目录策略约束;
不会上传浏览器所在电脑的文件。

本插件不做片段首尾拼接、音画偏移调整或不兼容编码的转码,也不在下载后自动执行。
Expand All @@ -41,11 +42,16 @@ pnpm lint
node scripts/pack.mjs motrix.media-merge
```

仅申请 `ffmpeg` 权限,不申请网络权限,也不注册下载任务生命周期 Hook。插件通过既有
公开命令机制暴露 `motrix.media-merge.mergeStreams`,接收 `{ videoInput,
audioInput, output }`,操作成功后返回 `{ outputPath }`。启动调用和操作句柄的
`result` 都会被等待,以兼容 QuickJS 异步句柄传输。
插件通过 `contributes.operations` 声明界面,通过 `commands.registerOperation`
注册私有处理命令,申请 `ffmpeg`、`files.selected.read` 和 `files.selected.write`。
声明权限不等于获得任意文件访问能力:宿主将用户选择得到的不透明文件引用绑定到单次操作。
插件不申请网络权限,也不注册下载任务生命周期 Hook。

处理函数接收 `{ videoInput, audioInput, format, output }`,通过 `context.media.probe`
探测输入,自动交换明确选反的轨道,等待 `context.media.mergeStreams` 完成,
再返回已授权的输出引用。宿主校验结果并保存文件。普通命令及跨插件调用均不能调用此操作。
表单、多语言文案、入口和业务错误由插件清单定义,无需宿主提供媒体专用界面。

该命令保留给宿主的手动合并界面。公开声明用于发现提供此功能的插件,不允许跨插件执行。
宿主会在处理函数运行前拒绝通用调用和跨插件调用;不要通过 `commands.execute` 调用它,
也不要绕过宿主授权的文件选择上下文。
每个输入最多 8 GiB,单次操作总输入最多 16 GiB。输入快照和输出暂存需要足够磁盘空间。
取消时先停止宿主管理的任务,再清理临时资源;关闭表单不会中止任务。
宿主重启会中断操作,不会自动重放合并。
25 changes: 21 additions & 4 deletions plugins/motrix.media-merge/locales/en-US.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
{
"name": "Media Merge",
"description": "Manually combine a downloaded or local video and audio file into MP4 or MKV without re-encoding. Requires a Motrix build with the manual media merge interface.",
"description": "Combine local video and audio into MP4 or MKV through plugin operations without re-encoding.",
"merge": "Merge audio and video",
"ffmpegMissing": "Configure FFmpeg in Settings > Integration > Media Tools, then restart the plugin.",
"differentFiles": "Choose two different files.",
"outputFormat": "Choose an MP4 or MKV output file.",
"missingStreams": "The selected files must provide a video track and an audio track. Check the files and try again."
"missingStreams": "The selected files must provide a video track and an audio track. Check the files and try again.",
"operationDescription": "Bring your video and audio together in one file, without re-encoding.",
"videoInput": "Video file",
"audioInput": "Audio file",
"format": "Output format",
"output": "Output file",
"videoInputPlaceholder": "Choose video",
"audioInputPlaceholder": "Choose audio",
"outputPlaceholder": "Choose a save location",
"videoInputBrowse": "Choose video file",
"audioInputBrowse": "Choose audio file",
"outputBrowse": "Choose output file",
"videoInputHint": "The picture for your merged file",
"audioInputHint": "The sound for your merged file",
"outputHint": "Save as MP4 or MKV",
"outputNotice": "Use a new filename; existing files cannot be overwritten. If MP4 is incompatible, try MKV.",
"serverNotice": "Select files on the Motrix server. Files on this computer are not uploaded.",
"mergeAction": "Merge",
"mergeAgain": "Merge another file",
"preserveOriginals": "Original files are kept"
}
25 changes: 21 additions & 4 deletions plugins/motrix.media-merge/locales/zh-CN.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
{
"name": "音视频合并",
"description": "手动将已下载或本地的视频和音频无损封装为 MP4 或 MKV。需要支持手动媒体合并界面的 Motrix 版本。",
"description": "通过插件操作将本地音视频合并为 MP4 或 MKV,无需重新编码。",
"merge": "合并音频和视频",
"ffmpegMissing": "请在“设置 > 集成 > 媒体工具”中配置 FFmpeg,然后重新启用插件。",
"differentFiles": "请选择两个不同的文件。",
"outputFormat": "请选择 MP4 或 MKV 输出文件。",
"missingStreams": "所选文件需要分别提供视频轨和音频轨,请检查文件后重试。"
"missingStreams": "所选文件需要分别提供视频轨和音频轨,请检查文件后重试。",
"operationDescription": "将视频画面与音频合为一个文件,无需重新编码。",
"videoInput": "视频文件",
"audioInput": "音频文件",
"format": "输出格式",
"output": "输出文件",
"videoInputPlaceholder": "选择视频",
"audioInputPlaceholder": "选择音频",
"outputPlaceholder": "选择保存位置",
"videoInputBrowse": "选择视频文件",
"audioInputBrowse": "选择音频文件",
"outputBrowse": "选择输出文件",
"videoInputHint": "提供合并后的画面",
"audioInputHint": "提供合并后的声音",
"outputHint": "保存为 MP4 或 MKV",
"outputNotice": "请使用新文件名,已有文件不会被覆盖。MP4 不兼容时可尝试 MKV。",
"serverNotice": "选择 Motrix 服务器上的文件;不会上传本机文件。",
"mergeAction": "合并",
"mergeAgain": "再次合并",
"preserveOriginals": "无损合并,保留源文件"
}
Loading
Loading