raspberrypi / rpicam-apps

BSD 2-Clause "Simplified" License
420 stars 228 forks source link

[BUG] Can't record a still snapshot while libcamera-vid is recording #382

Closed pakal closed 2 years ago

pakal commented 2 years ago

The legacy raspivid/picamera stack had a special mode to extract frames without disrupting video recording:

https://picamera.readthedocs.io/en/release-1.13/recipes2.html#capturing-images-whilst-recording

With libcamera, we can have a preview in a GUI window, but I couldn't find options to extract still images from the video stream.

Attempting to use libcamera-still during video recording naturally creates a conflict :

pi@raspberrypi:~ $ libcamera-still --nopreview -o screenshotlive.jpg
[0:38:46.902978936] [1491]  INFO Camera camera_manager.cpp:293 libcamera v0.0.0+3866-0c55e522
[0:38:47.817337184] [1492]  INFO RPI raspberrypi.cpp:1374 Registered camera /base/soc/i2c0mux/i2c@1/ov5647@36 to Unicam device /dev/media3 and ISP device /dev/media0
[0:38:47.838401006] [1491]  INFO Camera camera.cpp:848 Pipeline handler in use by another process
[0:38:47.839941993] [1492] ERROR V4L2 v4l2_videodevice.cpp:1234 /dev/video0[12:cap]: Unable to request 0 buffers: Device or resource busy
[0:38:47.840602987] [1492] ERROR V4L2 v4l2_videodevice.cpp:1234 /dev/video13[13:out]: Unable to request 0 buffers: Device or resource busy

Is there any workaround, of future plan, for libcamera-apps to allow this ? Without resorting to a custom handling of the h264 stream ?

Thanks a lot !

naushir commented 2 years ago

This is not something we intend to do with libcamera-apps unfortunately.

However, @davidplowman might be able to tell you if this might be feasible through picamera2.

davidplowman commented 2 years ago

Does this help? https://github.com/raspberrypi/picamera2/blob/main/examples/still_during_video.py

pakal commented 2 years ago

Thanks for the feedback, OK then for now I'll pause video, and I'll implement a picamera2-based handler later to make it smoothly :)