Remotion LabRemotion Lab
渲染編碼與格式

編碼與格式

了解 Remotion 支援的影片編碼器和輸出格式。

支援的編碼器

Remotion 透過 FFmpeg 支援多種影片編碼器:

編碼器格式說明建議使用場景
h264MP4最通用的編碼器社群媒體、一般用途
h265MP4更好的壓縮,較小檔案需要小檔案時
vp8WebM開放格式網頁嵌入
vp9WebMVP8 的改進版網頁嵌入(更好品質)
proresMOVApple ProRes專業後製

指定編碼器

CLI

npx remotion render MyComp out/video.mp4 --codec=h264

Node.js API

import { renderMedia } from "@remotion/renderer";
 
await renderMedia({
  composition,
  serveUrl: bundled,
  codec: "h264",
  outputLocation: "out/video.mp4",
});

品質控制

CRF(Constant Rate Factor)

CRF 控制壓縮品質。數值越低 = 品質越好 = 檔案越大:

# H.264: CRF 範圍 1-51,預設 18
npx remotion render MyComp out/video.mp4 --crf=15
 
# VP9: CRF 範圍 0-63,預設 28
npx remotion render MyComp out/video.webm --codec=vp9 --crf=20
CRF品質檔案大小
1-15近乎無損非常大
16-23高品質適中
24-35一般品質較小
36+低品質很小

位元率

也可以直接指定位元率:

npx remotion render MyComp out/video.mp4 --video-bitrate=8M

渲染靜態圖片

# 渲染單幀為 PNG
npx remotion still MyComp out/thumb.png --frame=45
 
# 渲染為 JPEG
npx remotion still MyComp out/thumb.jpeg --frame=45 --image-format=jpeg

渲染 GIF

npx remotion render MyComp out/animation.gif

GIF 適合短動畫(建議 5 秒以內),檔案會比較大。

透明影片

需要透明背景時,使用 ProRes 或 VP9:

# ProRes 4444(含 alpha 通道)
npx remotion render MyComp out/video.mov --codec=prores --prores-profile=4444
 
# VP9(含 alpha 通道)
npx remotion render MyComp out/video.webm --codec=vp9

確保你的 Composition 背景是透明的(不要設定 backgroundColor)。

選擇建議

場景建議編碼器格式
社群媒體發布H.264MP4
網頁嵌入VP9WebM
專業後製ProResMOV
短動畫 / 迷因GIF
需要透明背景ProRes 4444 或 VP9MOV / WebM

小結

  • H.264 MP4 是最通用的選擇
  • CRF 值控制品質與檔案大小的平衡
  • remotion still 渲染靜態圖片
  • 透明影片用 ProRes 4444 或 VP9