Rolling shutter measurements for EOS R

TLDR: one can easily measure rolling shutter for any digital camera by... filming some flickering light!

Method: https://blog.kasson.com/nikon-z6-7/how-fast-is-the-z7-silent-shutter/

Code: https://www.magiclantern.fm/forum/index.php?topic=23040

main

Test setup (results provided by @kitor on the forum):

  • LED flickering at 500 Hz PWM generated with an Arduino Uno runnning pwm.ino
  • test frames from a 5D Mark II to cross-check the LED frequency.
In [1]:
%%shell
wget -q -c https://kitor.pl/eos_r/eos.zip
unzip -o eos.zip
Archive:  eos.zip
   creating: eos/
   creating: eos/5d2/
  inflating: eos/5d2/M17-1739.MLV    
  inflating: eos/5d2/M17-1740.MLV    
  inflating: eos/5d2/M17-1741.MLV    
  inflating: eos/5d2/MVI_3694.MOV    
  inflating: eos/5d2/MVI_3695.MOV    
  inflating: eos/5d2/MVI_3696.MOV    
   creating: eos/r/
  inflating: eos/r/2Q4A0193.MP4      
  inflating: eos/r/2Q4A0194.MP4      
  inflating: eos/r/2Q4A0195.MP4      
  inflating: eos/r/2Q4A0196.MP4      
  inflating: eos/r/2Q4A0197.MP4      
  inflating: eos/r/2Q4A0198.MP4      
  inflating: eos/r/2Q4A0199.MP4      
  inflating: eos/r/2Q4A0200.MP4      
  inflating: eos/r/2Q4A0201.MP4      
  inflating: eos/r/2Q4A0202.MP4      
  inflating: eos/r/2Q4A0203.MP4      
  inflating: eos/r/2Q4A0204.MP4      
  inflating: eos/r/2Q4A0205.MP4      
  inflating: eos/r/2Q4A0206.MP4      
  inflating: eos/r/2Q4A0207.MP4      
  inflating: eos/r/2Q4A0208.MP4      
  inflating: eos/r/2Q4A0211.CR3      
  inflating: eos/r/2Q4A0211.JPG      

Bunch of files to be identified from metadata. 5D2 files are for cross-checking the method on a camera with known timings.

In [2]:
%%shell
for f in eos/*/*.MOV eos/*/*.MP4; do
  echo -n "$f:"
  ffprobe -i $f |& grep fps | grep -oE --color=never " [0-9][0-9]+x[0-9]+.* fps"
done
eos/5d2/MVI_3694.MOV: 1920x1080, 42205 kb/s, 25 fps
eos/5d2/MVI_3695.MOV: 1920x1080, 44155 kb/s, 23.98 fps
eos/5d2/MVI_3696.MOV: 1920x1080, 42634 kb/s, 29.97 fps
eos/r/2Q4A0193.MP4: 3840x2160, 458157 kb/s, 24 fps
eos/r/2Q4A0194.MP4: 1920x1080, 88201 kb/s, 24 fps
eos/r/2Q4A0195.MP4: 1280x720, 39331 kb/s, 25 fps
eos/r/2Q4A0196.MP4: 3840x2160, 458958 kb/s, 25 fps
eos/r/2Q4A0197.MP4: 1920x1080, 178179 kb/s, 50 fps
eos/r/2Q4A0198.MP4: 1920x1080, 88277 kb/s, 25 fps
eos/r/2Q4A0199.MP4: 1280x720, 79443 kb/s, 50 fps
eos/r/2Q4A0200.MP4: 1280x720, 13009 kb/s, 25 fps
eos/r/2Q4A0201.MP4: 1280x720, 40117 kb/s, 29.97 fps
eos/r/2Q4A0202.MP4: 3840x2160, 467960 kb/s, 29.97 fps
eos/r/2Q4A0203.MP4: 3840x2160, 467360 kb/s, 23.98 fps
eos/r/2Q4A0204.MP4: 1920x1080, 179887 kb/s, 59.94 fps
eos/r/2Q4A0205.MP4: 1920x1080, 90027 kb/s, 29.97 fps
eos/r/2Q4A0206.MP4: 1920x1080, 89975 kb/s, 23.98 fps
eos/r/2Q4A0207.MP4: 1280x720, 80214 kb/s, 59.94 fps
eos/r/2Q4A0208.MP4: 1280x720, 13371 kb/s, 29.97 fps

Checking 5D2 files. Will prefer MLV, as H.264 is upsampled from some lower resolution (close to 1872x1053, but not 100% sure). We already know the sensor readout timings for raw image capture, but we do not know exactly the resizing factors in the processing pipeline.

In [3]:
%%shell
for f in eos/5d2/*.MLV; do
  echo -n "$f: "
  mlv_dump $f --dng -f1-32 -v |& grep -im1 --color=never fps
done
eos/5d2/M17-1739.MLV:     FPS         : 25.000000
eos/5d2/M17-1740.MLV:     FPS         : 23.976000
eos/5d2/M17-1741.MLV:     FPS         : 29.970000

Measuring the light frequency, knowing the readout timings in LiveView (Main Clock = 24 MHz, FPS timer A = 600 at 25p and 576 and 24/30p):

In [4]:
%%shell
echo -n > freq.log

for f in eos/5d2/M17-1739*.dng; do
  octave rolling.m $f 24e6 600 | grep --color=never "measured" | tee -a freq.log
done

for f in eos/5d2/M17-174[01]*.dng; do
  octave rolling.m $f 24e6 576 | grep --color=never "measured" | tee -a freq.log
done
Light source frequency: 498.81 Hz (measured).
Light source frequency: 498.77 Hz (measured).
Light source frequency: 498.73 Hz (measured).
Light source frequency: 498.81 Hz (measured).
Light source frequency: 498.81 Hz (measured).
Light source frequency: 498.89 Hz (measured).
Light source frequency: 498.92 Hz (measured).
Light source frequency: 499.00 Hz (measured).
Light source frequency: 499.00 Hz (measured).
Light source frequency: 499.04 Hz (measured).
Light source frequency: 499.08 Hz (measured).
Light source frequency: 499.04 Hz (measured).
Light source frequency: 499.00 Hz (measured).
Light source frequency: 498.96 Hz (measured).
Light source frequency: 498.92 Hz (measured).
Light source frequency: 499.00 Hz (measured).
Light source frequency: 498.92 Hz (measured).
Light source frequency: 499.00 Hz (measured).
Light source frequency: 499.11 Hz (measured).
Light source frequency: 499.19 Hz (measured).
Light source frequency: 499.34 Hz (measured).
Light source frequency: 499.50 Hz (measured).
Light source frequency: 499.73 Hz (measured).
Light source frequency: 499.88 Hz (measured).
Light source frequency: 500.03 Hz (measured).
Light source frequency: 500.22 Hz (measured).
Light source frequency: 500.26 Hz (measured).
Light source frequency: 500.34 Hz (measured).
Light source frequency: 500.37 Hz (measured).
Light source frequency: 500.22 Hz (measured).
Light source frequency: 500.14 Hz (measured).
Light source frequency: 500.03 Hz (measured).
Light source frequency: 496.82 Hz (measured).
Light source frequency: 496.23 Hz (measured).
Light source frequency: 495.59 Hz (measured).
Light source frequency: 495.63 Hz (measured).
Light source frequency: 495.24 Hz (measured).
Light source frequency: 495.95 Hz (measured).
Light source frequency: 496.82 Hz (measured).
Light source frequency: 495.99 Hz (measured).
Light source frequency: 495.55 Hz (measured).
Light source frequency: 495.55 Hz (measured).
Light source frequency: 495.20 Hz (measured).
Light source frequency: 496.27 Hz (measured).
Light source frequency: 496.78 Hz (measured).
Light source frequency: 495.79 Hz (measured).
Light source frequency: 495.63 Hz (measured).
Light source frequency: 495.43 Hz (measured).
Light source frequency: 495.35 Hz (measured).
Light source frequency: 496.51 Hz (measured).
Light source frequency: 496.51 Hz (measured).
Light source frequency: 495.63 Hz (measured).
Light source frequency: 495.67 Hz (measured).
Light source frequency: 495.35 Hz (measured).
Light source frequency: 495.51 Hz (measured).
Light source frequency: 496.82 Hz (measured).
Light source frequency: 496.31 Hz (measured).
Light source frequency: 495.55 Hz (measured).
Light source frequency: 495.67 Hz (measured).
Light source frequency: 495.24 Hz (measured).
Light source frequency: 495.83 Hz (measured).
Light source frequency: 496.86 Hz (measured).
Light source frequency: 496.11 Hz (measured).
Light source frequency: 495.59 Hz (measured).
Light source frequency: 495.71 Hz (measured).
Light source frequency: 496.23 Hz (measured).
Light source frequency: 495.67 Hz (measured).
Light source frequency: 495.79 Hz (measured).
Light source frequency: 496.07 Hz (measured).
Light source frequency: 495.67 Hz (measured).
Light source frequency: 495.95 Hz (measured).
Light source frequency: 496.03 Hz (measured).
Light source frequency: 495.59 Hz (measured).
Light source frequency: 496.07 Hz (measured).
Light source frequency: 495.95 Hz (measured).
Light source frequency: 495.55 Hz (measured).
Light source frequency: 496.19 Hz (measured).
Light source frequency: 495.91 Hz (measured).
Light source frequency: 495.55 Hz (measured).
Light source frequency: 496.27 Hz (measured).
Light source frequency: 495.75 Hz (measured).
Light source frequency: 495.43 Hz (measured).
Light source frequency: 496.43 Hz (measured).
Light source frequency: 495.71 Hz (measured).
Light source frequency: 495.47 Hz (measured).
Light source frequency: 496.55 Hz (measured).
Light source frequency: 495.67 Hz (measured).
Light source frequency: 495.43 Hz (measured).
Light source frequency: 496.59 Hz (measured).
Light source frequency: 495.67 Hz (measured).
Light source frequency: 495.43 Hz (measured).
Light source frequency: 496.71 Hz (measured).
Light source frequency: 495.59 Hz (measured).
Light source frequency: 495.31 Hz (measured).
Light source frequency: 496.78 Hz (measured).
Light source frequency: 495.59 Hz (measured).
In [5]:
%%shell
cat freq.log | cut -d ' ' -f 4 > freq.csv
In [6]:
freq = dlmread('freq.csv');
mean(freq)
std(freq)
ans =  497.05
ans =  1.7093

Looks like our PWM is running at slightly below the expected 500 Hz. This can be confirmed by watching the video clips recorded at 25p and 50p - the PWM is not perfectly in sync. Ideally, the stripes should stay in the same place (they should not move).

Double-checked the Arduino code on my Micro board; its output is definitely 500 Hz and in perfect sync with both 5D2 and 5D3 at 1080p25 (and at 1080p50 on the latter). Not sure what happened on kitor's side; he ran the same code on an Arduino Uno. He did test the signal with an oscilloscope and found it to drift between 499.4 and 498.8 Hz.

osc

Let's assume the PWM frequency is 499 Hz for now.

On EOS R, manual examination reveals the same amount of rolling shutter at some given resolution, regardless of frame rate.

In this case, let's group together all 4K files, all 1080p files, all regular 720p files and all slow-mo 720p files.

In [7]:
%%shell
cd eos/r/
mkdir -p 4K 1080p 720p 720p-sm

for f in *.MP4; do
  if ffprobe -i $f |& grep fps | grep -q "3840x2160"; then
    mv $f 4K/;
  elif ffprobe -i $f |& grep fps | grep -q "1920x1080"; then
    mv $f 1080p/;
  elif ffprobe -i $f |& grep fps | grep -q "1280x720"; then
    if ffprobe -i $f |& grep -q "Audio:"; then
      mv $f 720p/
    else
      mv $f 720p-sm/
    fi
  fi
done

Let's extract the first 8 frames from each clip.

In [8]:
%%shell
cd eos/r
for f in */*.MP4; do
    ffmpeg -loglevel quiet -hide_banner -i $f -vframes 8 $(dirname $f)/$(basename $f .MP4)-%d.png
done

First frames from each set (4K, 1080p, 720p, 720p slow-mo):

In [9]:
%%shell
for f in eos/r/*/*-1.png; do
  convert $f -resize 50% -quality 80 $(dirname $f)/$(basename $f .png).jpg
done

4K 1080p 720p 720p-sm

We've also got a silent still picture, apparently read out pretty quickly:

In [10]:
%%shell
convert eos/r/2Q4A0211.JPG -resize 20% -quality 80 eos/r/2Q4A0211-small.jpg