ADD metadata endpoints + update Bruno
This commit is contained in:
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
meta {
|
||||
name: Process
|
||||
type: http
|
||||
seq: 4
|
||||
}
|
||||
|
||||
get {
|
||||
url: {{base_url}}/api/v1/process/{{video_uuid}}
|
||||
body: none
|
||||
auth: inherit
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
meta {
|
||||
name: Progress
|
||||
type: http
|
||||
seq: 5
|
||||
}
|
||||
|
||||
get {
|
||||
url: {{base_url}}/api/v1/progress/{{video_uuid}}
|
||||
body: none
|
||||
auth: inherit
|
||||
}
|
||||
@@ -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