diff --git a/gymboard-api/.gitignore b/gymboard-api/.gitignore index 5e7b517..02a81a7 100644 --- a/gymboard-api/.gitignore +++ b/gymboard-api/.gitignore @@ -32,3 +32,4 @@ build/ .vscode/ .sample_data +exercise_submission_temp_files/ diff --git a/gymboard-api/src/main/java/nl/andrewlalis/gymboard_api/model/exercise/ExerciseSubmission.java b/gymboard-api/src/main/java/nl/andrewlalis/gymboard_api/model/exercise/ExerciseSubmission.java index 41e71f8..73f51f4 100644 --- a/gymboard-api/src/main/java/nl/andrewlalis/gymboard_api/model/exercise/ExerciseSubmission.java +++ b/gymboard-api/src/main/java/nl/andrewlalis/gymboard_api/model/exercise/ExerciseSubmission.java @@ -10,11 +10,22 @@ import java.time.LocalDateTime; @Entity @Table(name = "exercise_submission") public class ExerciseSubmission { + /** + * The status of a submission. + * + */ public enum Status { WAITING, PROCESSING, FAILED, - COMPLETED + COMPLETED, + VERIFIED } @Id diff --git a/gymboard-api/src/main/java/nl/andrewlalis/gymboard_api/service/ExerciseSubmissionService.java b/gymboard-api/src/main/java/nl/andrewlalis/gymboard_api/service/ExerciseSubmissionService.java index 6c2ab58..b3c3f34 100644 --- a/gymboard-api/src/main/java/nl/andrewlalis/gymboard_api/service/ExerciseSubmissionService.java +++ b/gymboard-api/src/main/java/nl/andrewlalis/gymboard_api/service/ExerciseSubmissionService.java @@ -211,6 +211,17 @@ public class ExerciseSubmissionService { log.info("Processing of submission {} complete.", submission.getId()); } + /** + * Uses the `ffmpeg` system command to process a raw input video and produce + * a compressed, reduced-size output video that's ready for usage in the + * application. + * @param dir The working directory. + * @param inFile The input file to read from. + * @param outFile The output file to write to. MUST have a ".mp4" extension. + * @throws IOException If a filesystem error occurs. + * @throws CommandFailedException If the ffmpeg command fails. + * @throws InterruptedException If the ffmpeg command is interrupted. + */ private void processVideo(Path dir, Path inFile, Path outFile) throws IOException, InterruptedException { Path tmpStdout = Files.createTempFile(dir, "stdout-", ".log"); Path tmpStderr = Files.createTempFile(dir, "stderr-", ".log"); @@ -240,6 +251,7 @@ public class ExerciseSubmissionService { String reductionFactorStr = String.format("%.3f%%", reductionFactor * 100); log.info("Processed video from {} bytes to {} bytes in {} seconds, {} reduction.", startSize, endSize, dur.getSeconds(), reductionFactorStr); + // Delete the logs if everything was successful. Files.deleteIfExists(tmpStdout); Files.deleteIfExists(tmpStderr); }