Extraction works

This commit is contained in:
Guillaume Tâche
2024-08-04 21:55:30 +02:00
parent 8002fc6719
commit 5efdaa6f63
121 changed files with 3360 additions and 400 deletions

View File

@@ -71,7 +71,7 @@ public class FFmpegVideoConverter extends AbstractProcessRunner implements Video
args.add("-map");
args.add(String.valueOf(n));
args.add("-metadata:s:s:" + n);
args.add("language=" + c.locale().getISO3Language());
args.add("language=" + c.language().iso3());
});
args.add(out.toString());
run(args);
@@ -114,7 +114,7 @@ public class FFmpegVideoConverter extends AbstractProcessRunner implements Video
);
run(args);
Files.deleteIfExists(dumpVideoPath);
return new FileAudioImpl(audioPath, new AudioInfoImpl("wav"));
return new FileAudioImpl(audioPath, new AudioInfoImpl("wav", video.info().duration()));
}
private static Path getPath(final Video video) throws IOException {

View File

@@ -7,17 +7,12 @@ import com.github.gtache.autosubtitle.ffmpeg.FFprobeVideoLoader;
import dagger.Binds;
import dagger.Module;
import javax.inject.Singleton;
@Module
public interface FFmpegModule {
@Binds
@Singleton
VideoConverter bindsVideoConverter(final FFmpegVideoConverter converter);
@Binds
@Singleton
VideoLoader bindsVideoLoader(final FFprobeVideoLoader loader);
}

View File

@@ -1,4 +1,4 @@
package com.github.gtache.autosubtitle.setup.modules.ffmpeg;
package com.github.gtache.autosubtitle.modules.setup.ffmpeg;
import com.github.gtache.autosubtitle.modules.ffmpeg.FFBundledRoot;
import com.github.gtache.autosubtitle.modules.ffmpeg.FFmpegBundledPath;
@@ -7,9 +7,9 @@ import com.github.gtache.autosubtitle.modules.ffmpeg.FFmpegVersion;
import com.github.gtache.autosubtitle.modules.ffmpeg.FFprobeBundledPath;
import com.github.gtache.autosubtitle.modules.ffmpeg.FFprobeSystemPath;
import com.github.gtache.autosubtitle.modules.impl.ExecutableExtension;
import com.github.gtache.autosubtitle.modules.setup.impl.VideoConverterSetup;
import com.github.gtache.autosubtitle.setup.SetupManager;
import com.github.gtache.autosubtitle.setup.ffmpeg.FFmpegSetupManager;
import com.github.gtache.autosubtitle.setup.modules.impl.VideoConverterSetup;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;

View File

@@ -5,10 +5,9 @@ import com.github.gtache.autosubtitle.impl.OS;
import com.github.gtache.autosubtitle.modules.ffmpeg.FFmpegBundledPath;
import com.github.gtache.autosubtitle.modules.ffmpeg.FFmpegSystemPath;
import com.github.gtache.autosubtitle.modules.ffmpeg.FFmpegVersion;
import com.github.gtache.autosubtitle.process.impl.AbstractProcessRunner;
import com.github.gtache.autosubtitle.setup.SetupException;
import com.github.gtache.autosubtitle.setup.SetupManager;
import com.github.gtache.autosubtitle.setup.SetupStatus;
import com.github.gtache.autosubtitle.setup.impl.AbstractSetupManager;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -21,7 +20,7 @@ import java.util.Objects;
/**
* Manager managing the FFmpeg installation
*/
public class FFmpegSetupManager extends AbstractProcessRunner implements SetupManager {
public class FFmpegSetupManager extends AbstractSetupManager {
private static final Logger logger = LogManager.getLogger(FFmpegSetupManager.class);
private final Path bundledPath;
private final Path systemPath;
@@ -46,16 +45,17 @@ public class FFmpegSetupManager extends AbstractProcessRunner implements SetupMa
}
@Override
public SetupStatus status() {
public SetupStatus getStatus() throws SetupException {
try {
if (checkSystemFFmpeg() || checkBundledFFmpeg()) {
return SetupStatus.INSTALLED;
if (checkSystemFFmpeg()) {
return SetupStatus.SYSTEM_INSTALLED;
} else if (checkBundledFFmpeg()) {
return SetupStatus.BUNDLE_INSTALLED;
} else {
return SetupStatus.NOT_INSTALLED;
}
} catch (final IOException e) {
logger.error("Error checking status of {}", name(), e);
return SetupStatus.ERRORED;
throw new SetupException(e);
}
}
@@ -75,7 +75,7 @@ public class FFmpegSetupManager extends AbstractProcessRunner implements SetupMa
}
private boolean checkSystemFFmpeg() throws IOException {
final var result = run(systemPath.toString(), "-h");
final var result = run(systemPath.toString(), "-version");
return result.exitCode() == 0;
}

View File

@@ -8,7 +8,8 @@ module com.github.gtache.autosubtitle.ffmpeg {
requires org.apache.logging.log4j;
exports com.github.gtache.autosubtitle.ffmpeg;
exports com.github.gtache.autosubtitle.modules.ffmpeg;
exports com.github.gtache.autosubtitle.setup.ffmpeg;
exports com.github.gtache.autosubtitle.setup.modules.ffmpeg;
exports com.github.gtache.autosubtitle.modules.ffmpeg;
exports com.github.gtache.autosubtitle.modules.setup.ffmpeg;
}