ds72
Posts: 2
Joined: Fri Sep 14, 2018 10:27 pm

Frames dropped the longer the recording with raspivid

Fri Sep 14, 2018 10:37 pm

I'm using the v2 camera module with Raspberry Pi 3 Model B+ and am using raspivid to capture to some high fps, quick shutter speed video.

For some reason, there seems to be a lot of frames lost as I try to record longer videos:

120 fps, 640x480, sensor mode 7, shutter speed 1000 microsec
for a 20 sec video: no frames lost
30 sec video: 7% frames lost (210)
40 sec video: 38% frames lost (1180)
50 sec video: 38% frmaes lost (1580)

I have tried changing the dirty ratios according to the last post here: https://www.raspberrypi.org/forums/view ... 36#p720536
but I still get lost frames

same parameters as above:
20 second video: no frames lost
30 second video: 31% (681)
40 second video: camera preview freezes...

I have a vague understanding of the camera to GPU pipeline but not sure what else I can try to find the root cause of the issue. Does anyone have any idea what might be causing all these frames to be lost? Is there a way i can output what's being held in some of the buffers? Here's an example of a command I'm using

Code: Select all

raspivid -md 7 -w 640 -h 480 -fps 120 -t 40000 --verbose -pts time.1000ss_120fps_40s.pts -ss 1000 --output 640x480-120fps-1000ss_40s.h264 -a 512
More frames seem to be lost later in the video vs. earlier and it gets worse with higher fps as well. Ideally I would like to use 200 fps but could use the 120 fps if the higher fps causes some instability issues. Any help appreciated. Thanks.

ethanol100
Posts: 538
Joined: Wed Oct 02, 2013 12:28 pm

Re: Frames dropped the longer the recording with raspivid

Tue Sep 18, 2018 2:23 pm

Where do you try to save the video?
You can try to save the video to /dev/shm, which is a tmpfs file-system, which lives in the RAM (you need to copy everything afterwards to a save location, as the data there does not survive a reboot). Or you can even try to save the video to "/dev/null", which basically destroys it immediately. This will rule out issues with saving the video.

You could try to backup your system and then run "rpi-update" to test the latest firmware.

For me I got not lost frames for 180fps(on pi0 and pi3), if I use the latest firmware, and fix the analog and digital gain as well as the white balance.

Code: Select all

raspivid -md 7 -w 640 -h 480 -fps 180 -t 40000 -v -pts time.1000ss_120fps_40s.pts -ss 1000 -ag 1.0 -dg 1.0 -awb off -awbg 1,1 -o 640x480-120fps-1000ss_40s.h264 -a 512
I did see your behaviour with the original firmware. There I got around 2 second without dropped frames, and then each other frame was lost. The camera often hangs and a reboot was needed to get it going again.

ds72
Posts: 2
Joined: Fri Sep 14, 2018 10:27 pm

Re: Frames dropped the longer the recording with raspivid

Wed Sep 19, 2018 11:25 pm

ethanol100 wrote:
Tue Sep 18, 2018 2:23 pm
Where do you try to save the video?
You can try to save the video to /dev/shm, which is a tmpfs file-system, which lives in the RAM (you need to copy everything afterwards to a save location, as the data there does not survive a reboot). Or you can even try to save the video to "/dev/null", which basically destroys it immediately. This will rule out issues with saving the video.

You could try to backup your system and then run "rpi-update" to test the latest firmware.

For me I got not lost frames for 180fps(on pi0 and pi3), if I use the latest firmware, and fix the analog and digital gain as well as the white balance.

Code: Select all

raspivid -md 7 -w 640 -h 480 -fps 180 -t 40000 -v -pts time.1000ss_120fps_40s.pts -ss 1000 -ag 1.0 -dg 1.0 -awb off -awbg 1,1 -o 640x480-120fps-1000ss_40s.h264 -a 512
I did see your behaviour with the original firmware. There I got around 2 second without dropped frames, and then each other frame was lost. The camera often hangs and a reboot was needed to get it going again.

Thanks for the reply.
I tried saving the video and pts file to /dev/shm and it seemed to be getting better. However, I've been using this script to analyze frame drops: https://github.com/Hermann-SW/userland/ ... ptsanalyze
and it looks like it was giving me artifically high frame drop percentages...I actually looked at the .pts file and it looked like there was actually less than 300 ms of data missing (for a 90second video). So maybe somewhere at some point, something I did helped fix it.

Initially when I had the major frame dropping issues (with more frames being dropped later in the video), I thought I did run an rpi-update...but I just ran rpi-update again, rebooted and tried recording 200 fps video 90 seconds long to /home/pi and again, there seemed to be >1% frame loss. I recorded another video 120 seconds long and still pretty good performance as well.

Whatever happened, looks like I'm ok for now!

HermannSW
Posts: 764
Joined: Fri Jul 22, 2016 9:09 pm

Re: Frames dropped the longer the recording with raspivid

Thu Sep 20, 2018 10:22 am

> and tried recording 200 fps video
>
Please note that the Raspberry Pi GPU has a bug not allowing 202fps or higher.
And @6by9 always states that 120fps is save to use for 640x480.
I have seen problems with 200fps as you, but 180fps is fine for me.
It seems that 200fps being so near to the 202fps GPU issue mark might be the cause.
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/fork-raspiraw      https://github.com/Hermann-SW/userland
https://github.com/Hermann-SW/wireless-control-Eachine-E52-drone      https://twitter.com/HermannSW

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5664
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Frames dropped the longer the recording with raspivid

Thu Sep 20, 2018 11:09 am

HermannSW wrote:
Thu Sep 20, 2018 10:22 am
> and tried recording 200 fps video
>
Please note that the Raspberry Pi GPU has a bug not allowing 202fps or higher.
And @6by9 always states that 120fps is save to use for 640x480.
I have seen problems with 200fps as you, but 180fps is fine for me.
It seems that 200fps being so near to the 202fps GPU issue mark might be the cause.
The 202fps limit is going to be a calculation overflowing somewhere. It's just not something I have the energy to debug. Maybe one day if I have a spare half hour with the debugger I'll investigate. It'll almost certainly be linked to just the one mode on one sensor.

The issue with 200fps is that the various control loops take time to run. The cycle of processing the frame, analysing any stats, and then altering any settings has to complete in less than the frame time. If not then a frame will get dropped.
Above 60fps the firmware already reduces the tuner processing rate by a factor of 3 (that probably ought to be dynamic rather than a fixed factor, and that might get 200fps working again).

You're also almost at the nominal limit of the codec with VGA200 (61.4MPix/s), so there start to be other factors coming into play as well.

Sorry, but running at very high FPS is a pretty niche use case (albeit a fun one). Time has to be allocated to the more common use cases before the niche ones.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “Camera board”

Who is online

Users browsing this forum: No registered users and 12 guests