RENAME ClipConfig entity to VideoMetadata
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package com.ddf.vodsystem.services;
|
||||
|
||||
import com.ddf.vodsystem.entities.ClipConfig;
|
||||
import com.ddf.vodsystem.entities.VideoMetadata;
|
||||
import com.ddf.vodsystem.entities.JobStatus;
|
||||
import com.ddf.vodsystem.entities.Job;
|
||||
|
||||
@@ -84,19 +84,19 @@ public class CompressionService {
|
||||
}
|
||||
}
|
||||
|
||||
private ProcessBuilder buildCommand(File inputFile, File outputFile, ClipConfig clipConfig) {
|
||||
private ProcessBuilder buildCommand(File inputFile, File outputFile, VideoMetadata videoMetadata) {
|
||||
ArrayList<String> command = new ArrayList<>();
|
||||
command.add("ffmpeg");
|
||||
command.add("-progress");
|
||||
command.add("pipe:1");
|
||||
command.add("-y");
|
||||
|
||||
Float length = clipConfig.getEndPoint() - clipConfig.getStartPoint();
|
||||
buildInputs(command, inputFile, clipConfig.getStartPoint(), clipConfig.getEndPoint());
|
||||
buildFilters(command, clipConfig.getFps(), clipConfig.getWidth(), clipConfig.getHeight());
|
||||
Float length = videoMetadata.getEndPoint() - videoMetadata.getStartPoint();
|
||||
buildInputs(command, inputFile, videoMetadata.getStartPoint(), videoMetadata.getEndPoint());
|
||||
buildFilters(command, videoMetadata.getFps(), videoMetadata.getWidth(), videoMetadata.getHeight());
|
||||
|
||||
if (clipConfig.getFileSize() != null) {
|
||||
buildBitrate(command, length, clipConfig.getFileSize());
|
||||
if (videoMetadata.getFileSize() != null) {
|
||||
buildBitrate(command, length, videoMetadata.getFileSize());
|
||||
}
|
||||
|
||||
// Output file
|
||||
@@ -109,12 +109,12 @@ public class CompressionService {
|
||||
public void run(Job job) throws IOException, InterruptedException {
|
||||
logger.info("FFMPEG starting...");
|
||||
|
||||
ProcessBuilder pb = buildCommand(job.getInputFile(), job.getOutputFile(), job.getClipConfig());
|
||||
ProcessBuilder pb = buildCommand(job.getInputFile(), job.getOutputFile(), job.getVideoMetadata());
|
||||
Process process = pb.start();
|
||||
job.setStatus(JobStatus.RUNNING);
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
float length = job.getClipConfig().getEndPoint() - job.getClipConfig().getStartPoint();
|
||||
float length = job.getVideoMetadata().getEndPoint() - job.getVideoMetadata().getStartPoint();
|
||||
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.ddf.vodsystem.services;
|
||||
|
||||
import com.ddf.vodsystem.entities.ClipConfig;
|
||||
import com.ddf.vodsystem.entities.VideoMetadata;
|
||||
import com.ddf.vodsystem.entities.Job;
|
||||
import com.ddf.vodsystem.entities.JobStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -13,10 +13,10 @@ public class EditService {
|
||||
this.jobService = jobService;
|
||||
}
|
||||
|
||||
public void edit(String uuid, ClipConfig clipConfig) {
|
||||
public void edit(String uuid, VideoMetadata videoMetadata) {
|
||||
Job job = jobService.getJob(uuid);
|
||||
validateClipConfig(clipConfig);
|
||||
job.setClipConfig(clipConfig);
|
||||
validateClipConfig(videoMetadata);
|
||||
job.setVideoMetadata(videoMetadata);
|
||||
}
|
||||
|
||||
public void process(String uuid) {
|
||||
@@ -33,10 +33,10 @@ public class EditService {
|
||||
return job.getProgress();
|
||||
}
|
||||
|
||||
private void validateClipConfig(ClipConfig clipConfig) {
|
||||
Float start = clipConfig.getStartPoint();
|
||||
Float end = clipConfig.getEndPoint();
|
||||
Float fileSize = clipConfig.getFileSize();
|
||||
private void validateClipConfig(VideoMetadata videoMetadata) {
|
||||
Float start = videoMetadata.getStartPoint();
|
||||
Float end = videoMetadata.getEndPoint();
|
||||
Float fileSize = videoMetadata.getFileSize();
|
||||
|
||||
if (start != null && start < 0) {
|
||||
throw new IllegalArgumentException("Start point cannot be negative");
|
||||
|
||||
Reference in New Issue
Block a user