Skip to content

feat: server-side video transcoding (AV1 + VVC) with HLS/DASH delivery#13

Open
Sigma-project wants to merge 145 commits into
masterfrom
claude/video-encoding-9bWRd
Open

feat: server-side video transcoding (AV1 + VVC) with HLS/DASH delivery#13
Sigma-project wants to merge 145 commits into
masterfrom
claude/video-encoding-9bWRd

Conversation

@Sigma-project

@Sigma-project Sigma-project commented May 26, 2026

Copy link
Copy Markdown
Owner

Summary

アップロード済み動画をサーバー側でバックグラウンドにトランスコードし、AV1 (HLS+DASH) と任意の VVC (DASH のみ) で配信できるようにする。フロントの再生は HLS を優先(Safari はネイティブ、それ以外は hls.js を動的 import)。

フロントの mediabunny による事前圧縮はサイズ削減目的で残し、サーバー側はストリーミング向けにセグメンテーションを行う、という二段構え。AV1 で入ってきたファイルは -c:v copy で再エンコードを回避する。

主な変更

バックエンド

  • DB マイグレーション 1779779193946-videoTranscoding.js
    • drive_file: hlsManifestUrl, dashManifestUrl, transcodingStatus, transcodingPrefix, transcodingVariants
    • meta: enableVideoTranscoding, videoTranscodeMaxFileSize, videoTranscodeMaxDuration, keepOriginalAfterTranscoding
  • 新規サービス
    • FFmpegCapabilityService — 起動時に libsvtav1 / libvvenc / libopus を検出。未対応エンコーダはスキップ
    • VideoTranscodingServicefluent-ffmpeg ラッパー。CMAF fMP4 セグメント + HLS master / DASH manifest 生成
    • VideoTranscodingProgressService — Redis Pub/Sub による進捗イベント + ハッシュスナップショット
  • 専用 BullMQ キュー videoTranscodingVideoTranscodingProcessorService
    • フェーズ別 (downloading / probing / encoding-av1 / encoding-vvc / uploading) に重み付けして全体進捗を算出
    • 失敗は 3 回までリトライ、transcodingStatus = 'failed'
  • 新規 API: admin/video-transcoding/{list-jobs, cancel-job, retry-job}
  • 新規ストリーミングチャンネル: videoTranscoding
  • DriveService.addFile 後に enqueue / 削除時に S3 上の stream-*/ プレフィックス一式をクリーンアップ

設定(admin 設定)

  • 有効化トグル / 最大ファイルサイズ / 最大尺
  • keepOriginalAfterTranscoding — false の場合はトランスコード成功直後にオリジナルを削除、url を HLS master に差し替え(失敗時はオリジナルを保持)

フロントエンド

  • hls.js@1.5.20 を追加(動的 import で必要時のみロード)
  • MkMediaVideo.vuehlsManifestUrl があれば HLS を優先。Safari はネイティブ、それ以外は hls.js
  • 管理ページ /admin/video-transcoding
    • Capability 表示 / 設定フォーム / アクティブジョブのライブ進捗バー / Cancel / Retry / 直近の失敗ジョブ一覧

スコープ外

  • ABR (複数解像度)
  • ライブストリーミング
  • HEVC / H.264
  • 一般ユーザー向けの進捗表示(管理者のみ)

Test plan

  • pnpm migrate でマイグレーションが上がる / 下がる
  • ffmpeg -codecslibsvtav1 / libvvenc が含まれる環境で起動し、起動ログに Capability が出ること
  • Meta.enableVideoTranscoding = false のとき従来通り url 直接配信のままで、ジョブが投入されないこと
  • enableVideoTranscoding = true で短い .mp4 をアップロード → /admin/video-transcoding に進捗が 0% → 100% で流れ、master.m3u8 / manifest.mpd が生成されること
  • Chrome (hls.js 経由) と Safari (ネイティブ HLS) の両方で再生確認
  • keepOriginalAfterTranscoding = false でオリジナルが削除され、DriveFile.url が HLS master を指すこと
  • リモート / link ファイルは skip されること
  • Meta.videoTranscodeMaxDuration / videoTranscodeMaxFileSize の上限超過がスキップされること
  • Cancel ボタン / 失敗ジョブの Retry ボタンが動作すること
  • DriveFile を削除した際に stream-*/ 配下も削除されること

https://claude.ai/code/session_017qYaSfU7Mb73zQ64eiStdv

github-actions Bot and others added 30 commits December 22, 2025 05:30
…dev#16985)

* refactor: use TRANSIENT scope to avoid service bucket relay

* lint: fix lints

* refactor: use transient for apResolver

* Update packages/backend/src/core/activitypub/models/ApImageService.ts

* fix
…v#17024)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…#16888)

* ドライブクリーナーでファイル削除後、リロードなしで画面に反映されるように修正

* CHANGELOG.mdを修正

* CHANGELOGがおかしかったので修正
* enhance(frontend): MkDriveで自動でもっと見るを有効化

* Update Changelog
* add serach service test

* add meili test

* CIの修正が足りなかった

* テストの追加

* fix
* enhance(frontend): ウィジェットの設定画面を改良

* Update Changelog

* fix lint
* wip

* fix

* ref -> reactive

* tweak throttle threshold

* tweak throttle threshold

* rss設定にはmanualSaveを使用するように

* Update MkWidgetSettingsDialog.vue

---------

Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
* enhance(frontend): ウィジェットの設定項目の多言語対応

* Update Changelog

* refactor: move options locale key to root for optimizing artifacts for locale inlining

* fix

* fix

* ✌️

---------

Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
…ndieAuth 11 July 2024 spec (misskey-dev#17030)

* enhance(backend): Support client information discovery in the IndieAuth 11 July 2024 spec

* add tests

* Update Changelog

* Update Changelog

* fix tests

* fix test describe to align with the other describe format
)

* enhance(frontend): 「今日誕生日のフォロー中ユーザー」ウィジェットをリファクタリング

(cherry picked from commit 24652b9)

* fix(backend): 年越しの時期で誕生日検索クエリーが誤動作する問題を修正 (MisskeyIO#577)

(cherry picked from commit 3858100)

* fix

* spdx

* delete birthday param on users/following api

* 名称を一本化

* Update Changelog

* Update Changelog

* fix(frontend/WidgetBirthdayFollowings): ユーザーの名前が長いと投稿ボタンがはみ出てしまう問題を修正 (MisskeyIO#582)

(cherry picked from commit fa47a54)

* use module css

* default 3day

* Revert "delete birthday param on users/following api"

This reverts commit a47456c.

* Update Changelog

* 日付が1ヶ月ズレている問題を修正?

* fix: 日付関連のバグを修正

Co-authored-by: taiy <53635909+taiyme@users.noreply.github.com>

* build misskey-js types

* add comment

* Update CHANGELOG.md

* migrate

* change migration

* UPdate Changelog

* fix: revert unnecessary changes

* 🎨

* i18n

* fix

* update changelog

* 🎨

* fix lint

* refactor: remove unnecessary classes

* fix

* fix

---------

Co-authored-by: まっちゃとーにゅ <17376330+u1-liquid@users.noreply.github.com>
Co-authored-by: taiy <53635909+taiyme@users.noreply.github.com>
* fix(frontend): 登録日によるソートの場合はpaginator側のソートを使用するように

* Update Changelog

* fix lint

* refactor
…skey-dev#17058)

* refactor(frontend): prefer.model, store.modelではcustomRefを使用するように

* fix: watchの解除に失敗してもエラーで落ちないように

* Update packages/frontend/src/lib/pizzax.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* fix(frontend): ログインダイアログが表示されたあとの処理がおかしくなる問題を修正

* Update Changelog
…y-dev#17019)

* fix(frontend): ファイルタブのセンシティブメディアを開く際に確認ダイアログを出す設定が適用されない問題を修正

* Update Changelog

* refactor

* Update Changelog
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…key-dev#17059)

* fix(frontend): 管理画面でアーカイブ済のお知らせを表示した際にアクティブなお知らせが多い旨の警告が出る問題を修正

* Update Changelog

---------

Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
…7023)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* fix(deps): update [frontend] update dependencies

* rollback tsgo to fix type error

* Revert "rollback tsgo to fix type error"

This reverts commit 3a0b94e.

* rollback vue-tsc to fix type errors (test)

* update vue-tsc to 3.2.0

* update vue-tsc stack to v3.2.1

* rollback vue-tsc to v3.1.8
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

競合を解消:
- FileServerService.ts: masterのインライン化版(WasmVips/JXL対応)を採用し、/transcoded配信ルートとtranscodedHandlerを再適用
- backend/package.json: image-size追加 + ioredis 5.9.2維持
- frontend/package.json: @jsquash/jxl追加 + @mcaptcha/core-glue維持(hls.js維持、未使用のvanilla-glueは不採用)
- use-uploader.ts: masterの多段JXL圧縮フローを採用
- pnpm-lock.yaml: 解決済みpackage.jsonから再生成
- masterが削除したハンドラ群(FileServerProxyHandler/DriveHandler/FileResolver/Utils)を削除

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Thank you for sending us a great Pull Request! 👍
Please regenerate misskey-js type definitions! 🙏

example:

pnpm run build-misskey-js-with-types

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 29d49308b1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/backend/build.js
Comment on lines +59 to +63
parser: {
syntax: 'typescript',
decorators: true,
dynamicImport: true,
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Carry over TSX JSX settings in backend bundle

When pnpm build runs the new backend bundler, the entry point imports the web views under src/server/web/views/*.tsx through ClientServerService. This custom SWC parser config drops the JSX/TSX settings from .swcrc, so those TSX view files cannot be parsed during the production bundle build. Reuse the existing .swcrc JSX parser/transform settings here.

Useful? React with 👍 / 👎.

// Capability(libsvtav1/HLS)が無ければ投入しない
this.ffmpegCapabilityService.getCapabilities().then(caps => {
if (!caps.av1 || !caps.hls) return;
this.queueService.createVideoTranscodingJob(file.id);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Return the enqueue promise so failures are handled

If capability detection succeeds but Bull/Redis rejects createVideoTranscodingJob, this promise is not returned or awaited, so the .catch below does not run. On transient queue failures, the upload completes with no transcoding job and an unhandled rejection instead of the intended warning; return or await this promise from the then callback.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants