Subject: Streaming data of unknown length

From: Jonathan Hemingway <[email-masked]>
Date: Tue, 08 Nov 2022 23:03:34 +0000

Hello,

I have an interesting use-case for NNCP and I'm wondering how best to go about it.

Imagine I have a security camera with a fallback battery power supply. Normally the
camera stream is recorded to local storage and discarded after some arbitrary period.

In the event that main power is cut or some other emergency conditions are met the
video stream should immediately feed to some remote storage as well. The remote
storage channel would be NNCP so that the video stream can be transmitted to a
dependable relay and decrypted later.

This situation is different from how NNCP normally works because it must be assumed
that the sender may be taken permantly offline at any momement during transmission.
In this case, what is the best way to use NNCP? A file-transfer with chunking?

Here is an example script to show what I mean:
---------------------------------------------
#!/bin/sh
NODE="${1}"
FILE="$(mktemp --dry-run XXXX.ismv)"

# encode from webcam into nncp-file
ffmpeg -nostats \
                -f alsa -i default -f v4l2 -i /dev/video0 \
                -b:a 48K -b:v 128K \
                -timestamp now \
                -f ismv pipe: \
        | nncp-file -chunked 128 -quiet -nice F - "${NODE}:${FILE}" \
        &

while true; do
        sleep 2s
        nncp-call -onlinedeadline 60 -tx "${NODE}"
done
---------------------------------------------

I'm using chunking here because I think it is the easiest way to reconcstruct
an interrupted stream, but I'm not sure if that is how it works.

Cheers,
Emery