Skip to content

A self-hosted media server and file management system

fix: mov_text doesn't work without re-encode

aminnausinee519f5635dc
diff --git a/app/Services/Subtitles/SubtitleExtractor.php b/app/Services/Subtitles/SubtitleExtractor.php
index 9b1ef89f..2b99b53a 100644
--- a/app/Services/Subtitles/SubtitleExtractor.php
+++ b/app/Services/Subtitles/SubtitleExtractor.php
@@ -22,12 +22,18 @@ class SubtitleExtractor {
try {
$mediaPath = $metadata->video->path;
- $ext = $this->getExtensionFromCodec($subtitle['codec']);
+ $codec = $subtitle['codec'];
+ $ext = $this->getExtensionFromCodec($codec);
$pathStart = microtime(true);
$outputPath = $this->getOutputPath($subtitle, $ext);
$timings['get_output_path'] = microtime(true) - $pathStart;
+ $encoder = match ($codec) {
+ 'mov_text' => 'srt',
+ default => 'copy',
+ };
+
$commandStart = microtime(true);
$command = [
'ffmpeg',
@@ -40,15 +46,15 @@ class SubtitleExtractor {
'-vn', // skip reading video
'-an', // skip reading audio
'-c:s',
- 'copy', // don't re-encode
+ $encoder, // don't re-encode unless mov_text
Storage::disk('local')->path($outputPath),
];
$timings['build_command'] = microtime(true) - $commandStart;
$ffmpegStart = microtime(true);
$process = new Process($command);
- $process->mustRun();
$process->setTimeout(300);
+ $process->mustRun();
$timings['ffmpeg_execution'] = microtime(true) - $ffmpegStart;
$verifyStart = microtime(true);