diff --git a/docs_v1.0/M4_workspace/2026-05-08_response_ffmpeg_evaluation.md b/docs_v1.0/M4_workspace/2026-05-08_response_ffmpeg_evaluation.md new file mode 100644 index 0000000..aa48ef3 --- /dev/null +++ b/docs_v1.0/M4_workspace/2026-05-08_response_ffmpeg_evaluation.md @@ -0,0 +1,41 @@ +# M4 Response: FFmpeg DrawText 選型回饋 + +## 核心遺漏:ARG_MAX overflow + +M5 的選型評估沒有解決 **真正導致 500 的原因** — `trace_video()` 為 trace #3128 (1109 detections) 產生的 filter_complex 字串超過 macOS 命令列長度限制 (~256KB)。 + +不管選 drawtext、ASS、還是 drawbox,只要 filter 寫在命令列上,超過 256KB 就會炸。 + +## 建議修正順序 + +### Step 1: `-filter_complex_script`(立即見效) + +把 filter 寫入 temp file 再餵給 ffmpeg,避開 ARG_MAX: + +```diff +- .arg("-filter_complex") +- .arg(&filter_str) ++ .arg("-filter_complex_script") ++ .arg(&temp_file_path) +``` + +這是 3 行程式碼的修改,**任何 filter 方案都適用**。 + +### Step 2: 加 fontfile(Unicode 中文) + +```diff +- drawtext=text='Cary Grant':fontsize=24 ++ drawtext=text='Cary Grant':fontsize=24:fontfile=/System/Library/Fonts/PingFang.ttc +``` + +### Step 3: 評估 ASS 方案(未來) + +ASS 格式本身就在檔案中,沒有 ARG_MAX 問題,且原生支援中文。 + +## 比較 + +| 方案 | 解決 ARG_MAX | Unicode | 開發量 | +|------|:------------:|:-------:|:------:| +| A: drawtext + script | ✅ | ❌ 需加 fontfile | 3 行 | +| B: ASS subtitles | ✅ (檔案) | ✅ | 中 | +| A+B: drawtext script + font | ✅ | ✅ | 3 行 + fontfile |