Is there a way to record a webcam video?

I’m trying to get a video by putting the recorded video on the webcam device on the screen in Unity environment.
But it doesn’t work.
I tried using recorder in Unity, but this recorder only saved things such as game view, not the webcam video.
If you look at the link below that I attached, there is an API that can record a webcam and save it as a file separately, so wouldn’t it be okay to use it?
And I tried using this API, but it saved only a empty MP4 file.

And I tried second way about this.
https://forum.unity.com/threads/record-webcam-texture-in-unity-use-unity-to-record-webcam-view.1199284/
I want to solve the same problem as the question on this link, so I specified a render texture asset on Unity Recorder like this link and recorded it, but only the black screen is recorded. What should I do?
Additionally, I made and assigned a specific render texture in raw image and used this code as a Camera script.

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class CameraScript : MonoBehaviour
{
    int currentCamIndex = 0;

    WebCamTexture tex;

    public RawImage display;

    public Text startStopText;


    public void SwapCam_Clicked()
    {
        if (WebCamTexture.devices.Length > 0)
        {
            currentCamIndex += 1;
            currentCamIndex %= WebCamTexture.devices.Length;

            // if tex is not null:
            // stop the web cam
            // start the web cam

            if (tex != null)
            {
                StopWebCam();
                StartStopCam_Clicked();
            }
        }
    }

    public void StartStopCam_Clicked()
    {
        if (tex != null) // Stop the camera
        {
            StopWebCam();
            startStopText.text = "Start Camera";
        }
        else // Start the camera
        {
            WebCamDevice device = WebCamTexture.devices[currentCamIndex];
            tex = new WebCamTexture(device.name);
            display.texture = tex;

            tex.Play();
            startStopText.text = "Stop Camera";
        }
    }

    private void StopWebCam()
    {
        display.texture = null;
        tex.Stop();
        tex = null;
    }
}