ADD status endpoint
This commit is contained in:
@@ -2,6 +2,7 @@ package com.ddf.vodsystem.controllers;
|
||||
|
||||
import com.ddf.vodsystem.entities.ClipConfig;
|
||||
import com.ddf.vodsystem.services.EditService;
|
||||
import org.atmosphere.config.service.Get;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -28,4 +29,9 @@ public class EditController {
|
||||
return new ResponseEntity<>(uuid, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/progress/{uuid}")
|
||||
public ResponseEntity<Float> getProgress(@PathVariable("uuid") String uuid) {
|
||||
return new ResponseEntity<>(editService.getProgress(uuid), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@@ -24,7 +25,7 @@ public class CompressionService {
|
||||
private static final float MAX_AUDIO_BITRATE = 128f;
|
||||
private static final float BITRATE_MULTIPLIER = 0.9f;
|
||||
|
||||
private Pattern timePattern = Pattern.compile("time=([\\d:.]+)");
|
||||
private Pattern timePattern = Pattern.compile("out_time_ms=([\\d:.]+)");
|
||||
private long out_time_ms;
|
||||
|
||||
private void buildFilters(ArrayList<String> command, Float fps, Integer width, Integer height) {
|
||||
@@ -114,10 +115,16 @@ public class CompressionService {
|
||||
job.setStatus(JobStatus.RUNNING);
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
Float length = job.getClipConfig().getEndPoint() - job.getClipConfig().getStartPoint();
|
||||
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
logger.debug(line);
|
||||
Matcher matcher = timePattern.matcher(line);
|
||||
if (matcher.find()) {
|
||||
Float progress = Float.parseFloat(matcher.group(1))/(length*1000000);
|
||||
job.setProgress(progress);
|
||||
}
|
||||
}
|
||||
|
||||
job.setStatus(JobStatus.FINISHED);
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ddf.vodsystem.services;
|
||||
|
||||
import com.ddf.vodsystem.entities.ClipConfig;
|
||||
import com.ddf.vodsystem.entities.Job;
|
||||
import com.ddf.vodsystem.exceptions.JobNotFound;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@@ -27,4 +28,14 @@ public class EditService {
|
||||
public void jobReady(String uuid) {
|
||||
jobService.jobReady(uuid);
|
||||
}
|
||||
|
||||
public float getProgress(String uuid) {
|
||||
Job job = jobService.get(uuid);
|
||||
|
||||
if (job == null) {
|
||||
throw new JobNotFound(uuid);
|
||||
}
|
||||
|
||||
return job.getProgress();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user