Skip to content

Commit 0c6baed

Browse files
committed
Transcript: Support set the video codec parameters. v5.14.11
1 parent 62b2e5d commit 0c6baed

File tree

4 files changed

+36
-8
lines changed

4 files changed

+36
-8
lines changed

DEVELOPER.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,7 @@ The following are the update records for the SRS Stack server.
11511151
* Dubbing: Refine download button with comments. v5.14.8
11521152
* Room: AI-Talk support post processing. v5.14.9
11531153
* Website: Support setting title for popout. v5.14.10
1154+
* Transcript: Support set the video codec parameters. [v5.14.11](https://github.com/ossrs/srs-stack/releases/tag/v5.14.11)
11541155
* v5.13:
11551156
* Fix bug for vlive and transcript. v5.13.1
11561157
* Support AWS Lightsail install script. v5.13.2

platform/transcript.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,11 +1018,13 @@ type TranscriptConfig struct {
10181018
Language string `json:"lang"`
10191019
// The force_style for overlay subtitle.
10201020
ForceStyle string `json:"forceStyle"`
1021+
// The video codec parameters.
1022+
VideoCodecParams string `json:"videoCodecParams"`
10211023
}
10221024

10231025
func (v TranscriptConfig) String() string {
1024-
return fmt.Sprintf("all=%v, key=%vB, organization=%v, base=%v, lang=%v, forceStyle=%v",
1025-
v.All, len(v.SecretKey), v.Organization, v.BaseURL, v.Language, v.ForceStyle)
1026+
return fmt.Sprintf("all=%v, key=%vB, organization=%v, base=%v, lang=%v, forceStyle=%v, videoCodecParams=%v",
1027+
v.All, len(v.SecretKey), v.Organization, v.BaseURL, v.Language, v.ForceStyle, v.VideoCodecParams)
10261028
}
10271029

10281030
func (v *TranscriptConfig) Load(ctx context.Context) error {
@@ -1758,11 +1760,15 @@ func (v *TranscriptTask) DriveFixQueue(ctx context.Context) error {
17581760
}...)
17591761
}
17601762
}
1763+
// Generate the video parameters.
1764+
videoCodecParams := "-c:v libx264 -profile:v main -preset:v medium -tune zerolatency -bf 0"
1765+
if v.config.VideoCodecParams != "" {
1766+
videoCodecParams = v.config.VideoCodecParams
1767+
}
1768+
args = append(args, strings.Split(videoCodecParams, " ")...)
1769+
// Generate other parameters for FFmpeg.
17611770
args = append(args, []string{
1762-
"-vcodec", "libx264", "-profile:v", "main", "-preset:v", "medium",
1763-
"-tune", "zerolatency", // Low latency mode.
1764-
"-bf", "0", // Disable B frame for WebRTC.
1765-
"-acodec", "aac",
1771+
"-c:a", "aac",
17661772
"-copyts", // To keep the pts not changed.
17671773
"-y", overlayFile.File,
17681774
}...)

ui/src/pages/ScenarioTranscript.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ function ScenarioTranscriptImpl({activeKey, defaultEnabled, defaultConf, default
5353
const [baseURL, setBaseURL] = React.useState(defaultConf.baseURL || (language === 'zh' ? '' : 'https://api.openai.com/v1'));
5454
const [targetLanguage, setTargetLanguage] = React.useState(defaultConf.lang || language);
5555
const [forceStyle, setForceStyle] = React.useState(defaultConf.forceStyle || 'Alignment=2,MarginV=20');
56+
const [videoCodecParams, setVideoCodecParams] = React.useState(defaultConf.videoCodecParams || '-c:v libx264 -profile:v main -preset:v medium -tune zerolatency -bf 0');
5657

5758
const [liveQueue, setLiveQueue] = React.useState();
5859
const [asrQueue, setAsrQueue] = React.useState();
@@ -89,15 +90,15 @@ function ScenarioTranscriptImpl({activeKey, defaultEnabled, defaultConf, default
8990
if (!baseURL) return alert(`Invalid base url ${baseURL}`);
9091

9192
axios.post('/terraform/v1/ai/transcript/apply', {
92-
uuid, all: !!enabled, secretKey, organization, baseURL, lang: targetLanguage, forceStyle,
93+
uuid, all: !!enabled, secretKey, organization, baseURL, lang: targetLanguage, forceStyle, videoCodecParams,
9394
}, {
9495
headers: Token.loadBearerHeader(),
9596
}).then(res => {
9697
alert(t('helper.setOk'));
9798
console.log(`Transcript: Apply config ok, uuid=${uuid}.`);
9899
success && success();
99100
}).catch(handleError);
100-
}, [t, handleError, secretKey, baseURL, targetLanguage, forceStyle, uuid, organization]);
101+
}, [t, handleError, secretKey, baseURL, targetLanguage, forceStyle, videoCodecParams, uuid, organization]);
101102

102103
const resetTask = React.useCallback(() => {
103104
setOperating(true);
@@ -307,6 +308,9 @@ function ScenarioTranscriptImpl({activeKey, defaultEnabled, defaultConf, default
307308
<Nav.Item>
308309
<Nav.Link href="#overlay" onClick={(e) => changeConfigItem(e, 'overlay')}>{t('transcript.overlay2')}</Nav.Link>
309310
</Nav.Item>
311+
<Nav.Item>
312+
<Nav.Link href="#transcode" onClick={(e) => changeConfigItem(e, 'transcode')}>{t('transcript.transcode')}</Nav.Link>
313+
</Nav.Item>
310314
</Nav>
311315
</Card.Header>
312316
{configItem === 'provider' && <Card.Body>
@@ -334,6 +338,15 @@ function ScenarioTranscriptImpl({activeKey, defaultEnabled, defaultConf, default
334338
<Form.Control as="input" defaultValue={forceStyle} onChange={(e) => setForceStyle(e.target.value)} />
335339
</Form.Group>
336340
</Card.Body>}
341+
{configItem === 'transcode' && <Card.Body>
342+
<Form.Group className="mb-3">
343+
<Form.Label>{t('transcript.trans0')}</Form.Label>
344+
<Form.Text> * {t('transcript.trans1')}. &nbsp;
345+
{t('helper.see')} <a href={t('transcript.trans2')} target='_blank' rel='noreferrer'>FFmpeg: video codec</a>.
346+
</Form.Text>
347+
<Form.Control as="input" defaultValue={videoCodecParams} onChange={(e) => setVideoCodecParams(e.target.value)} />
348+
</Form.Group>
349+
</Card.Body>}
337350
</Card>
338351
<p></p>
339352
<Button ariant="primary" type="submit" onClick={(e) => {

ui/src/resources/locale.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,10 @@
379379
"res": "最后收到的响应"
380380
},
381381
"transcript": {
382+
"trans2": "https://ossrs.net/lts/zh-cn/faq-srs-stack#how-to-setup-the-video-codec-parameters-for-ai-transcript",
383+
"trans1": "自定义视频转码参数",
384+
"trans0": "视频转码参数",
385+
"transcode": "转码设置",
382386
"fstyle3": "https://ossrs.net/lts/zh-cn/faq-srs-stack#how-to-setup-the-font-style-for-ai-transcript",
383387
"fstyle2": "设置字幕的样式",
384388
"fstyle": "字幕样式",
@@ -870,6 +874,10 @@
870874
"setupOk": "Set record rule ok"
871875
},
872876
"transcript": {
877+
"trans2": "https://ossrs.io/lts/en-us/faq-srs-stack#how-to-setup-the-video-codec-parameters-for-ai-transcript",
878+
"trans1": "Customize video transcode parameters",
879+
"trans0": "Video Transcode Parameters",
880+
"transcode": "Transcode Settings",
873881
"fstyle3": "https://ossrs.io/lts/en-us/faq-srs-stack#how-to-setup-the-font-style-for-ai-transcript",
874882
"fstyle2": "Force the style of the subtitle",
875883
"fstyle": "Force Style",

0 commit comments

Comments
 (0)