Still on postmarketOS.
using bash, to call
ffmpeg take pictures with the pinephone camera.
need to setup the camera for the resolution and format required :
-d /dev/media1 \
--set-v4l2 '"ov5640 4-004c":0[fmt:SBGGR8_1X8/2592x1944@1/15]'
then call ffmpeg to record raw video to a file. Found the following settings work:
ffmpeg -hide_banner \ -f rawvideo \ -pix_fmt bayer_bggr8 \ -s 2592x1944 \ -f video4linux2 \ -i /dev/video3 \ -vsync 2 \ -vframes 20 \ NAME_vid.yuv
this sets the encoder and resolution to match the settings above; the device
/dev/video3 is my phone, not sure if this is standard for all.
why 20 frames? by experimentation, found that the first few frames were not good (~5 or so). To me it seems like the system is “warming up”. Initial black or green, then lighting/colours off. So for the “real” picture, need more than just one.
then, convert the above
.yuv file to a set of jpeg files with another
ffmpeg \ -ss 0.5 \ -hide_banner \ -f rawvideo \ -pix_fmt bayer_bggr8 \ -s 2592x1944 \ -i NAME_vid.yuv \ -vsync 2 \ -vframes 2 \ ~/Pictures/NAME_of_Pictures_%05d.jpg
.png or another picture format.
-ss 0.5 skips the bad frames
Note: latest ffmpeg gave an error (2021-04-11) when run:
Error relocating /usr/bin/ffmpeg: av_opt_child_class_iterate: symbol not found
but downloading the latest source for ffmpeg and compiling worked again.
Sample, a bit dark, took it in the evening.
more camera controls: exposure, and such…