in src/backend/transcriber/src/main/java/com/amazonaws/transcriber/App.java [45:92]
public static void main(String... args) {
String input = config.mediaUrl();
String resolved = input;
LifecycleInfoPersister lcp = new LifecycleInfoPersister(resolved);
logger.info("Input is {}", resolved);
if (input.startsWith("https://www.youtube.com/")) {
resolved = getYouTubeUrl(config.youtubeDlPath(), input);
logger.info("YouTube input is %s", resolved);
}
Encoder encoder = new Encoder(config.ffmpegPath(), "s16le", resolved);
Transcriber transcriber = new Transcriber(input, LanguageCode.EN_US, MediaEncoding.PCM,
config.mediaSampleRate(), config.vocabularyName().orElse(""));
try {
InputStream mediaStream = encoder.start();
addShutdownHook(lcp);
CompletableFuture<Void> promise = transcriber.start(mediaStream);
logger.info("Persisting lifecycle stage PROCESSING in DynamoDb...");
lcp.transcriptionBegun();
// this blocks the main thread, we could have multiple transcriptions if we want by
// storing the promises in an array and then using an infinite loop to keep the main
// thread alive but as we only have one video per container this is not necessary
promise.get();
} catch (IOException ioe) {
logger.error("There was an error starting ffmpeg...", ioe);
error = ioe.getMessage();
} catch (InterruptedException ie) {
logger.info("Transcription thread stopped...");
} catch (ExecutionException ex) {
logger.error("Transcription errored...", ex);
error = ex.getMessage();
} finally {
logger.info("Stopping transcription.");
transcriber.stop();
logger.info("Stopping ffmpeg encoding.");
try {
encoder.stop();
} catch (IOException ioe) {
logger.error("The ffmpeg process errored.", ioe);
error = ioe.getMessage();
}
}
}