Simultaenous camera preview and recording

Hi,
On 820 platform, preview and recording is working independently. But when trying to enable both at the same time (recording with preview displayed), I am getting below error while configuring the pipeline.

media_setup_link: Unable to setup link (Device or resource busy)

“msm_ispif0”:1->“msm_vfe0_pix”:0[1]

Unable to parse link: Device or resource busy (16).

For preview, pipeline is configured as below

sudo media-ctl -d /dev/media0 -l ‘“msm_csiphy0”:1->“msm_csid0”:0[1],“msm_csid0”:1->“msm_ispif0”:0[1],“msm_ispif0”:1->“msm_vfe0_rdi0”:0[1]’
sudo media-ctl -d /dev/media0 -V ‘“ov5640 4-003b”:0[fmt:UYVY8_2X8/1920x1080 field:none],“msm_csiphy0”:0[fmt:UYVY8_2X8/1920x1080 field:none],“msm_csid0”:0[fmt:UYVY8_2X8/1920x1080 field:none],“msm_ispif0”:0[fmt:UYVY8_2X8/1920x1080 field:none],“msm_vfe0_rdi0”:0[fmt:UYVY8_2X8/1920x1080 field:none]’

For encoding, below is the configuration.

sudo media-ctl -v -d /dev/media0 -l ‘“msm_csiphy0”:1->“msm_csid0”:0[1],“msm_csid0”:1->“msm_ispif0”:0[1],“msm_ispif0”:1->“msm_vfe0_pix”:0[1]’
sudo media-ctl -v -d /dev/media0 -V ‘“ov5640 4-003b”:0[fmt:UYVY8_2X8/1920x1080 field:none],“msm_csiphy0”:0[fmt:UYVY8_2X8/1920x1080 field:none],“msm_csid0”:0[fmt:UYVY8_2X8/1920x1080 field:none],“msm_ispif0”:0[fmt:UYVY8_2X8/1920x1080 field:none],“msm_vfe0_pix”:0[fmt:UYVY8_2X8/1920x1080 field:none],“msm_vfe0_pix”:1[fmt:UYVY8_1_5X8/1920x1080 field:none]’

Regards,
Kamalnath

AFAIU, you can not fork the pipeline, an ‘entity pad’ can only have point-to-point link to an other one (sink/source). That why you get the resource busy error. Actually the configurations here have nothing to do with preview or recording, the first one routes the video to the raw data interface (rdi0), bypassing the Image Processing Pipeline, so you can get the untouched output of your sensor (YUV, bayer…) via e.g. /dev/video0. The second configuration routes the video to the pix interface, feeding the Image Processing Pipeline, in which you can convert format (YUV to NV12…), crop, scale…, the result is available via e.g. /dev/video3.

So video preview/encoding depend on what you do with that stream. The point is that the hardware encoder (venus) supports NV12 only as input, so using the pix interface (with UYVY8_1_5X8 bus format) here is probably good to perform the conversion in hardware and feed the encoder with native format.

You can, however, involve branches later in your gstreamer pipeline using named elements (e.g. with tee), here is a basic example of two simultaneous previews:

gst-launch-1.0 videotestsrc ! videoconvert ! tee name=t ! queue ! autovideosink t. ! queue ! autovideosink

You need to apply the same in your preview+record gst pipeline.

refs:

Thanks Loic for the response.

I was expecting that there will be a way for ISP to output 2 streams since it has been working that way in Android with the same hardware.

As per your suggestion, I’ll try to configure gstreamer pipeline and see if streams can be duplicated.

Regards,
Kamalnath

Thanks Loic.

With below command, able to get preview and encoding simultaneously.

gst-launch-1.0 -e v4l2src device=/dev/video3 ! video/x-raw,format=NV12,width=1920,height=1080,framerate=30/1 ! tee name=t ! queue ! v4l2h264enc ! filesink location=/home/linaro/enc.h264 t. ! queue ! videoconvert ! glimagesink

Regards,
Kamalnath