User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: dropped frames

Mon Aug 12, 2013 8:42 pm

jamesh wrote:To all those seeing drops, if you pipe to NULL does the preview glitch go away? Can you reduce bitrate to see if it helps? That would have a better effect than dropping the framerate if the media is too slow.
Won't have access to an HDMI monitor for another 2 weeks James.

IIRC, I settled on "-fps 25 -b 15000000" for the RasPiCamcorder and it seems to give reasonably stable results at 1080p
Alex Eames RasPi.TV, RasP.iO

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23944
Joined: Sat Jul 30, 2011 7:41 pm

Re: dropped frames

Mon Aug 12, 2013 9:20 pm

alexeames wrote:
jamesh wrote:To all those seeing drops, if you pipe to NULL does the preview glitch go away? Can you reduce bitrate to see if it helps? That would have a better effect than dropping the framerate if the media is too slow.
Won't have access to an HDMI monitor for another 2 weeks James.

IIRC, I settled on "-fps 25 -b 15000000" for the RasPiCamcorder and it seems to give reasonably stable results at 1080p
Almost certainly a media speed problem then.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: dropped frames

Tue Aug 13, 2013 7:12 am

jamesh wrote:
alexeames wrote:
jamesh wrote:To all those seeing drops, if you pipe to NULL does the preview glitch go away? Can you reduce bitrate to see if it helps? That would have a better effect than dropping the framerate if the media is too slow.
Won't have access to an HDMI monitor for another 2 weeks James.

IIRC, I settled on "-fps 25 -b 15000000" for the RasPiCamcorder and it seems to give reasonably stable results at 1080p
Almost certainly a media speed problem then.
I wonder what the ultimate card for use as a video camera is? I remember I dropped my RasPiCamcorder and broke the card slot, then put in a microSD adaptor. I don't think I've had any dropped frame issues since then but I couldn't be sure without a retest on max settings with an HDMI screen. (7dayshop 16 Gig micro SD card).

Perhaps the people who experience dropped frames could chip in with what SD cards they're using?
Alex Eames RasPi.TV, RasP.iO

Aikidokajeff
Posts: 68
Joined: Fri May 25, 2012 3:31 pm

Re: dropped frames

Tue Aug 13, 2013 8:12 am

Patriot LX Series 16GB SDHC Class 10 Sd card: PSF16GSDHC10-pc
I've seen some good and some bad reviews - most of the bad center around being bad for small writes.

ripping
Posts: 32
Joined: Wed Mar 14, 2012 10:55 am
Location: New Zealand

Re: dropped frames

Wed Aug 14, 2013 8:48 am

A brief update on my progression with understanding the issue I have with dropped frames as described in the OP.
I have since put a fresh version of the latest Raspbian wheezy image on a faster Class 8 SD card (as opposed to Class 4) that I had in the drawer. Along with that I am using my fastest available USB drive to run the filesystem from once booted up.
I initially ran everything from the SD card alone and did a couple of tests with raspivid using the same parameters that I have used in previous tests.
The rate of dropped frames in the test videos was appreciably reduced... Only 2 glitches in a 2 minute recording.. both of them minor, one virtually unnoticable, the other a little worse, but still less frames dropped than any glitch with my original SD card and setup.
After this, I transferred the file system to the 'new' USB thumb drive to use that as the duty drive.
And again, very similar results from examining fresh footage from the camera. Less glitches with less missing frames.
So I think its fair to say that my issues were solely to do with media with write speeds that are just not adequate for this type of application.
Its possible that the new Raspbian installation has also helped, but as I was running a very recent and clean Raspbian OS image previously, I doubt that this had much impact.
Still, the performance, although improved, is not error free, so I have a Transcend Class 10 SD (seemingly Rpi compatible), and a PQI USB 3 drive in the mail, so I can try those out on arrival to hopefully put the issues to bed.
Thank you all for your input.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23944
Joined: Sat Jul 30, 2011 7:41 pm

Re: dropped frames

Wed Aug 14, 2013 8:52 am

Depending on the resolution and fps you need, dropping the bitrate will help a lot and you probably wont even see the difference.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

User avatar
RaTTuS
Posts: 10493
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: dropped frames

Wed Aug 14, 2013 9:07 am

if you have a usb HD you can test that as a write medium [or even a file on the network wired network 1st]
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

PiGraham
Posts: 3666
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: dropped frames

Wed Aug 14, 2013 11:45 am

Rough write speed test on my 16GB Samsung class 10 Micro SD

Code: Select all

[email protected] ~ $ dd bs=1M count=512 if=/dev/zero of=test conv=fdatasync
512+0 records in
512+0 records out
536870912 bytes (537 MB) copied, 50.0011 s, 10.7 MB/s

ripping
Posts: 32
Joined: Wed Mar 14, 2012 10:55 am
Location: New Zealand

Re: dropped frames

Sat Aug 17, 2013 7:24 am

Just to drag this thread up from last week.
I acquired a PQI Tiffy 16Gb USB 3.0 stick today. Using the same method of testing on windows as I used previously I got a read/write speed of 28.49/24.844 MB/s. (over 2x the write speed of anything I had used previously)
I installed a fresh version of Raspbian on an SD card, did all the usual updating and upgrading, and then transferred the file system to the USB stick.
Once everything was up and running properly I did a quick test

Code: Select all

dd bs=1M count=512 if=/dev/zero of=test conv=fdatasync
512+0 records in
512+0 records out
536870912 bytes (537 MB) copied, 19.1144 s, 28.1 MB/s
With my last USB stick I managed 10MB/s in a similar test
So, onto testing video recording.
A two minute video at 1080p, 30fps, bitrate of 40000000 (is that valid?) shows no dropped frames.
Fair to say, as proposed earlier in this thread, that my issues with dropped frames can be solely attributed to slow media.
/closed.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23944
Joined: Sat Jul 30, 2011 7:41 pm

Re: dropped frames

Sat Aug 17, 2013 12:20 pm

Thanks Ripping - always worth having some confirmation.

I wonder whether I ought to drop the default bitrate a little.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

Aikidokajeff
Posts: 68
Joined: Fri May 25, 2012 3:31 pm

Re: dropped frames

Sun Aug 18, 2013 10:01 am

PiGraham wrote:
Aikidokajeff wrote:I always use the "-n" option when taking videos like the one seen above. (because the small TFT doesn't support live preview very well, no point in trying)
I get very nice preview on the 2.8" TFT from TEXY with tftfb and fbcopy.

What problems do you see?
I just remembered a problem I've had - using raspistill with either -vf or -hf does not show any preview.
But it works fine with raspivid.
Odd, but not a problem as I have the camera mounted the correct way up to no need it.

Jeff

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23944
Joined: Sat Jul 30, 2011 7:41 pm

Re: dropped frames

Sun Aug 18, 2013 7:26 pm

Aikidokajeff wrote:
PiGraham wrote:
Aikidokajeff wrote:I always use the "-n" option when taking videos like the one seen above. (because the small TFT doesn't support live preview very well, no point in trying)
I get very nice preview on the 2.8" TFT from TEXY with tftfb and fbcopy.

What problems do you see?
I just remembered a problem I've had - using raspistill with either -vf or -hf does not show any preview.
But it works fine with raspivid.
Odd, but not a problem as I have the camera mounted the correct way up to no need it.

Jeff
I think I fixed that bug. Try an rpi-update - think it was GPU code change.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

Aikidokajeff
Posts: 68
Joined: Fri May 25, 2012 3:31 pm

Re: dropped frames

Sun Aug 25, 2013 10:25 am

I'm out and about, so can't quickly find information, but does anyone know the default bit rate with raspivid?
I have the printed pdf to hand but it doesn't really mention defaults.

Thanks,

Jeff

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: dropped frames

Sun Aug 25, 2013 2:22 pm

30000000 as far as I remember
Alex Eames RasPi.TV, RasP.iO

shakirabbas
Posts: 10
Joined: Thu Feb 27, 2014 7:14 pm

Re: dropped frames

Mon May 19, 2014 12:14 am

This is an old thread, but I think I've came across a solution from another forum which was regarding dropped packets for audio recordings when using "arecord". I've confirmed that the same solution applies to raspivid video files as well.

Instead of buying USB sticks with higher bandwidth or reducing the bitrate in raspivid to prevent dropped frames as suggested in this thread so far, you can simply create a new partition on the Pi SD card and format the partition to XFS filesystem and write the video file (or audio file from arecord) to this disk partition. Then I see no dropped frames from raspivid with 1080p30 with default options and bitrate and no "overrun" errors from the arecord command.

I'm really not sure what it is about the XFS filesystem that solves this issue. XFS is supposed to be more reliable for larger files. I was consistently getting several dropped frames within 2 mins of video, but when writing to an XFS file system, I get zero dropped frames. This was especially a problem when running raspivid and arecord simultaneously to capture both audio and video and saving them both as files on to the SD card. With XFS i'm recording audio and video without any dropped frames/packets.

To intall XFS, you must use 'sudo apt-get install xfsprogs', and then use the 'mkfs.xfs' command to format that partition in XFS format, mount the new partition, and then write video/audio file to that partition.

el_cid
Posts: 27
Joined: Thu Jun 05, 2014 2:29 pm
Location: Switzerland

Re: dropped frames

Mon Dec 08, 2014 3:06 pm

Hello everybody,

I'm still struggling with serious frame losses and inconsistent framerates. First I was using the RPi Cam Web Interface to record videos. I then discovered my issues, and I tried then raspivid. Problems got a bit better, but the still remained. The problems are:

What I did to "measure" (a) the dropped frames and (b) to detect inconsistent framerates was (a) to run a 2 minute timer in the video and (b) to walk around.

I did a lot of videos yet, 4 Examples:

RPi Cam Web Interface
Video mode: 1920x1080, 25fps, 17Mbit/s
Video 1: Video of timer on smartphone 2 min on times takes in the clip 1:49 --> Difference of 11s
Video 2: Video of me walking around and a timer 2 min on timer <--> 1:38 in clip --> Difference 22s; serious accelerations and deccelerations in the walking movements --> means that the framerate is inconsistent

Raspivid
Video mode: 1920x1080, 25fps, default bitrate
Video 3: Video of me walking around and a timer 2 min on timer <--> 1:44 in clip --> Difference 16s; accelerations and deccelerations in the walking movements

Video mode: 1920x1080, 25fps, 10Mbit/s
Video 4: Video of me walking around and a timer 2 min on timer <--> 1:47 in clip --> Difference 13s; accelerations and deccelerations in the walking movements

SD-Card
I'm using an Sandisk Extreme Plus, my benchmarks give me 16 MB/s write speed. I have created an XFS-partition, and the RPi Cam Web Interface is recording to that partition. But as you can see it doesn't help. I will try recording to the xfs partition with raspivid.

I'm a bit discouraged... Am I just expecting to much of the camera module? I have tried a lot of things (new better sd card, xfs partition) but the issue doesn't seem to get much better ( the best I get is a loss of frames of 10%....)




EDIT: youtube-link to video: http://youtu.be/2OhT4if5YP4
Last edited by el_cid on Mon Dec 08, 2014 3:23 pm, edited 1 time in total.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23944
Joined: Sat Jul 30, 2011 7:41 pm

Re: dropped frames

Mon Dec 08, 2014 3:14 pm

What about low bitrates on lower resolutions (e.g. 720p).
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

el_cid
Posts: 27
Joined: Thu Jun 05, 2014 2:29 pm
Location: Switzerland

Re: dropped frames

Mon Dec 08, 2014 3:42 pm

jamesh wrote:What about low bitrates on lower resolutions (e.g. 720p).

I just tried 720p with 10Mbit/s. 2 min just take 1:43 in the video (recorded with raspivid). The movements seem more natural, but there a still some accelerations.

What do you think?

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23944
Joined: Sat Jul 30, 2011 7:41 pm

Re: dropped frames

Mon Dec 08, 2014 4:00 pm

Dunno, what happens if you take the bitrate down to 5Mbits/s.

The camera is clearly OK at 1080p30 (actually, its not exactly 30 but very close), so I suspect something else, probably bandwidth to the SD card, or overall CPU bandwidth. Are you doing anything other than just running raspivid with default (apart from resolution and bitrate ) settings?
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

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

Re: dropped frames

Mon Dec 08, 2014 4:10 pm

The main camera crystal is running at 25MHz instead of the intended 24.8MHz, so that will run 0.81% fast (ie too many frames per time interval) - not a big enough difference to explain your diffs.

All frames are timestamped, but as raspivid doesn't write to a container and the raw H264 bitstream doesn't have timestamps, you don't see it.
I'd suggest you do a couple of your own tests:
- checkout your own copy of the userland tree (git clone https://github.com/raspberrypi/userland.git)
- cd userland
- edit raspivid.c (nano host_applications/linux/apps/raspicam/RaspiVid.c) and add code in encoder_buffer_callback to print out buffer->pts.
- compile it (./buildme)
- run your new raspivid (it will have been installed to the normal /opt/vc directory by buildme) and see what the timestamps are.
If there are jumps of 80ms between some buffers then your SD card isn't keeping up. Retest with streaming to /dev/nul to confirm that the timestamps are then even.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

el_cid
Posts: 27
Joined: Thu Jun 05, 2014 2:29 pm
Location: Switzerland

Re: dropped frames

Mon Dec 08, 2014 4:13 pm

I believe I just found an important factor: the metering (mode), and the difficult light conditions in the place where I record the videos. The best is to watch the video: http://youtu.be/FGoB8mLPGxY

In the moments when the brightness changes, the video speeds up - when I walk around on the side of the image, the movements look very normal. Also time difference is reduced to 8s. This makes somehow sense, no? When I get in to the spots where the metering is done, the camera needs to recalculate the brightness and the focus, and this takes time, which causes frame losses, which the causes the accelerated movements... Please correct me where I'm wrong.

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

Re: dropped frames

Mon Dec 08, 2014 4:31 pm

el_cid wrote:In the moments when the brightness changes, the video speeds up - when I walk around on the side of the image, the movements look very normal. Also time difference is reduced to 8s. This makes somehow sense, no? When I get in to the spots where the metering is done, the camera needs to recalculate the brightness and the focus, and this takes time, which causes frame losses, which the causes the accelerated movements... Please correct me where I'm wrong.
It should have no impact. If you have asked for a fixed frame rate, then that should be delivered. Exposure time is independent of, but bounded by, framerate.
Please quote the exact raspivid command line you are using, and the firmware you are using (IIRC "sudo vcgencmd version). There was a bug about a year back that meant that the framerate wasn't followed but that was fixed.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

el_cid
Posts: 27
Joined: Thu Jun 05, 2014 2:29 pm
Location: Switzerland

Re: dropped frames

Mon Dec 08, 2014 5:28 pm

jamesh wrote:Dunno, what happens if you take the bitrate down to 5Mbits/s.

The camera is clearly OK at 1080p30 (actually, its not exactly 30 but very close), so I suspect something else, probably bandwidth to the SD card, or overall CPU bandwidth. Are you doing anything other than just running raspivid with default (apart from resolution and bitrate ) settings?
with (--> the raspivid command)

Code: Select all

raspivid -o /xfsmedia/video5.h264 -w 1080 -h 720 -b 5000000 -t 150000 -mm spot -fps 25
followed by

Code: Select all

MP4Box -fps 25 -add /xfsmedia/video5.h264 /xfsmedia/video.mp4
I actually get good videos. In the first one I tried not to cross the metering spot as few times as possible, in the other I tried to cross it as much as possible - In both movement is natural and the 2 minute timer takes 2 minutes in the video (+-2s accuracy, but that might be because VLC doesnt show the precise time)

I think the apache server from the RPi Cam Web Interface is still running, but this uses nearly no CPU.

vcgencmd version gives 3f2f2607186be72e4945cfa8edc77872dfc73195 (clean) (release)

el_cid
Posts: 27
Joined: Thu Jun 05, 2014 2:29 pm
Location: Switzerland

Re: dropped frames

Mon Dec 08, 2014 5:37 pm

6by9 wrote:The main camera crystal is running at 25MHz instead of the intended 24.8MHz, so that will run 0.81% fast (ie too many frames per time interval) - not a big enough difference to explain your diffs.

All frames are timestamped, but as raspivid doesn't write to a container and the raw H264 bitstream doesn't have timestamps, you don't see it.
I'd suggest you do a couple of your own tests:
- checkout your own copy of the userland tree (git clone https://github.com/raspberrypi/userland.git)
- cd userland
- edit raspivid.c (nano host_applications/linux/apps/raspicam/RaspiVid.c) and add code in encoder_buffer_callback to print out buffer->pts.
- compile it (./buildme)
- run your new raspivid (it will have been installed to the normal /opt/vc directory by buildme) and see what the timestamps are.
If there are jumps of 80ms between some buffers then your SD card isn't keeping up. Retest with streaming to /dev/nul to confirm that the timestamps are then even.
You need to help me a little bit here. You mean I can just write in the function encoder_buffer_callback a line, which prints buffer->pts in a file?

I justed wanted to write that this is way to difficult for me, but just by thinking 5 minutes and reading the code, things got in reach. :)

el_cid
Posts: 27
Joined: Thu Jun 05, 2014 2:29 pm
Location: Switzerland

Re: dropped frames

Mon Dec 08, 2014 5:39 pm

Just to say it: jamesh and 6by9, I greatly appreciate your help.

Return to “Camera board”