ADD metadata endpoints + update Bruno
This commit is contained in:
@@ -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<VideoMetadata> 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<VideoMetadata> getConvertedMetadata(@PathVariable String uuid) {
|
||||
VideoMetadata convertedMetadata = jobService.getJob(uuid).getOutputVideoMetadata();
|
||||
|
||||
if (convertedMetadata == null) {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.body(convertedMetadata);
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ public class UploadController {
|
||||
this.uploadService = uploadService;
|
||||
}
|
||||
|
||||
@PostMapping("/")
|
||||
@PostMapping()
|
||||
public ResponseEntity<String> uploadVideo(@RequestParam("file") MultipartFile file) {
|
||||
String uuid = uploadService.upload(file);
|
||||
|
||||
|
||||
@@ -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<String> command, Float fps, Integer width, Integer height) {
|
||||
List<String> 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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user