(ugly colors animated .gif, plays slowed down by factor of 16, allows to see 0.01s steps in timeoverlay)

Why PS3 Eye as webcam?
I really like to take 90fps 640x480 videos with Pi camera v1. I also want to go with higher fps with that camera, and 6by9's cool "raspiraw" might even make >300fps possible.
Last week I googled for alternative high framerate cameras and stumbled over this posting:
https://www.zonetrigger.com/articles/hi ... e-cameras/
It mentioned Sony PS3 Eye camera as being able to do 150fps@320x240 as USB webcam:
https://en.wikipedia.org/wiki/PlayStation_Eye
Then I found this 2014 article
http://www.phoronix.com/scan.php?page=n ... px=MTg3NTM
that speaks of 187fps support addition to Linux kernel for PS3 Eye:
http://lkml.iu.edu/hypermail/linux/kern ... 01236.html
At that point I searched where to get and what price, and ordered on amazon for 10$.
PS3 Eye modes available under Linux/Raspbian
After I received PS3 Eye, I attached it to Pi ZeroW and some googling showed how to determine the modes available. I was not impressed by the 640x480 modes, but definitely was from the many >100fps 320x240 modes:
Capturing and storing 100fps PS3 Eye 320x240 video with Pi ZeroWpi@raspberrypi03:~ $ v4l2-ctl --list-devices
USB Camera-B4.09.24.1 (usb-20980000.usb-1):
/dev/video0
pi@raspberrypi03:~ $ v4l2-ctl --list-formats-ext -d /dev/video0
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'YUYV'
Name : YUYV 4:2:2
Size: Discrete 320x240
Interval: Discrete 0.005s (187.000 fps)
Interval: Discrete 0.007s (150.000 fps)
Interval: Discrete 0.007s (137.000 fps)
Interval: Discrete 0.008s (125.000 fps)
Interval: Discrete 0.010s (100.000 fps)
Interval: Discrete 0.013s (75.000 fps)
Interval: Discrete 0.017s (60.000 fps)
Interval: Discrete 0.020s (50.000 fps)
Interval: Discrete 0.027s (37.000 fps)
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 640x480
Interval: Discrete 0.017s (60.000 fps)
Interval: Discrete 0.020s (50.000 fps)
Interval: Discrete 0.025s (40.000 fps)
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.067s (15.000 fps)
pi@raspberrypi03:~ $
I tried ffmpeg to capture normal low fps video from PS3 Eye, but only ran into problems, too much frame losses, unreliable.
Then I remembered gstreamer library (I showed how to stream with it with PI here). After some playing I was able to setup a 100fps pipeline that stored video as file. Unfortunately a 3sec video took more than 5sec to record. It turned out that storing on SD card was bottleneck. I resolved that by outputting file into /dev/shm (memory filesystem). Now only 0.1sec overhead was added to video taking time (Execution ended after 3116775270 ns):
Code: Select all
pi@raspberrypi03:~ $ gst-launch-0.10 -v v4l2src device=/dev/video0 num-buffers=300 ! video/x-raw-yuv,width=320,height=240, framerate=100/1 ! videoscale ! timeoverlay ! avimux ! filesink location=/dev/shm/x.avi
Setting pipeline to PAUSED ...
/GstPipeline:pipeline0/GstV4l2Src:v4l2src0.GstPad:src: caps = video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)100/1
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)100/1
New clock: GstSystemClock
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:sink: caps = video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)100/1
/GstPipeline:pipeline0/GstVideoScale:videoscale0.GstPad:src: caps = video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)100/1
/GstPipeline:pipeline0/GstVideoScale:videoscale0.GstPad:sink: caps = video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)100/1
/GstPipeline:pipeline0/GstTimeOverlay:timeoverlay0.GstPad:src: caps = video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)100/1
/GstPipeline:pipeline0/GstTimeOverlay:timeoverlay0.GstPad:video_sink: caps = video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)100/1
/GstPipeline:pipeline0/GstAviMux:avimux0.GstPad:video_00: caps = video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)100/1
/GstPipeline:pipeline0/GstAviMux:avimux0.GstPad:src: caps = video/x-msvideo
/GstPipeline:pipeline0/GstFileSink:filesink0.GstPad:sink: caps = video/x-msvideo
Got EOS from element "pipeline0".
Execution ended after 3116775270 ns.
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
/GstPipeline:pipeline0/GstFileSink:filesink0.GstPad:sink: caps = NULL
/GstPipeline:pipeline0/GstAviMux:avimux0.GstPad:video_00: caps = NULL
/GstPipeline:pipeline0/GstAviMux:avimux0.GstPad:src: caps = NULL
/GstPipeline:pipeline0/GstTimeOverlay:timeoverlay0.GstPad:src: caps = NULL
/GstPipeline:pipeline0/GstTimeOverlay:timeoverlay0.GstPad:video_sink: caps = NULL
/GstPipeline:pipeline0/GstVideoScale:videoscale0.GstPad:src: caps = NULL
/GstPipeline:pipeline0/GstVideoScale:videoscale0.GstPad:sink: caps = NULL
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = NULL
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:sink: caps = NULL
/GstPipeline:pipeline0/GstV4l2Src:v4l2src0.GstPad:src: caps = NULL
Setting pipeline to NULL ...
Freeing pipeline ...
pi@raspberrypi03:~ $
I uploaded the video to youtube (the original x.avi is available here as well, 44MB):
https://www.youtube.com/watch?v=WwBwgtl ... e=youtu.be
In order to avoid youtube upload to drop a lot of frames from the .avi I had to do this strange conversion to .mp4 with fake 25fps framerate:
Code: Select all
$ ffmpeg -i x.avi frame.%03d.png; ffmpeg -r 25 -f image2 -i frame.%03d.png -vcodec libx264 -crf 25 -pix_fmt yuv420p frame.mp4
Or you choose 0.25 as speed in youtube settings, then video plays slowed down by factor of 16 and you can see the 0.01s steps of timeoverlay as well.
Here you can see that from first frame you can see match glow (0.866s) it takes until 1.026s before flame gets bigger:

The framerate is shaky until 0.2s, and a bit shaky until 0.7s. It turned out that the camera framerate is 100fps, and the shaky timestamps are result of using gstreamer timeoverlay at all ...:
Code: Select all
pi@raspberrypi03:~ $ gst-launch-0.10 -v v4l2src device=/dev/video0 num-buffers=300 ! video/x-raw-yuv,width=320,height=240, framerate=100/1 ! videoscale ! fakesink | grep duration | cut -f 5-8 -d\: | cut -f2 -d, | tail -3
timestamp: 0:00:02.970570154
timestamp: 0:00:02.980650070
timestamp: 0:00:02.990441988
pi@raspberrypi03:~ $ gst-launch-0.10 -v v4l2src device=/dev/video0 num-buffers=300 ! video/x-raw-yuv,width=320,height=240, framerate=100/1 ! videoscale ! fakesink | grep duration | cut -f 5-8 -d\: | cut -f2 -d, | tail -3
timestamp: 0:00:02.970263156
timestamp: 0:00:02.980386072
timestamp: 0:00:02.990262989
pi@raspberrypi03:~ $ gst-launch-0.10 -v v4l2src device=/dev/video0 num-buffers=300 ! video/x-raw-yuv,width=320,height=240, framerate=100/1 ! videoscale ! timeoverlay ! fakesink | grep duration | cut -f 5-8 -d\: | cut -f2 -d, | tail -3
timestamp: 0:00:03.073793293
timestamp: 0:00:03.083821210
timestamp: 0:00:03.093823126
pi@raspberrypi03:~ $ gst-launch-0.10 -v v4l2src device=/dev/video0 num-buffers=300 ! video/x-raw-yuv,width=320,height=240, framerate=100/1 ! videoscale ! timeoverlay ! fakesink | grep duration | cut -f 5-8 -d\: | cut -f2 -d, | tail -3
timestamp: 0:00:03.044038542
timestamp: 0:00:03.054030458
timestamp: 0:00:03.064040375
pi@raspberrypi03:~ $