REFACTOR for consistency
This commit is contained in:
@@ -28,12 +28,6 @@ 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<>();
|
||||
|
||||
@@ -138,10 +132,6 @@ 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");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ddf.vodsystem.services;
|
||||
|
||||
import com.ddf.vodsystem.entities.Job;
|
||||
import com.ddf.vodsystem.entities.VideoMetadata;
|
||||
import com.ddf.vodsystem.exceptions.FFMPEGException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
@@ -21,6 +22,12 @@ import java.io.InputStreamReader;
|
||||
public class MetadataService {
|
||||
private static Logger logger = LoggerFactory.getLogger(MetadataService.class);
|
||||
|
||||
private final JobService jobService;
|
||||
|
||||
public MetadataService(JobService jobService) {
|
||||
this.jobService = jobService;
|
||||
}
|
||||
|
||||
public VideoMetadata getVideoMetadata(File file) {
|
||||
logger.info("Getting metadata for file {}", file.getAbsolutePath());
|
||||
|
||||
@@ -45,6 +52,16 @@ public class MetadataService {
|
||||
|
||||
}
|
||||
|
||||
public VideoMetadata getInputFileMetadata(String uuid) {
|
||||
Job job = jobService.getJob(uuid);
|
||||
return getVideoMetadata(job.getInputFile());
|
||||
}
|
||||
|
||||
public VideoMetadata getOutputFileMetadata(String uuid) {
|
||||
Job job = jobService.getJob(uuid);
|
||||
return getVideoMetadata(job.getOutputFile());
|
||||
}
|
||||
|
||||
private JsonNode readStandardOutput(Process process) throws IOException{
|
||||
// Read the standard output (JSON metadata)
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
|
||||
Reference in New Issue
Block a user