> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XAppCaptureReadLocalStream

> XAppCaptureReadLocalStream

# XAppCaptureReadLocalStream

이전에 [XAppCaptureRecordTimespan](/reference/system/xappcapture/functions/xappcapturerecordtimespan) 호출로 생성된 .mp4 파일의 내용을 읽습니다.

## 구문

```cpp theme={null}
HRESULT XAppCaptureReadLocalStream(
  XAppCaptureLocalStreamHandle handle,
  size_t startPosition,
  uint32_t bytesToRead,
  uint8_t * buffer,
  uint32_t * bytesWritten
)
```

### 매개 변수

*handle* \_In\_\
형식: XAppCaptureLocalStreamHandle

이전에 [XAppCaptureRecordTimespan](/reference/system/xappcapture/functions/xappcapturerecordtimespan)으로 생성된 로컬 녹화 파일에 대한 핸들입니다.

*startPosition* \_In\_\
형식: size\_t

스트림에서의 시작 위치입니다.

*bytesToRead* \_In\_\
형식: uint32\_t

읽을 바이트 수입니다.

*buffer* \_Out\_writes\_to\_(bytesToRead, \*bytesWritten)\
형식: uint8\_t \*

스트림 데이터를 쓸 버퍼입니다.

*bytesWritten* \_Out\_\
형식: uint32\_t \*

함수 완료 시 제공된 버퍼에 쓴 바이트 수를 포함합니다.

### 반환 값

형식: HRESULT

함수 결과입니다.

## 설명

동시에 최대 2개의 녹화가 존재할 수 있습니다. 스트림 종료 시 파일이 삭제됩니다. 게임이 종료되면 오래된 파일을 방지하기 위해 녹화가 자동으로 삭제됩니다.

[XAppCaptureLocalResult](/reference/system/xappcapture/structs/xappcapturelocalresult)를 얻는 방법은 [XAppCaptureRecordTimespan](/reference/system/xappcapture/functions/xappcapturerecordtimespan)을 참조하세요.

```cpp theme={null}
const int MAX_DATA = 1024;

XAppCaptureLocalResult localResult = {0};
XAppCaptureLocalStreamHandle localHandle = nullptr;
HANDLE file = INVALID_HANDLE_VALUE;

uint8_t buffer[MAX_DATA];
/* 5 seconds, for example. You should call XAppCaptureGetVideoCaptureSettings() to ensure there's sufficient duration available */
uint64_t durationInMs = 5000;
size_t totalBytesRead = 0;
size_t fileSize = 0;

XAppCaptureRecordTimespan(nullptr, durationInMs, &localResult);

localHandle = localResult.clipHandle;
fileSize = localResult.fileSizeInBytes;

/* T:\ is one example of a writeable local directory. Be aware that the T:\ drive can be invalidated on suspend or resume, and as such it's better to use PLS */ 
file = CreateFileA("T:\\MyFile.mp4", GENERIC_READ | GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);

while (totalBytesRead < fileSize)
{
    uint32_t bytesRead = 0;
    uint32_t bytesWritten = 0;
    if (SUCCEEDED(XAppCaptureReadLocalStream(localHandle, totalBytesRead, sizeof(buffer), buffer, &bytesRead)))
    {
        WriteFile(file, buffer, bytesRead, &bytesWritten, NULL);

        totalBytesRead += bytesRead;
    }
    else
    {
        break;
    }
}

/* You must always close a local stream handle even if nothing was read in */
XAppCaptureCloseLocalStream(localHandle);

```

## 요구 사항

**헤더:** XAppCapture.h

**라이브러리:** xgameruntime.lib

**지원되는 플랫폼:** Windows, XBOX One 제품군 콘솔 및 XBOX Series 콘솔

## 함께 보기

[XAppCapture 멤버](/reference/system/xappcapture/xappcapture_members)


## Related topics

- [XAppCaptureLocalResult](/ko/reference/system/xappcapture/structs/xappcapturelocalresult.md)
- [XAppCaptureRecordTimespan](/ko/reference/system/xappcapture/functions/xappcapturerecordtimespan.md)
- [XAppCapture](/ko/reference/system/xappcapture/xappcapture_members.md)
- [GDK용 Unity C# API 래퍼](/ko/build/gdk-and-engines/unity/unity-api-wrappers.md)
- [XAppCaptureReadScreenshotStream](/ko/reference/system/xappcapture/functions/xappcapturereadscreenshotstream.md)
