I need to record video from the pi's inbuilt camera at the same time as streaming it.

One way to do this (using "tee") is described here record and stream video from camera simultaneously. It works for me, but the latency when viewing the stream is poor (5 seconds +).

I've also experimented with the user space driver uv4l, which provides good low latency video streaming from my raspberry pi (<1 s delay). http://www.linux-projects.org/modules/news/article.php?storyid=190. However that driver doesn't seem to lend itself to the "tee" approach.

Is there a way I can use the uv4l driver to both record to a file and stream simultaneously?

  • 1
    I don't see why something like 'dd if=/dev/video0' piped to 'tee' would not work, if it worked for you with raspivid. the principle is the same.
    – prinxis
    Commented Mar 7, 2016 at 23:06
  • Could you give a command line to achieve that?
    – abraae
    Commented Mar 8, 2016 at 7:56

1 Answer 1


In case it helps anyone, I never managed to get this working using uv4l. Shame, as uv4l was the only approach I tried that could stream from the pi in near real-time to a browser.

I did find an alternate solution based on http://pi.gbaman.info/?p=150 that worked for me, but viewing the stream requires gstreamer instead of a browser on the viewing machine. That's OK for my needs.

On the pi I used rapivid, and teed the output to both gstreamer and a local file:

raspivid -vf -t 0 -w 640 -h 480 -fps 25 -hf -b 2000000 -o - | tee test_video.h264 | gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! gdppay ! tcpserversink host= port=5000

I viewed the stream on my laptop, and found the stream to be good quality and low lag (maybe < .3s latency, not measured).

gst-launch-1.0 -v tcpclientsrc host= port=5000  ! gdpdepay !  rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=false

I also used iptraf to check the network traffic out of the pi, it seems to hover around 900kbps - 1Mbps. Bumping the resolution increases this as you would expect. top shows very low cpu usage.

Then to check the quality of the recorded file I made an mp4 file.

MP4Box -add test_video.h264 -fps 25 test_video.mp4

I opened the file in chrome - the quality seems just as good as the stream.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.