Repository navigation
Description
What happens
assembly caption fails after transcription and SRT export when the system temporary directory path contains a colon (:) or an apostrophe ('). The temporary SRT file is written correctly, but ffmpeg cannot open it through the generated -vf subtitles=... filter.
Tested on CLI main a4a7760ad7925f5feb1f4776d56b5ffd299f3d54, Linux (Fedora 44), Python 3.13.14, ffmpeg 8.1.2. The real Typer command, the real temp-directory handling and real ffmpeg were used. Only the AssemblyAI transcription boundary was replaced with an in-process fake, so no API request or billing was involved.
TMPDIR directory name |
Exit | Result |
|---|---|---|
tmp-plain |
0 | Captioned video written |
tmp,semi;brk[1] |
0 | Captioned video written (comma, semicolon and brackets already work) |
tmp:colon |
1 | Error: Could not write talk.captioned.mp4: Error opening output files: Invalid argument |
tmp'quote |
1 | Error: Could not write talk.captioned.mp4: Error opening output files: No such file or directory |
In the failing cases, transcription and SRT export had already happened before ffmpeg failed.
Reproduction (from the repository root, no API key needed)
Save as /tmp/repro_caption.py:
import sys
from types import SimpleNamespace
from typer.testing import CliRunner
from aai_cli.core import client
from aai_cli.main import app
SRT = "1\n00:00:00,000 --> 00:00:02,000\nHello captions\n"
def fake_transcribe(api_key, audio, *, config):
return SimpleNamespace(id="fake", export_subtitles_srt=lambda chars_per_caption=None: SRT)
client.transcribe = fake_transcribe # the only stubbed boundary
result = CliRunner().invoke(app, ["caption", sys.argv[1]])
print(result.exit_code)
print(result.output)mkdir -p /tmp/aai-repro/plain "/tmp/aai-repro/tmp:colon" "/tmp/aai-repro/tmp'quote"
ffmpeg -hide_banner -loglevel error -y -f lavfi -i color=c=black:s=320x240:r=1:d=2 \
-c:v mpeg4 /tmp/aai-repro/talk.mp4
export ASSEMBLYAI_API_KEY=fake-not-a-real-key AAI_TELEMETRY_DISABLED=1 \
XDG_CONFIG_HOME="$(mktemp -d)"
TMPDIR=/tmp/aai-repro/plain uv run python /tmp/repro_caption.py /tmp/aai-repro/talk.mp4
TMPDIR="/tmp/aai-repro/tmp:colon" uv run python /tmp/repro_caption.py /tmp/aai-repro/talk.mp4
TMPDIR="/tmp/aai-repro/tmp'quote" uv run python /tmp/repro_caption.py /tmp/aai-repro/talk.mp4The first run exits 0. The colon and apostrophe runs exit 1 with the errors above.
Cause
subtitles_filter escapes the path once with \ for \':,;[], and _burn passes the result as the -vf value.
ffmpeg parses that value twice: the filtergraph parser removes one level of escaping, then the subtitles filter's option parser reads filename and treats : as an option separator and ' as quoting. With a single level, the colon escape is gone by the time the option parser sees it. A path /x/tmp:colon/captions.srt becomes the filename /x/tmp plus a stray option, which matches the Invalid argument error.
Comma, semicolon and brackets are only special to the filtergraph parser, which is why the current single level works for them.
Independent ffmpeg controls with no CLI code involved confirm this. On the same files, a two-level escaped filename (for example tmp\\:colon and o\\\'brien in the -vf value) renders the subtitles: the output frame hashes differ from the uncaptioned video. The current single-level form fails.
Windows
Windows temporary paths contain a drive colon (C:\Users\...\Temp\...), so they likely run into the same colon handling. This is a suspicion only. It has not been tested on a native Windows host. The only check was a Linux parser probe using a directory literally named C:.
Activity