REFACTOR for consistency
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
import {VideoMetadataFrontend} from "Frontend/components/Playbar";
|
|
||||||
import RangeSlider from 'react-range-slider-input';
|
import RangeSlider from 'react-range-slider-input';
|
||||||
import 'react-range-slider-input/dist/style.css';
|
import 'react-range-slider-input/dist/style.css';
|
||||||
import {useRef} from "react";
|
import {useRef} from "react";
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
|
import VideoMetadata from "Frontend/generated/com/ddf/vodsystem/entities/VideoMetadata";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
videoRef: HTMLVideoElement | null;
|
videoRef: HTMLVideoElement | null;
|
||||||
videoMetadata: VideoMetadataFrontend;
|
videoMetadata: VideoMetadata;
|
||||||
setSliderValue: Function;
|
setSliderValue: Function;
|
||||||
setClipRangeValue: Function;
|
setClipRangeValue: Function;
|
||||||
className?: string;
|
className?: string;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import {VideoMetadataFrontend} from "Frontend/components/Playbar";
|
|
||||||
import {useEffect, useState} from "react";
|
import {useEffect, useState} from "react";
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
|
import VideoMetadata from "Frontend/generated/com/ddf/vodsystem/entities/VideoMetadata";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
videoRef: HTMLVideoElement | null;
|
videoRef: HTMLVideoElement | null;
|
||||||
videoMetadata: VideoMetadataFrontend;
|
videoMetadata: VideoMetadata;
|
||||||
sliderValue: number;
|
sliderValue: number;
|
||||||
setSliderValue: Function;
|
setSliderValue: Function;
|
||||||
className?: string;
|
className?: string;
|
||||||
|
|||||||
@@ -1,20 +1,12 @@
|
|||||||
import { useEffect, useState} from "react";
|
import { useEffect, useState} from "react";
|
||||||
import { Volume, Play, Pause } from 'lucide-react';
|
import { Volume, Play, Pause } from 'lucide-react';
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
|
import VideoMetadata from "Frontend/generated/com/ddf/vodsystem/entities/VideoMetadata";
|
||||||
|
|
||||||
|
|
||||||
export type VideoMetadataFrontend = {
|
|
||||||
startPoint: number,
|
|
||||||
endPoint: number,
|
|
||||||
fps: number,
|
|
||||||
width: number,
|
|
||||||
height: number,
|
|
||||||
fileSize: number
|
|
||||||
}
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
video: HTMLVideoElement | null;
|
video: HTMLVideoElement | null;
|
||||||
videoMetadata: VideoMetadataFrontend;
|
videoMetadata: VideoMetadata;
|
||||||
className?: string;
|
className?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -87,9 +79,11 @@ export default function Playbar({ video, videoMetadata, className }: Props) {
|
|||||||
<button onClick={togglePlay}>
|
<button onClick={togglePlay}>
|
||||||
{isPlaying ? <Pause size={24} /> : <Play size={24} />}
|
{isPlaying ? <Pause size={24} /> : <Play size={24} />}
|
||||||
</button>
|
</button>
|
||||||
<label>
|
{videoMetadata.endPoint &&
|
||||||
{formatTime(video?.currentTime ?? 0)} / {formatTime(videoMetadata.endPoint)}
|
<label>
|
||||||
</label>
|
{formatTime(video?.currentTime ?? 0)} / {formatTime(videoMetadata.endPoint)}
|
||||||
|
</label>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import { VideoMetadataFrontend } from "Frontend/components/Playbar";
|
|
||||||
import Playbar from "./../../components/Playbar";
|
import Playbar from "./../../components/Playbar";
|
||||||
import PlaybackSlider from "./../../components/PlaybackSlider";
|
import PlaybackSlider from "./../../components/PlaybackSlider";
|
||||||
import ClipRangeSlider from "./../../components/ClipRangeSlider";
|
import ClipRangeSlider from "./../../components/ClipRangeSlider";
|
||||||
import ClipConfig from "./../../components/ClipConfig";
|
import ClipConfig from "./../../components/ClipConfig";
|
||||||
import * as editService from "../../generated/EditService";
|
import * as editService from "../../generated/EditService";
|
||||||
|
import * as metadataService from "../../generated/MetadataService"
|
||||||
import VideoMetadata from "Frontend/generated/com/ddf/vodsystem/entities/VideoMetadata";
|
import VideoMetadata from "Frontend/generated/com/ddf/vodsystem/entities/VideoMetadata";
|
||||||
|
|
||||||
function exportFile(uuid: string,
|
function exportFile(uuid: string,
|
||||||
@@ -36,7 +36,7 @@ export default function VideoId() {
|
|||||||
const videoRef = useRef<HTMLVideoElement | null>(null);
|
const videoRef = useRef<HTMLVideoElement | null>(null);
|
||||||
const videoUrl = `api/v1/download/input/${id}`
|
const videoUrl = `api/v1/download/input/${id}`
|
||||||
|
|
||||||
const [metadata, setMetadata] = useState<VideoMetadataFrontend | null>(null);
|
const [metadata, setMetadata] = useState<VideoMetadata | null>(null);
|
||||||
const [playbackValue, setPlaybackValue] = useState(0);
|
const [playbackValue, setPlaybackValue] = useState(0);
|
||||||
const [clipRangeValue, setClipRangeValue] = useState([0, 1]);
|
const [clipRangeValue, setClipRangeValue] = useState([0, 1]);
|
||||||
const [width, setWidth] = useState(1280);
|
const [width, setWidth] = useState(1280);
|
||||||
@@ -45,13 +45,11 @@ export default function VideoId() {
|
|||||||
const [fileSize, setFileSize] = useState(10);
|
const [fileSize, setFileSize] = useState(10);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch(`api/v1/metadata/original/${id}`)
|
if (!id) return;
|
||||||
.then((res) => {
|
|
||||||
if (!res.ok) throw new Error("Failed to fetch metadata");
|
metadataService.getInputFileMetadata(id)
|
||||||
return res.json();
|
.then((data) => setMetadata(data ?? null)) // 👈 Normalize undefined to null
|
||||||
})
|
.catch((err) => console.error("Metadata fetch failed:", err));
|
||||||
.then(setMetadata)
|
|
||||||
.catch((err) => console.log(err.message));
|
|
||||||
}, [id]);
|
}, [id]);
|
||||||
|
|
||||||
const sendData = () => {
|
const sendData = () => {
|
||||||
|
|||||||
@@ -28,12 +28,6 @@ public class CompressionService {
|
|||||||
|
|
||||||
private final Pattern timePattern = Pattern.compile("out_time_ms=([\\d:.]+)");
|
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) {
|
private void buildFilters(ArrayList<String> command, Float fps, Integer width, Integer height) {
|
||||||
List<String> filters = new ArrayList<>();
|
List<String> filters = new ArrayList<>();
|
||||||
|
|
||||||
@@ -138,10 +132,6 @@ public class CompressionService {
|
|||||||
throw new FFMPEGException("FFMPEG process failed");
|
throw new FFMPEGException("FFMPEG process failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
// set new metadata
|
|
||||||
VideoMetadata newMetadata = metadataService.getVideoMetadata(job.getOutputFile());
|
|
||||||
job.setOutputVideoMetadata(newMetadata);
|
|
||||||
|
|
||||||
job.setStatus(JobStatus.FINISHED);
|
job.setStatus(JobStatus.FINISHED);
|
||||||
logger.info("FFMPEG finished");
|
logger.info("FFMPEG finished");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.ddf.vodsystem.services;
|
package com.ddf.vodsystem.services;
|
||||||
|
|
||||||
|
import com.ddf.vodsystem.entities.Job;
|
||||||
import com.ddf.vodsystem.entities.VideoMetadata;
|
import com.ddf.vodsystem.entities.VideoMetadata;
|
||||||
import com.ddf.vodsystem.exceptions.FFMPEGException;
|
import com.ddf.vodsystem.exceptions.FFMPEGException;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
@@ -21,6 +22,12 @@ import java.io.InputStreamReader;
|
|||||||
public class MetadataService {
|
public class MetadataService {
|
||||||
private static Logger logger = LoggerFactory.getLogger(MetadataService.class);
|
private static Logger logger = LoggerFactory.getLogger(MetadataService.class);
|
||||||
|
|
||||||
|
private final JobService jobService;
|
||||||
|
|
||||||
|
public MetadataService(JobService jobService) {
|
||||||
|
this.jobService = jobService;
|
||||||
|
}
|
||||||
|
|
||||||
public VideoMetadata getVideoMetadata(File file) {
|
public VideoMetadata getVideoMetadata(File file) {
|
||||||
logger.info("Getting metadata for file {}", file.getAbsolutePath());
|
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{
|
private JsonNode readStandardOutput(Process process) throws IOException{
|
||||||
// Read the standard output (JSON metadata)
|
// Read the standard output (JSON metadata)
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||||
|
|||||||
Reference in New Issue
Block a user