Files
XC_VM/tests/Unit/StreamProcessSubtitleImportTest.php
T
obscuremindandClaude Opus 5.5 aba0a1e06c fix(streams): quote subtitle names and list paths, stop a deleted recording
- A subtitle track's name went on ffmpeg's command line through
  escapeshellcmd(), which leaves spaces alone: "English (SDH) forced"
  became three arguments and the movie's encode failed. Each is one
  escapeshellarg()'d argument.
- A quote in a created channel's source path ended the path in ffmpeg's
  concat list, which then did not parse.
- Deleting a recording killed by grep 'Record[<id>]': bare brackets are
  a character class, which never matched the process's title, and the
  recording went on to its end.
- Archive cleanup took any entry whose name began with a stream's id for
  that stream's archive: a recording's "<id>.ts" beside it was removed.
- The RTMP endpoint's shutdown never saw $db, so it closed nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 14:51:41 +00:00

44 lines
1.6 KiB
PHP

<?php
use PHPUnit\Framework\TestCase;
use XcVm\Domain\Stream\StreamProcess;
/**
* StreamProcess::buildSubtitleImport() — movies and episodes saved without
* subtitles store movie_subtitles as NULL, and startMovie() hands that value
* over. With a `string` parameter it threw, killing the queue daemon that
* encodes the movie queue.
*/
final class StreamProcessSubtitleImportTest extends TestCase {
private function build(?string $rJson): array {
$rMethod = new ReflectionMethod(StreamProcess::class, 'buildSubtitleImport');
$rMethod->setAccessible(true);
return $rMethod->invoke(null, $rJson, []);
}
public function testNoSubtitlesImportsNothing(): void {
$this->assertSame(['', ''], $this->build(null));
$this->assertSame(['', ''], $this->build(''));
$this->assertSame(['', ''], $this->build('{"files":[]}'));
}
/**
* A track's name is one argument of ffmpeg whatever it holds. It was put
* on the command line through escapeshellcmd(), which leaves spaces alone:
* "English (SDH) forced" became three arguments, the last two read as
* output files, and the movie's encode failed.
*/
public function testATracksNameIsOneArgument(): void {
$rFile = tempnam(sys_get_temp_dir(), 'sub');
try {
[, $rMetadata] = $this->build((string) json_encode(['files' => [$rFile], 'names' => ['English (SDH) forced'], 'charset' => ['UTF-8'], 'location' => SERVER_ID]));
$rArgs = [];
exec('printf "%s\\n" ' . $rMetadata, $rArgs);
$this->assertSame(['-map', '1', '-metadata:s:s:0', 'title=English (SDH) forced', '-metadata:s:s:0', 'language=English (SDH) forced'], $rArgs);
} finally {
@unlink($rFile);
}
}
}