diff --git a/bruno/VoD-System/Download Input.bru b/bruno/VoD-System/Download Input.bru deleted file mode 100644 index 1e10802..0000000 --- a/bruno/VoD-System/Download Input.bru +++ /dev/null @@ -1,11 +0,0 @@ -meta { - name: Download Input - type: http - seq: 7 -} - -get { - url: {{base_url}}/api/v1/download/input/{{video_uuid}} - body: none - auth: inherit -} diff --git a/bruno/VoD-System/Download Output.bru b/bruno/VoD-System/Download Output.bru deleted file mode 100644 index a85fc85..0000000 --- a/bruno/VoD-System/Download Output.bru +++ /dev/null @@ -1,11 +0,0 @@ -meta { - name: Download Output - type: http - seq: 6 -} - -get { - url: {{base_url}}/api/v1/download/output/{{video_uuid}} - body: none - auth: inherit -} diff --git a/bruno/VoD-System/Edit.bru b/bruno/VoD-System/Edit.bru deleted file mode 100644 index ca2ec0c..0000000 --- a/bruno/VoD-System/Edit.bru +++ /dev/null @@ -1,17 +0,0 @@ -meta { - name: Edit - type: http - seq: 3 -} - -post { - url: {{base_url}}/api/v1/edit/{{video_uuid}} - body: formUrlEncoded - auth: inherit -} - -body:form-urlencoded { - startPoint: 10 - endPoint: 30 - fileSize: 8000 -} diff --git a/bruno/VoD-System/Process.bru b/bruno/VoD-System/Process.bru deleted file mode 100644 index 2a1595c..0000000 --- a/bruno/VoD-System/Process.bru +++ /dev/null @@ -1,11 +0,0 @@ -meta { - name: Process - type: http - seq: 4 -} - -get { - url: {{base_url}}/api/v1/process/{{video_uuid}} - body: none - auth: inherit -} diff --git a/bruno/VoD-System/Progress.bru b/bruno/VoD-System/Progress.bru deleted file mode 100644 index d7bb165..0000000 --- a/bruno/VoD-System/Progress.bru +++ /dev/null @@ -1,11 +0,0 @@ -meta { - name: Progress - type: http - seq: 5 -} - -get { - url: {{base_url}}/api/v1/progress/{{video_uuid}} - body: none - auth: inherit -} diff --git a/src/main/java/com/ddf/vodsystem/controllers/MetadataController.java b/src/main/java/com/ddf/vodsystem/controllers/MetadataController.java new file mode 100644 index 0000000..d47496c --- /dev/null +++ b/src/main/java/com/ddf/vodsystem/controllers/MetadataController.java @@ -0,0 +1,44 @@ +package com.ddf.vodsystem.controllers; + +import com.ddf.vodsystem.entities.VideoMetadata; +import com.ddf.vodsystem.services.JobService; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/api/v1/metadata") +public class MetadataController { + private final JobService jobService; + + public MetadataController(JobService jobService) { + this.jobService = jobService; + } + + @GetMapping("/original/{uuid}") + public ResponseEntity getMetadata(@PathVariable String uuid) { + VideoMetadata originalMetadata = jobService.getJob(uuid).getInputVideoMetadata(); + + if (originalMetadata == null) { + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + + return ResponseEntity.ok() + .body(originalMetadata); + } + + @GetMapping("/converted/{uuid}") + public ResponseEntity getConvertedMetadata(@PathVariable String uuid) { + VideoMetadata convertedMetadata = jobService.getJob(uuid).getOutputVideoMetadata(); + + if (convertedMetadata == null) { + return ResponseEntity.notFound().build(); + } + + return ResponseEntity.ok() + .body(convertedMetadata); + } +} diff --git a/src/main/java/com/ddf/vodsystem/controllers/UploadController.java b/src/main/java/com/ddf/vodsystem/controllers/UploadController.java index 7307ec1..5248086 100644 --- a/src/main/java/com/ddf/vodsystem/controllers/UploadController.java +++ b/src/main/java/com/ddf/vodsystem/controllers/UploadController.java @@ -18,7 +18,7 @@ public class UploadController { this.uploadService = uploadService; } - @PostMapping("/") + @PostMapping() public ResponseEntity uploadVideo(@RequestParam("file") MultipartFile file) { String uuid = uploadService.upload(file); diff --git a/src/main/java/com/ddf/vodsystem/services/CompressionService.java b/src/main/java/com/ddf/vodsystem/services/CompressionService.java index fb0ebad..6175504 100644 --- a/src/main/java/com/ddf/vodsystem/services/CompressionService.java +++ b/src/main/java/com/ddf/vodsystem/services/CompressionService.java @@ -28,6 +28,12 @@ public class CompressionService { private final Pattern timePattern = Pattern.compile("out_time_ms=([\\d:.]+)"); + private final MetadataService metadataService; + + public CompressionService(MetadataService metadataService) { + this.metadataService = metadataService; + } + private void buildFilters(ArrayList command, Float fps, Integer width, Integer height) { List filters = new ArrayList<>(); @@ -132,6 +138,10 @@ public class CompressionService { throw new FFMPEGException("FFMPEG process failed"); } + // set new metadata + VideoMetadata newMetadata = metadataService.getVideoMetadata(job.getOutputFile()); + job.setOutputVideoMetadata(newMetadata); + job.setStatus(JobStatus.FINISHED); logger.info("FFMPEG finished"); }