AMF icon indicating copy to clipboard operation
AMF copied to clipboard

[Question]: Can be capture two monitor at the same time?

Open gang929 opened this issue 2 years ago • 5 comments

OS: Ubuntu 22.04.1 5.15.0-46 Display Adapter: AMD RX 470 Amd Driver: amdgpu-install_22.20.50200-1_all.deb

When the amf capture two monitor at the same time, the m_pDisplayCapture Init didn't return error, but could not get correct capture image, and had error message in journal log as bellow

0123-02-16 15:33:20 420E2640 [AMFScreenCaptureEngineImplDRM]   Error: ../../../../../runtime/src/components/ScreenCapture/drm/ScreenCaptureEngineDRM.cpp(857):Could not bind to socket - Address already in use

By trace code, it cause by the m_pDisplayCapture Init for the second monitor.

m_pDisplayCapture->Init(amf::AMF_SURFACE_UNKNOWN, 0, 0);

How to capture two monitor at the same time in one application?

gang929 avatar Mar 16 '23 07:03 gang929

I assume, you are trying to capture two monitors with two instances of AMF Capture component on Linux. It is not officially supported yet, though may just work. The error in the log can be ignored. Can you check cropping values on output surface - the same way as you did in the other issue submitted by you?

MikhailAMD avatar Mar 16 '23 15:03 MikhailAMD

the log for capture two monitors with two instances of AMF Capture component on Linux at same time.

LOG_WARNING("%d %dx%d", m_monitorID, pSurfPtr->GetPlane(amf::AMF_PLANE_UNKNOWN)->GetWidth(), pSurfPtr->GetPlane(amf::AMF_PLANE_UNKNOWN)->GetHeight());

0 1024x768
1 1024x768
0 1024x768
1 1024x768
0 1024x768
0 1024x768
1 1024x768

Before the second capture starting, the first capture image is OK, After the second capture started, the first capture image turns into a green blurred image, and the second capture image is always black.

gang929 avatar Mar 17 '23 00:03 gang929

If in your setup two capture components provide access to the same surface, you may want to use the first one before accessing the second one. Could you please elaborate what your app is doing: threading, consumption of captured surface, how do you verify the content of surface/corruption.

MikhailAMD avatar Mar 17 '23 13:03 MikhailAMD

The application implements a DesktopRecord class, it own a m_pDisplayCapture, a m_pEncoder, like AMF's DVR sample. when app starting, it create two thread, each thread create a DesktopRecord instance with a m_pDisplayCapture instance and m_pEncoder instance , then INIT and QueryOutput each other. It should not share any data or surface.

gang929 avatar Mar 18 '23 00:03 gang929

Can you try as an experiment to "Duplicate()" the captured surface before submitting to the encoder?

MikhailAMD avatar Apr 11 '23 16:04 MikhailAMD