The tee
command reads from standard input and copies to any number of files plus standard output by default, see man tee
for more details. This means you can ask tee to create a file from input and then pipe the output to something else.
The addition of an extra pipe does in theory add a bit of inefficiency. As to whether this is significant or not you will have to judge for yourself using your own streaming method. My current method is not satisfactory at full resolution. It's not a huge interest right now but when it is I will try to find something better (e.g. supposedly gstreamer works better than clvc).
However, worth noting that the file saved locally on the pi at the same time is perfect quality, so the activity does not interfere with raspivid. Here's an example:
raspivid -o - -t 0 | tee test_video.h264 |
cvlc -v stream:///dev/stdin --sout '#standard{access=http,mux=ts,dest=:8080' :demux=h264
I broke this into two lines for readability; you can hit return after |
(pipe) and finish the command just as you can break a line with \
. You can replace the cvlc
with whatever you want. Again, although the stream was of poor quality, test_video.h264
came out perfect.
If I lower the resolution to 640x360 this arrangement is fine, with a second or two of latency which is what I normally get. I do not think the tee
or the second pipe makes any difference to the quality of the stream; these are capable of much higher throughput than necessary here and do not require much in the way of system resources.
The CPU ran at 35-45%, which is the same as it does when streaming video sans tee
.
raspivid
you couldtee
the output to a file and gstreamer or whatever else (seeman tee
). As long as one stream is straight to disk, it won't add much overhead, but if you want to process the input into two different formats simultaneously I think that will be too much work for the pi to handle.