Skip to content

Commit

Permalink
Dubbing: Fix utest fail. v5.14.2
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Feb 22, 2024
1 parent 4296973 commit 12060ae
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 24 deletions.
10 changes: 5 additions & 5 deletions platform/dubbing.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func handleDubbingService(ctx context.Context, handler *http.ServeMux) error {
dubbing.FileType, dubbing.FilePath = targetFile.Type, targetFile.Path
})

if err := dubbing.CheckSource(ctx); err != nil {
if err := dubbing.CheckSource(ctx, targetFile.Target); err != nil {
return errors.Wrapf(err, "check source type=%v, %v", targetFile.Type, targetFile.Target)
}

Expand Down Expand Up @@ -2160,14 +2160,14 @@ func (v *SrsDubbingProject) Save(ctx context.Context) error {
return nil
}

func (v *SrsDubbingProject) CheckSource(ctx context.Context) error {
func (v *SrsDubbingProject) CheckSource(ctx context.Context, target string) error {
if v.FileType != FFprobeSourceTypeFile && v.FileType != FFprobeSourceTypeUpload {
return errors.Errorf("unsupported file type %v", v.FileType)
}

fileAbsPath, err := filepath.Abs(v.FilePath)
fileAbsPath, err := filepath.Abs(target)
if err != nil {
return errors.Wrapf(err, "abs %v", v.FilePath)
return errors.Wrapf(err, "abs %v", target)
}

var validExtension bool
Expand All @@ -2186,7 +2186,7 @@ func (v *SrsDubbingProject) CheckSource(ctx context.Context) error {
return errors.Wrapf(err, "stat %v", fileAbsPath)
}

logger.Tf(ctx, "check source ok, type=%v, file=%v", v.FileType, v.FilePath)
logger.Tf(ctx, "check source ok, type=%v, file=%v", v.FileType, target)
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions test/camera_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func TestScenario_WithStream_PublishCameraStreamUrl(t *testing.T) {
if ts := 90; m.Format.ProbeScore < ts {
r4 = errors.Errorf("low score=%v < %v, %v, %v", m.Format.ProbeScore, ts, m.String(), str)
}
if dv := m.Duration(); dv < duration/2 {
if dv := m.Duration(); dv < duration/3 {
r5 = errors.Errorf("short duration=%v < %v, %v, %v", dv, duration, m.String(), str)
}
}
Expand Down Expand Up @@ -409,7 +409,7 @@ func TestScenario_WithStream_PublishCameraVideoOnly(t *testing.T) {
if ts := 90; m.Format.ProbeScore < ts {
r4 = errors.Errorf("low score=%v < %v, %v, %v", m.Format.ProbeScore, ts, m.String(), str)
}
if dv := m.Duration(); dv < duration/2 {
if dv := m.Duration(); dv < duration/3 {
r5 = errors.Errorf("short duration=%v < %v, %v, %v", dv, duration, m.String(), str)
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ func prepareTest(ctx context.Context) (err error) {
srsFFmpegStderr = flag.Bool("srs-ffmpeg-stderr", false, "Whether enable the FFmpeg stderr log")
srsDVRStderr = flag.Bool("srs-dvr-stderr", false, "Whether enable the DVR stderr log")
srsFFprobeStdout = flag.Bool("srs-ffprobe-stdout", false, "Whether enable the FFprobe stdout log")
srsFFprobeDuration = flag.Int("srs-ffprobe-duration", 31000, "For each case, the duration for ffprobe in ms")
srsFFprobeTimeout = flag.Int("srs-ffprobe-timeout", 32000, "For each case, the timeout for ffprobe in ms")
srsFFprobeDuration = flag.Int("srs-ffprobe-duration", 35000, "For each case, the duration for ffprobe in ms")
srsFFprobeTimeout = flag.Int("srs-ffprobe-timeout", 38000, "For each case, the timeout for ffprobe in ms")
srsFFprobe = flag.String("srs-ffprobe", "ffprobe", "The FFprobe tool")
srsInputFile = flag.String("srs-input-file", "source.200kbps.768x320.flv", "The input file")
noMediaTest = flag.Bool("no-media-test", false, "Whether disable the media test")
Expand Down
14 changes: 7 additions & 7 deletions test/scenario_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func TestScenario_WithStream_PublishVliveStreamUrl(t *testing.T) {
if ts := 90; m.Format.ProbeScore < ts {
r4 = errors.Errorf("low score=%v < %v, %v, %v", m.Format.ProbeScore, ts, m.String(), str)
}
if dv := m.Duration(); dv < duration/2 {
if dv := m.Duration(); dv < duration/3 {
r5 = errors.Errorf("short duration=%v < %v, %v, %v", dv, duration, m.String(), str)
}
}
Expand Down Expand Up @@ -412,7 +412,7 @@ func TestScenario_WithStream_PublishVLiveServerFile(t *testing.T) {
if ts := 90; m.Format.ProbeScore < ts {
r4 = errors.Errorf("low score=%v < %v, %v, %v", m.Format.ProbeScore, ts, m.String(), str)
}
if dv := m.Duration(); dv < duration/2 {
if dv := m.Duration(); dv < duration/3 {
r5 = errors.Errorf("short duration=%v < %v, %v, %v", dv, duration, m.String(), str)
}
}
Expand Down Expand Up @@ -1629,7 +1629,7 @@ func TestScenario_WithStream_PublishRtmpForwardPlatform(t *testing.T) {
if ts := 90; m.Format.ProbeScore < ts {
r4 = errors.Errorf("low score=%v < %v, %v, %v", m.Format.ProbeScore, ts, m.String(), str)
}
if dv := m.Duration(); dv < duration/2 {
if dv := m.Duration(); dv < duration/3 {
r5 = errors.Errorf("short duration=%v < %v, %v, %v", dv, duration, m.String(), str)
}
}
Expand Down Expand Up @@ -1790,7 +1790,7 @@ func TestScenario_WithStream_PublishRtmpTranscodeDefault(t *testing.T) {
if ts := 90; m.Format.ProbeScore < ts {
r4 = errors.Errorf("low score=%v < %v, %v, %v", m.Format.ProbeScore, ts, m.String(), str)
}
if dv := m.Duration(); dv < duration/2 {
if dv := m.Duration(); dv < duration/3 {
r5 = errors.Errorf("short duration=%v < %v, %v, %v", dv, duration, m.String(), str)
}

Expand Down Expand Up @@ -1930,7 +1930,7 @@ func TestScenario_WithStream_PublishRtmpTranscodeFollow(t *testing.T) {
if ts := 90; m.Format.ProbeScore < ts {
r4 = errors.Errorf("low score=%v < %v, %v, %v", m.Format.ProbeScore, ts, m.String(), str)
}
if dv := m.Duration(); dv < duration/2 {
if dv := m.Duration(); dv < duration/3 {
r5 = errors.Errorf("short duration=%v < %v, %v, %v", dv, duration, m.String(), str)
}

Expand Down Expand Up @@ -2070,7 +2070,7 @@ func TestScenario_WithStream_PublishRtmpTranscodeMono(t *testing.T) {
if ts := 90; m.Format.ProbeScore < ts {
r4 = errors.Errorf("low score=%v < %v, %v, %v", m.Format.ProbeScore, ts, m.String(), str)
}
if dv := m.Duration(); dv < duration/2 {
if dv := m.Duration(); dv < duration/3 {
r5 = errors.Errorf("short duration=%v < %v, %v, %v", dv, duration, m.String(), str)
}

Expand Down Expand Up @@ -2210,7 +2210,7 @@ func TestScenario_WithStream_PublishRtmpTranscodeStereo(t *testing.T) {
if ts := 90; m.Format.ProbeScore < ts {
r4 = errors.Errorf("low score=%v < %v, %v, %v", m.Format.ProbeScore, ts, m.String(), str)
}
if dv := m.Duration(); dv < duration/2 {
if dv := m.Duration(); dv < duration/3 {
r5 = errors.Errorf("short duration=%v < %v, %v, %v", dv, duration, m.String(), str)
}

Expand Down
6 changes: 3 additions & 3 deletions ui/src/components/VideoSourceSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export default function ChooseVideoSource({platform, endpoint, vLiveFiles, setVL
}, [vLiveFiles]);
return (<>
<Form.Group className="mb-3">
<Form.Label>{t('plat.tool.source')}</Form.Label>
<Form.Text> * {t('vle.source2')}</Form.Text>
<Form.Label>{endpoint === 'dubbing' ? t('plat.tool.source2') : t('plat.tool.source')}</Form.Label>
<Form.Text> * {endpoint === 'dubbing' ? t('dubb.create.source') : t('vle.source2')}</Form.Text>
<Form.Check type="radio" label={t('plat.tool.upload')} id={'upload-' + platform} checked={checkType === 'upload'}
name={'chooseSource-' + platform} onChange={e => setCheckType('upload')}
/>
Expand Down Expand Up @@ -164,7 +164,7 @@ function VLiveFileSelector({platform, endpoint, vLiveFiles, setVLiveFiles}) {
setVLiveFiles(res.data.data.files);
}).catch(handleError);
}).catch(handleError);
}, [t, inputFile, handleError, platform, setVLiveFiles]);
}, [t, inputFile, handleError, platform, setVLiveFiles, endpoint]);

return (<>
<Form.Control as="div">
Expand Down
7 changes: 5 additions & 2 deletions ui/src/pages/ScenarioDubbing.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function ScenarioDubbingList({setDubbingId}) {

const createDubbingProject = React.useCallback((e) => {
e.preventDefault();
if (!files || files.length === 0) return alert('Please upload a video file to dubbing.');

axios.post('/terraform/v1/dubbing/create', {
title: name, files,
Expand All @@ -51,7 +52,7 @@ function ScenarioDubbingList({setDubbingId}) {
setDubbingId(uuid);
console.log(`Status: Create ok, name=${name}, files=${files}, data=${JSON.stringify(res.data.data)}`);
}).catch(handleError);
}, [t, handleError, setDubbingId, searchParams, setSearchParams, name, files]);
}, [handleError, setDubbingId, searchParams, setSearchParams, name, files]);

const manageProject = React.useCallback((project) => {
const uuid = project.uuid;
Expand Down Expand Up @@ -569,6 +570,7 @@ function DubbingStudioEditor({project}) {

let timeout = 0.5;
do {
// eslint-disable-next-line no-loop-func
task = await new Promise(resolve => {
axios.post('/terraform/v1/dubbing/task-query', {
uuid: project.uuid, task: task.uuid,
Expand All @@ -588,6 +590,7 @@ function DubbingStudioEditor({project}) {
});

timeout = Math.min(3, timeout * 2);
// eslint-disable-next-line no-loop-func
await new Promise(resolve => setTimeout(resolve, timeout * 1000));
} while (task.status !== 'done');
} finally {
Expand Down Expand Up @@ -615,7 +618,7 @@ function DubbingStudioEditor({project}) {
} finally {
setRequesting(false);
}
}, [setRequesting, handleError, project, saveAs]);
}, [setRequesting, handleError, project]);

const formatDuration = React.useCallback((duration) => {
let hours = Math.floor(duration / 3600);
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/ScenarioVLive.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
//
import React from "react";
import {Accordion, Badge, Button, Col, Form, ListGroup, Row, Table} from "react-bootstrap";
import {Accordion, Badge, Button, Col, Form, Row, Table} from "react-bootstrap";
import {Token} from "../utils";
import axios from "axios";
import moment from "moment";
Expand Down
8 changes: 6 additions & 2 deletions ui/src/resources/locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@
"link2": "创建直播"
},
"tool": {
"source2": "视频源",
"source": "视频源",
"upload": "上传本地文件",
"upload2": "无上传文件",
Expand Down Expand Up @@ -611,7 +612,8 @@
"name2": "请输入翻译项目名称",
"projects": "翻译项目列表",
"delete": "删除后不可恢复,确认删除翻译项目吗?",
"empty": "暂无翻译项目"
"empty": "暂无翻译项目",
"source": "翻译的视频的源文件或地址"
},
"setting": {
"title": "视频翻译设置",
Expand Down Expand Up @@ -654,6 +656,7 @@
"title": "Dubbing Settings"
},
"create": {
"source": "Video source file or URL for dubbing",
"empty": "No dubbing project",
"delete": "Once deleted, it cannot be restored. Are you sure you want to delete the dubbing project?",
"projects": "Dubbing Projects",
Expand Down Expand Up @@ -699,7 +702,8 @@
"upload3": "Set file source ok",
"upload2": "No file selected",
"upload": "Upload local file",
"source": "Live Stream Source"
"source": "Live Stream Source",
"source2": "Video Source"
},
"ks": {
"link2": "Live Producer",
Expand Down

0 comments on commit 12060ae

Please sign in to comment.