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?

| improve this question | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.