I'm trying to accomplish a few things at the same time with the raspberry pi camera;

  • create an HLS live stream
  • take regular interval jpg snapshots and save them to disk
  • irregularly record short pieces of video to disk triggered by another process

Running the HLS stream on its self works well with raspivid, psips and ffmpeg like this:

raspivid -n -w 1280 -h 720 -fps 30 -t 86400000 -b 10000000 -o - | /root/psips | ffmpeg -loglevel 2 -y -analyzeduration 10M -i - -c:v copy -hls_time 5 -hls_list_size 10 -hls_wrap 20 /var/www/stream.m3u8

Since it's not possible to get access to the video device when it's already in use by raspivid, I create multiple virtual video devices for the desired scenario with v4l2loopback.

The first virtual device (/dev/video1) is created by running ffmpeg in the background like this:

ffmpeg -f video4linux2 -video_size 1280x720 -r 24 -input_format h264 -i /dev/video0 -vcodec rawvideo -f v4l2 /dev/video1

Then I try to start the HLS stream like this:

ffmpeg -i /dev/video1 -r 24 -f h264 - | /root/psips | ffmpeg -loglevel 2 -y -analyzeduration 10M -i - -c:v copy -hls_time 5 -hls_list_size 10 -hls_wrap 20 var/www/stream.m3u8

For some reason this results in ffmpeg producing quite a few 'Past duration 0.xxxxx too large" errors and psips exiting with a 'SPS/PPS overrun!' warning.

I'm not sure what's happening here or if there's something wrong with the approach I've chosen maybe?

1 Answer 1


I don't know how raspberry encodes video, but if you got encoded stream, you can:

  1. Setup local RTMP server
  2. Transcode it to HLS on the fly (this is cheap task, build-in in nginx rtmp server)
  3. When you need, you can get screenshots with ffmpeg
  4. When you need, you can record as many videos as you want with ffmpeg/rtmpdump
  5. Feed video/images everywhere else you want

Since here only one stream, here must be no problems with stream errors.

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.