User avatar
HermannSW
Posts: 6093
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

raspivid: fpsₘₐₓ(v₂)=120, fpsₘₐₓ(v₁)=90 / 800x760: fps(v₂)=120, fps(v₁)=90

Sat Jan 06, 2018 3:19 pm

I am interested in high framerate video capturing and found that v1 cameras can do up to 750fps with the help of GPU avoiding raspiraw.

Yesterday I read many postings being search results for "high framerate" in this forum and found this year old posting from 6by9:
viewtopic.php?t=169169#p1089367
  1. raspivid can produce timecode file in form usable for matroska video tools
  2. mkvmerge can create Matroska video from .h264 using that timecodes file for the frames
  3. most importantly I saw "-fps 100", and that it worked with a v2 camera
I knew that 90fps is the absolute maximal raspivid framerate for v1 camera and played a bit.

You can get 108fps for 960x720 without frame skips, maybe standard qHD format 960x540 is more important.

And there is a limit of 120fps that can be achieved, I did not lookup source code yet but it seems to be hard coded.

Anyway the biggest format that I found and can do 120fps without frame skips is 800x600!
So this is the difference for raspivid between v1 and v2 cameras:
  1. maximal framerate for v2 camera is 120fps, for v1 camera 90fps
  2. 800x600 maximal framerate is 120fps for v2 camera, 90fps for v1 camera
Frame delta and skip analysis:

Code: Select all

pi@raspberrypi2B:~ $ raspivid -w 800 -h 600 -fps 150 -o video.h264 -pts timecodes.txt -t 10000
pi@raspberrypi2B:~ $ ./ptsanalyze timecodes.txt 1-79
1170 tstamps.csv frames were captured at 120fps
frame delta time[us] distribution
      1 
      2 8279
      1 8292
      2 8293
     40 8294
    346 8295
    560 8296
    191 8297
     22 8298
      3 8299
      2 8312
after skip frame indices (middle column)
0% frame skips
pi@raspberrypi2B:~
Last edited by HermannSW on Wed Jan 10, 2018 2:24 pm, edited 1 time in total.
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

User avatar
HermannSW
Posts: 6093
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: raspivid: fpsₘₐₓ(v₂)=120, fpsₘₐₓ(v₁)=90 / 800x600: fps(v₂)=120, fps(v₁)=90

Tue Jan 09, 2018 11:00 pm

I played a bit more and stored generated .h264 file in /dev/shm ramdisk.
I could keep 120fps as long as I kept width=800.
I finally reached 800x760(!) at 120fps, without a single frame skip!!

This is how I captured the video and converted to video.mkv with mkvmerge and timestamp file:

Code: Select all

pi@raspberrypi2B:~ $ raspivid -t 5300 -w 800 -h 760 -fps 120 -pts timecodes.txt -o /dev/shm/test.h264
Too many macroblocks/s: Increasing H264 Level to 4.2
pi@raspberrypi2B:~ $ mkvmerge -o video.mkv --timecodes 0:timecodes.txt /dev/shm/test.h264 
mkvmerge v9.8.0 ('Kuglblids') 32bit
'/dev/shm/test.h264': Using the demultiplexer for the format 'AVC/h.264'.
'/dev/shm/test.h264' track 0: Using the output module for the format 'AVC/h.264 (unframed)'.
The file 'video.mkv' has been opened for writing.
Progress: 100%
The cue entries (the index) are being written...
Multiplexing took 3 seconds.
pi@raspberrypi2B:~ $ 

And the file sizes are really small, less than 7MB.
Given 448MB free memory under /dev/shm on Pi 2B you can capture more than a minute of 800x760 at 120fps video!

Code: Select all

pi@raspberrypi2B:~ $ du -sk /dev/shm/test.h264 video.mkv 
6656	/dev/shm/test.h264
6664	video.mkv
pi@raspberrypi2B:~ $ 

Frame delta and skip analysis shows that capturing was really done at 120fps, without any skipped frame!

Code: Select all

pi@raspberrypi2B:~ $ ./ptsanalyze timecodes.txt 1-79
609 tstamps.csv frames were captured at 120fps
frame delta time[us] distribution
      1 
      3 8292
      6 8293
     55 8294
    135 8295
    258 8296
    137 8297
      8 8298
      4 8299
      2 8300
after skip frame indices (middle column)
0% frame skips
pi@raspberrypi2B:~ $

You can download video.mkv for playing with your video player.
Below you see confirmation of Dimensions, Codec and Framerate from totem video player.
https://stamm-wilbrandt.de/en/forum/video.mkv
Image


Here you can see frame delta and skip analysis for a minute of video capture (8296μs ± 15μs):

Code: Select all

pi@raspberrypi2B:~ $ ./ptsanalyze timecodes.txt 1-79
7210 tstamps.csv frames were captured at 120fps
frame delta time[us] distribution
      1 
      1 8281
      1 8283
      3 8284
      2 8285
      1 8286
      1 8287
      2 8288
      2 8289
      4 8290
      4 8291
     10 8292
     56 8293
    586 8294
   1668 8295
   3236 8296
   1413 8297
    171 8298
     20 8299
      9 8300
      3 8301
      2 8302
      4 8303
      2 8305
      1 8306
      2 8307
      2 8308
      2 8309
      1 8311
after skip frame indices (middle column)
0% frame skips
pi@raspberrypi2B:~ $

If I ever get this frame size captured with raspiraw (better only 800x720 at 120fps), then I will most likely get
  • 800x240 at 360fps
  • 800x120 at 720fps
  • 800x64 at 1300fps(?)
  • 800x32 at >2000fps(?)
...

I really want to capture the register sets for v2 camera, and I spent a lot of time on that already.
Any help to get me over the hurdles is really appreciated, see this posting and following for details:
viewtopic.php?f=43&t=109137&start=350#p1252015


P.S:
XGA format 1024x768 at 90fps can be captured on Pi Zero with v1 camera without frame skips:

Code: Select all

pi@raspberrypi01:~ $ raspivid -t 5300 -w 1024 -h 768 -fps 90 -pts timecodes.txt -o /dev/shm/test.h264 2>/dev/null 
pi@raspberrypi01:~ $ ./ptsanalyze timecodes.txt 2-9
464 tstamps.csv frames were captured at 90fps
frame delta time[us] distribution
      1 
      1 11089
     65 11090
    348 11091
     48 11092
      1 11094
after skip frame indices (middle column)
0% frame skips
pi@raspberrypi01:~ $  
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

Return to “Camera board”