Skip to content

Commit

Permalink
Change default values for smooth playback (#778)
Browse files Browse the repository at this point in the history
* #768 change default values for smooth playback

DECODER_QUEUE_LENGTH=5 in module
SYNC_INPUT=True in AO-sink

* #768 set default SYNC_OFFSET_MS to 1000
  • Loading branch information
tomskikh authored Jun 11, 2024
1 parent 8c9b82a commit ee6aa7a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 18 deletions.
4 changes: 2 additions & 2 deletions adapters/ds/sinks/always_on_rtsp/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ def __init__(self):
self.framerate = opt_config('FRAMERATE', '30/1')
self.idr_period_frames = opt_config('IDR_PERIOD_FRAMES', IDR_PERIOD_FRAMES, int)

self.sync = opt_config('SYNC_INPUT', False, strtobool)
self.sync = opt_config('SYNC_INPUT', True, strtobool)
self.realtime = opt_config('REALTIME', False, strtobool)
self.sync_offset_ms = opt_config('SYNC_OFFSET_MS', 0, int)
self.sync_offset_ms = opt_config('SYNC_OFFSET_MS', 1000, int)
assert self.sync_offset_ms >= 0, 'SYNC_OFFSET_MS should be non-negative.'
self.sync_queue_size = opt_config('SYNC_QUEUE_SIZE', 500, int)
assert self.sync_queue_size > 0, 'SYNC_QUEUE_SIZE should be positive.'
Expand Down
10 changes: 5 additions & 5 deletions docs/source/savant_101/10_adapters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1124,16 +1124,16 @@ The simplified design of the adapter is depicted in the following diagram:
- ``logger``
* - ``SYNC_INPUT``
- A flag indicating whether to show frames on sink synchronously (i.e. at the source rate).
- ``False``
- ``True``
- ``False``
* - ``REALTIME``
- A flag indicating whether to synchronise frames at realtime (i.e. using avsolute timestamps); ignored when ``SYNC_INPUT=False``.
- A flag indicating whether to synchronise frames at realtime (i.e. using absolute timestamps); ignored when ``SYNC_INPUT=False``.
- ``False``
- ``True``
* - ``SYNC_OFFSET_MS``
- An offset in milliseconds to adjust the synchronisation. Tune this parameter to play video more smoothly. When ``REALTIME=False``, the offset is applied to the timestamp of the first frame; when ``REALTIME=True``, the offset is applied to the current time. Ignored when ``SYNC_INPUT=False``.
- ``0``
- ``10``
- ``1000``
- ``5000``
* - ``SYNC_QUEUE_SIZE``
- A size of queue for frames to be synchronised; ignored when ``SYNC_INPUT=False``. Tune this parameter according to the stream framerate and ``SYNC_OFFSET_MS``.
- ``500``
Expand Down Expand Up @@ -1177,7 +1177,7 @@ Running the adapter with Docker:
docker run --rm -it --name sink-always-on-rtsp \
--gpus=all \
--entrypoint python \
-e SYNC_INPUT=False \
-e SYNC_INPUT=True \
-e ZMQ_ENDPOINT=sub+connect:ipc:///tmp/zmq-sockets/output-video.ipc \
-e SOURCE_ID=test \
-e STUB_FILE_LOCATION=/path/to/stub_file/test.jpg \
Expand Down
2 changes: 1 addition & 1 deletion gst_plugins/python/savant_rs_video_decode_bin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
OUT_CAPS = Gst.Caps.from_string('video/x-raw(memory:NVMM);video/x-raw')
DEFAULT_PASS_EOS = True
# Default values of "queue" element
DEFAULT_DECODER_QUEUE_LENGTH = 200
DEFAULT_DECODER_QUEUE_LENGTH = 5
DEFAULT_DECODER_QUEUE_SIZE = 10485760

NESTED_DEMUX_PROPERTIES = {
Expand Down
1 change: 0 additions & 1 deletion samples/peoplenet_detector/docker-compose.x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ services:
- ZMQ_SRC_ENDPOINT=sub+bind:ipc:///tmp/zmq-sockets/input-video.ipc
- ZMQ_SINK_ENDPOINT=pub+bind:ipc:///tmp/zmq-sockets/output-video.ipc
- METRICS_FRAME_PERIOD=1000
- DECODER_QUEUE_LENGTH=5
deploy:
resources:
reservations:
Expand Down
2 changes: 1 addition & 1 deletion savant/config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ pipeline:
ingress_queue_length: ${oc.decode:${oc.env:INGRESS_QUEUE_LENGTH, null}}
# Size of the ingress queue in bytes (0 - no limit, default 10485760).
ingress_queue_byte_size: ${oc.decode:${oc.env:INGRESS_QUEUE_BYTE_SIZE, null}}
# Length of the queue before decoder in frames (0 - no limit, default 200).
# Length of the queue before decoder in frames (0 - no limit, default 5).
decoder_queue_length: ${oc.decode:${oc.env:DECODER_QUEUE_LENGTH, null}}
# Size of the queue before decoder in bytes (0 - no limit, default 10485760).
decoder_queue_byte_size: ${oc.decode:${oc.env:DECODER_QUEUE_BYTE_SIZE, null}}
Expand Down
16 changes: 8 additions & 8 deletions scripts/run_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,13 @@ def video_files_sink(
help='Where to dump metadata (stdout or logger).',
)
@click.option(
'--sync',
'--no-sync',
is_flag=True,
default=False,
help='Show frames on sink synchronously (i.e. at the source file rate).',
help=(
'Disable showing frames on sink synchronously (i.e. at the source file rate). '
'Set this flag to show frames as soon as possible.'
),
)
@click.option(
'--realtime',
Expand All @@ -414,7 +417,7 @@ def video_files_sink(
@click.option(
'--sync-offset-ms',
type=click.INT,
default=0,
default=1000,
help=(
'Offset in milliseconds to adjust the synchronisation. '
'Tune this parameter to play video more smoothly.'
Expand Down Expand Up @@ -504,7 +507,7 @@ def always_on_rtsp_sink(
fps_period_frames: Optional[int],
fps_period_seconds: Optional[float],
metadata_output: Optional[str],
sync: bool,
no_sync: bool,
realtime: bool,
sync_offset_ms: int,
sync_queue_size: int,
Expand Down Expand Up @@ -534,9 +537,6 @@ def always_on_rtsp_sink(
Stream control API is available at http://<container-host>:<api-port>.
See http://<container-host>:<api-port>/docs for API documentation.
Note: it is advisable to use --sync flag on source adapter or use a live
source adapter (e.g. rtsp or usb-cam).
"""

assert (
Expand Down Expand Up @@ -594,7 +594,7 @@ def always_on_rtsp_sink(
cmd = build_docker_run_command(
f'sink-always-on-rtsp-{uuid.uuid4().hex}',
zmq_endpoints=[in_endpoint],
sync_input=sync,
sync_input=not no_sync,
entrypoint='python',
args=['-m', 'adapters.ds.sinks.always_on_rtsp'],
envs=envs,
Expand Down

0 comments on commit ee6aa7a

Please sign in to comment.