Skip to content

Commit 1b2bc7b

Browse files
committed
refactor: rename target_latency to target_latency_secs
BREAKING CHANGES: renamed target_latency to target_latency_secs in configuration file
1 parent 837174c commit 1b2bc7b

File tree

7 files changed

+28
-28
lines changed

7 files changed

+28
-28
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ A complete description of the JSON schema can be found in `src/server/ConfigPars
8282
- type: `string`
8383
- required: `true`
8484

85-
**`.sources[].target_latency`**
85+
**`.sources[].target_latency_secs`**
8686
- description: Total end to end latency that the browser tries to maintain. If set too low the browser buffers often. Can be changed temporarily in the fronted.
8787
- type: `number`
8888
- required: `false`

config.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,56 +3,56 @@
33
"sources": [
44
{
55
"id": "traffic",
6-
"target_latency": 10,
6+
"target_latency_secs": 10,
77
"rtsp": {
88
"url": "rtsp://211.132.61.124:554/axis-media/media.amp?videocodec=h264&resolution=1280x720&videoformat-hdtv"
99
}
1010
},
1111
{
1212
"id": "norway",
13-
"target_latency": 10,
13+
"target_latency_secs": 10,
1414
"rtsp": {
1515
"url": "rtsp://77.110.246.1:554/axis-media/media.amp?videocodec=h264&resolution=1280x720&videoformat-hdtv"
1616
}
1717
},
1818
{
1919
"id": "tree",
20-
"target_latency": 10,
20+
"target_latency_secs": 10,
2121
"rtsp": {
2222
"url": "rtsp://50.194.64.66:554/axis-media/media.amp?videocodec=h264&resolution=1280x720&videoformat-hdtv"
2323
}
2424
},
2525
{
2626
"id": "norway2",
27-
"target_latency": 10,
27+
"target_latency_secs": 10,
2828
"rtsp": {
2929
"url": "rtsp://79.161.235.219:554/axis-media/media.amp?videocodec=h264&camera=1&resolution=1920x1080&videoformat-hdtv"
3030
}
3131
},
3232
{
3333
"id": "us-traffic",
34-
"target_latency": 10,
34+
"target_latency_secs": 10,
3535
"rtsp": {
3636
"url": "rtsp://96.91.10.218:554/axis-media/media.amp?videocodec=h264&camera=1&resolution=1920x1080&videoformat-hdtv"
3737
}
3838
},
3939
{
4040
"id": "us-traffic2",
41-
"target_latency": 10,
41+
"target_latency_secs": 10,
4242
"rtsp": {
4343
"url": "rtsp://96.91.10.219:554/axis-media/media.amp?videocodec=h264&camera=1&resolution=1920x1080&videoformat-hdtv"
4444
}
4545
},
4646
{
4747
"id": "test",
48-
"target_latency": 10,
48+
"target_latency_secs": 10,
4949
"rtsp": {
5050
"url": "rtsp://demo:[email protected]:5541/onvif-media/media.amp?profile=profile_1_h264&sessiontimeout=60&streamtype=unicast"
5151
}
5252
},
5353
{
5454
"id": "church",
55-
"target_latency": 20,
55+
"target_latency_secs": 20,
5656
"rtsp": {
5757
"url": "rtsp://217.41.42.231:8554/axis-media/media.amp?videocodec=h264&resolution=1280x720&videoformat-hdtv"
5858
}

ffmpeg-wrapper.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ set -eo pipefail
33

44
FFMPEG="ffmpeg"
55
MKDIR=0
6-
TARGET_LATENCY=4
6+
TARGET_LATENCY_SECS=4
77
CLEAN_ON_EXIT=0
88

99
function print_usage() {
10-
echo "usage: ffmpeg-wrapper.sh [--use-docker] [--mkdir] [--target-latency seconds] [--clean-on-exit] RTSP_URL OUTPUT_PATH"
10+
echo "usage: ffmpeg-wrapper.sh [--use-docker] [--mkdir] [--target-latency-secs seconds] [--clean-on-exit] RTSP_URL OUTPUT_PATH"
1111
}
1212

13-
TEMP=$(getopt -o '' --long 'use-docker,mkdir,target-latency:,clean-on-exit' -n 'ffmpeg-wrapper.sh' -- "$@")
13+
TEMP=$(getopt -o '' --long 'use-docker,mkdir,target-latency-secs:,clean-on-exit' -n 'ffmpeg-wrapper.sh' -- "$@")
1414
if [[ $? -ne 0 ]] ; then
1515
echo "failed to parse command line arguments" >&2
1616
exit 1
@@ -30,11 +30,11 @@ while true; do
3030
shift
3131
continue
3232
;;
33-
'--target-latency')
34-
TARGET_LATENCY="$2"
33+
'--target-latency-secs')
34+
TARGET_LATENCY_SECS="$2"
3535
shift 2
3636

37-
if [[ "$TARGET_LATENCY" -lt 3 || "$TARGET_LATENCY" -gt 3600 ]] ; then
37+
if [[ "$TARGET_LATENCY_SECS" -lt 3 || "$TARGET_LATENCY_SECS" -gt 3600 ]] ; then
3838
echo 'target latency should be in the range [3,3600]' >&2
3939
exit 1
4040
fi
@@ -133,7 +133,7 @@ function stream() {
133133
-window_size 60 \
134134
-frag_type none \
135135
-tune zerolatency \
136-
-target_latency "${TARGET_LATENCY}" \
136+
-target_latency "${TARGET_LATENCY_SECS}" \
137137
-format_options "movflags=cmaf" \
138138
-export_side_data prft -write_prft 1 \
139139
"${OUTPUT_PATH}/manifest.mpd" &

src/server/ConfigParser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export interface IRtspSource {
1818

1919
export interface IStreamSource {
2020
id: string;
21-
target_latency?: number;
21+
target_latency_secs?: number;
2222
onvif?: IOnvifSource;
2323
rtsp?: IRtspSource;
2424
}
@@ -90,7 +90,7 @@ const StreamSourceSchema: JSONSchemaType<IStreamSource> = {
9090
type: "object",
9191
$ref: "./RtspSource.json",
9292
},
93-
target_latency: {
93+
target_latency_secs: {
9494
type: "number",
9595
nullable: true,
9696
},

src/server/FfmpegStreamer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ export class FfmpegStreamer {
3434

3535
const args = ["--mkdir", "--clean-on-exit"];
3636

37-
if (this._camera.config.target_latency) {
37+
if (this._camera.config.target_latency_secs) {
3838
args.push("--target-latency");
39-
args.push(`${this._camera.config.target_latency}`);
39+
args.push(`${this._camera.config.target_latency_secs}`);
4040
}
4141

4242
const streamUrl = this._camera.streamUrl;

src/server/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function getStateForClient(streamers: FfmpegStreamer[]): IStateForClient {
107107
const sources = () =>
108108
streamers.map((s) => ({
109109
id: s.camera.id,
110-
latency: s.camera.config.target_latency,
110+
latency: s.camera.config.target_latency_secs,
111111
}));
112112

113113
app.get("/", (req, res) => {
@@ -146,22 +146,22 @@ function getStateForClient(streamers: FfmpegStreamer[]): IStateForClient {
146146
const stateJson: string = JSON.stringify(state);
147147
socket.send(Buffer.from(stateJson, "utf8"));
148148
break;
149-
case "target_latency": {
149+
case "target_latency_secs": {
150150
const streamer: FfmpegStreamer | undefined = streamers.find(
151151
(s) => s.camera.id === msg.stream_id
152152
);
153153
if (streamer) {
154-
streamer.camera.config.target_latency = msg.value;
154+
streamer.camera.config.target_latency_secs = msg.value;
155155
console.log(
156-
`set ${streamer.camera.id} latency = ${streamer.camera.config.target_latency}`
156+
`set ${streamer.camera.id} latency = ${streamer.camera.config.target_latency_secs}`
157157
);
158158

159159
wss.clients.forEach((client) => {
160160
if (client === socket) return;
161161
const msg = {
162-
type: "target_latency",
162+
type: "target_latency_secs",
163163
id: streamer.camera.id,
164-
value: streamer.camera.config.target_latency,
164+
value: streamer.camera.config.target_latency_secs,
165165
};
166166
client.send(Buffer.from(JSON.stringify(msg), "utf8"));
167167
});

src/server/static/StreamSource.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export class StreamSource {
147147
this.appendLog(eventObject.entry.content);
148148
return;
149149
}
150-
if (eventObject.type === "target_latency") {
150+
if (eventObject.type === "target_latency_secs") {
151151
this.onTargetLatencyUpdate(eventObject.value);
152152
}
153153
}
@@ -170,7 +170,7 @@ export class StreamSource {
170170
// only local target latency change for now
171171
// this.socket.send(
172172
// JSON.stringify({
173-
// type: "target_latency",
173+
// type: "target_latency_secs",
174174
// stream_id: this.streamId,
175175
// value: newLatency,
176176
// })

0 commit comments

Comments
 (0)