---
title: VideoRecording
slug: world-sdk-guide-kr/videorecording
docTags: 
createdAt: 2024-09-02T08:34:13.135Z
---

당신은 WorldVideoRecorder API의 비디오 관련 기능을 사용하여 월드 내에서 비디오를 저장하거나 공유할 수 있으며, 비디오를 사용하여 피드를 생성할 수 있습니다.

비디오 녹화 및 저장/공유/피드 게시 기능을 사용하려면 다음과 같이 import 문을 작성해야 합니다.

```typescript
import { WorldVideoRecorder } from 'ZEPETO.World';
```

WorldVideoRecorder API는 다음과 같은 비디오 관련 기능을 제공합니다.

| **API**                                                                                                                                                    | **설명**                                                                                                                                                                                                                                                      |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| WorldVideoRecorder.StartRecording(camera: UnityEngine.Camera, resolutions: VideoResolutions, durationSecond: number)\:boolean                              | 비디오 녹화를 시작합니다. 녹화 카메라, 비디오 해상도 및 녹화 시간을 매개변수로 설정할 수 있습니다. 반환 결과는 녹화 시작이 성공했는지 여부를 나타냅니다.<br /><br />- enum VideoResolutions \{ W1280xH720 = 0, W720xH1280 = 1, W1920xH1080 = 2, W1080xH1920 = 3 }<br />- durationSecond : 최대 값은 60이므로 가능하면 60 미만으로 입력해 주세요. |
| WorldVideoRecorder.StopRecording()                                                                                                                         | 진행 중인 비디오 녹화를 중지합니다.                                                                                                                                                                                                                                        |
| WorldVideoRecorder.IsRecording()\:boolean                                                                                                                  | 비디오 녹화를 진행 중인지 여부를 반환합니다.                                                                                                                                                                                                                                   |
| WorldVideoRecorder.SaveToCameraRoll(callback: System.Action$1)                                                                                             | 비디오를 사진 라이브러리에 저장합니다.                                                                                                                                                                                                                                       |
| WorldVideoRecorder.Share(callback: System.Action$1)                                                                                                        | 비디오를 외부 앱과 공유합니다.                                                                                                                                                                                                                                           |
| WorldVideoRecorder.CreateFeed(contents: string, $callback: System.Action$1)                                                                                | 비디오를 피드에 업로드합니다. 첫 번째 요소인 contents는 게시물의 내용을 지정할 수 있게 해줍니다.                                                                                                                                                                                                 |
| WorldVideoRecorder.AddVideoPlayerComponent(playerObject: UnityEngine.GameObject, renderTexture: UnityEngine.RenderTexture)\:UnityEngine\_Video.VideoPlayer | 비디오를 재생할 GameObject에 비디오 플레이어 구성 요소를 추가하고 녹화된 비디오 파일을 연결합니다. 이는 추가된 비디오 플레이어를 반환하며, 매개변수에 따라 비디오를 재생할 너비, 높이 또는 RenderTexture를 지정할 수 있습니다.                                                                                                                  |
| WorldVideoRecorder.GetThumbnail()\:UnityEngine.Texture2D;                                                                                                  | 녹화된 비디오의 썸네일을 반환합니다.                                                                                                                                                                                                                                        |

다음은 World Video Recorder 내에서 내 비디오 기능의 Save/Share/Feed 게시물 기능을 호출하는 예입니다.

:::hint{type="danger"}
- Unity 에디터 환경에서는 확인할 수 없지만, 앱을 통해 재생할 때는 확인할 수 있습니다.
- 해상도는 파일로 저장될 때 지정된 값으로 기록되지만, ZEPETO Feed에 업로드할 때 해상도가 변경될 수 있습니다.
- durationSecond에 60보다 큰 값을 입력하면 녹음이 제대로 작동하지 않습니다.
:::

```typescript
WorldVideoRecorder.SaveToCameraRoll(result => {console.log(`${result}`)});   

WorldVideoRecorder.Share(result => {console.log(`${result}`)});

WorldVideoRecorder.CreateFeed("[contents]", result => {console.log(`${result}`)});
```



다음은 RenderTexture를 사용하여 WorldVideoRecorder 내에서 내 비디오 녹화 기능의 함수를 사용하는 전체 예제 코드입니다.

```typescript
import { Camera, GameObject, RenderTexture } from 'UnityEngine';
import { Button, RawImage } from 'UnityEngine.UI';
import { ZepetoScriptBehaviour } from 'ZEPETO.Script';
import { VideoResolutions, WorldVideoRecorder } from 'ZEPETO.World';

export default class WorldVideoRecorderExample extends ZepetoScriptBehaviour {
    
    // WorldVideoRecorder Video UI 
    public startRecordingButton: Button;
    public stopRecordingButton: Button;
    public saveVideoButton: Button;
    public shareVideoButton: Button;
    public createFeedButton: Button;
    public getThumbnailButton: Button;
    public thumbnailImage: RawImage;

    // Recorder Camera 
    public recorderCamera: Camera;

    // Target Texture 
    public targetTexture: RenderTexture;

    // VideoPlayer Object 
    private videoPlayerObject: GameObject;

    Awake() {
        this.videoPlayerObject = new GameObject();
    }

    Start() {
        this.startRecordingButton.onClick.AddListener(() => {
            if (false == WorldVideoRecorder.StartRecording(this.recorderCamera, VideoResolutions.W1280xH720, 15)) {
                return;
            }

            this.StartCoroutine(this.CheckRecording());
        });

        this.stopRecordingButton.onClick.AddListener(() => {
            if (false == WorldVideoRecorder.IsRecording()) {
                return;
            }

            WorldVideoRecorder.StopRecording();
        });

        this.saveVideoButton.onClick.AddListener(() => {
            if (false == WorldVideoRecorder.IsRecording()) {
                WorldVideoRecorder.SaveToCameraRoll(result => { console.log(`${result}`) });
            }
        });

        this.shareVideoButton.onClick.AddListener(() => {
            if (false == WorldVideoRecorder.IsRecording()) {
                WorldVideoRecorder.Share(result => { console.log(`${result}`) });
            }
        });

        this.createFeedButton.onClick.AddListener(() => {
            if (false == WorldVideoRecorder.IsRecording()) {
                WorldVideoRecorder.CreateFeed("[contents]", result => { console.log(`${result}`) });
            }
        });

        this.getThumbnailButton.onClick.AddListener(() => {
            if (false == WorldVideoRecorder.IsRecording()) {
                this.thumbnailImage.texture = WorldVideoRecorder.GetThumbnail();
            }
        });
    }

    *CheckRecording() {
        while (WorldVideoRecorder.IsRecording()) {
            yield null;
        }

        let videoPlayer = WorldVideoRecorder.AddVideoPlayerComponent(this.videoPlayerObject, this.targetTexture);

        if (videoPlayer == null) {
            return;
        }
        
        videoPlayer.Play();
    }
}
```

스크립트를 작성한 후, 캔버스에 필요한 버튼과 원본 이미지를 생성합니다.

그 후, 검사기에서 각 구성 요소를 할당합니다.

- 카메라의 경우, 일반 카메라 컴포넌트를 사용할 수 있습니다.
- 타겟 텍스처의 경우, 생성 > 렌더 텍스처로 생성해 주세요.

::Image[]{src="https://api.archbee.com/api/optimize/fCt3n1oCa8rgNJ8fw9I2N-9Q1Nl9SoGPJfMgEClrJkV-20240904-102426.png" size="58" width="337" height="441" position="center" showCaption="false"}

:::hint{type="success"}
**👍 팁**

- 스크린샷과 동일한 렌더 텍스처를 사용하면 올바르게 렌더링되지 않을 수 있으므로, 녹화를 위해 새로운 렌더 텍스처를 생성하고 사용하세요.
:::



QR 모바일 빌드를 통해 비디오 녹화 기능을 테스트할 수 있습니다.

![](https://api.archbee.com/api/optimize/fCt3n1oCa8rgNJ8fw9I2N-_RN5L3ExW9fSNhlLPLc30-20240904-102426.png)

