Android에서 AR 세션 녹화 및 재생하기
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Recording & Playback API를 사용하면 지정된 환경 내에서 한 번 동영상과 AR 데이터를 녹화하고 이 콘텐츠를 사용하여 실시간 카메라 세션을 대체할 수 있습니다.
기본 요건
계속하기 전에 기본 AR 개념과 ARCore 세션을 구성하는 방법을 이해해야 합니다.
다른 ARCore API와의 호환성
세션 데이터가 처리되는 방식으로 인해 ARCore API는 재생 중에 녹화 중에 관찰된 것과 다른 결과를 생성할 수 있습니다. 후속 재생 세션 중에 다른 결과가 나올 수도 있습니다. 예를 들어 재생 중에 감지된 추적 가능한 물체의 수, 감지의 정확한 시점, 시간 경과에 따른 포즈가 다를 수 있습니다.
공유 카메라와의 호환성
공유 카메라를 사용하는 세션은 녹화할 수 있습니다. 하지만 현재 공유 카메라 모드를 사용하여 이 세션을 재생할 수는 없습니다.
Cloud Anchors와의 호환성
세션을 녹화하거나 재생하는 동안 클라우드 앵커를 호스팅하고 해결할 수 있습니다.
녹화
ARCore 세션 녹화를 시작, 중지, 확인합니다.
ARCore 세션 기록
ARCore 세션을 녹화하려면 세션을 구성하고 녹화할 MP4 URI를 제공합니다. 첫 번째 session.resume()
호출 전에 session.startRecording()
를 호출합니다. 세션이 재개되면 녹화가 자동으로 시작됩니다. 세션이 일시중지될 때 녹화를 자동으로 중지하려면 RecordingConfig.setAutoStopOnPause()
를 호출합니다. 부분 세션을 녹화하려면 세션이 실행되는 동안 session.startRecording()
를 호출합니다.
자바
// Configure the ARCore session.
Session session = new Session(context);
Uri destination = Uri.fromFile(new File(context.getFilesDir(), "recording.mp4"));
RecordingConfig recordingConfig =
new RecordingConfig(session)
.setMp4DatasetUri(destination)
.setAutoStopOnPause(true);
try {
// Prepare the session for recording, but do not start recording yet.
session.startRecording(recordingConfig);
} catch (RecordingFailedException e) {
Log.e(TAG, "Failed to start recording", e);
}
// Resume the ARCore session to start recording.
session.resume();
Kotlin
// Configure the ARCore session.
val session = Session(context)
val destination = Uri.fromFile(File(context.getFilesDir(), "recording.mp4"))
val recordingConfig = RecordingConfig(session)
.setMp4DatasetUri(destination)
.setAutoStopOnPause(true)
session.startRecording(recordingConfig)
// Resume the ARCore session to start recording.
session.resume()
세션 녹화 중지
현재 실행 중인 AR 세션을 일시중지하지 않고 녹화를 중지하려면 session.stopRecording()
를 호출합니다.
자바
try {
session.stopRecording(); // Stop recording.
} catch (RecordingFailedException e) {
Log.e(TAG, "Failed to stop recording", e);
}
Kotlin
session.stopRecording()
녹화 상태 확인
session.getRecordingStatus()
를 사용하여 언제든지 현재 RecordingStatus
를 확인할 수 있습니다.
자바
// Use any time to determine current RecordingStatus.
if (session.getRecordingStatus() == RecordingStatus.OK) {
// Update the UI to show that the session is currently being recorded.
}
Kotlin
// Use any time to determine current RecordingStatus.
if (session.recordingStatus == RecordingStatus.OK) {
// Update the UI to show that the session is currently being recorded.
}
재생
이전에 녹화된 AR 세션을 재생합니다. 세션은 실시간으로 재생되며 세션 재생이나 속도는 조정할 수 없습니다.
이전에 녹화된 세션 재생
이전에 녹음된 세션을 재생하려면 session.resume()
를 처음 호출하기 전에 session.setPlaybackDatasetUri()
를 호출합니다.
session.resume()
를 처음 호출하여 재생이 시작되면 session.pause()
를 호출하여 세션을 일시중지하면 데이터 세트의 모든 카메라 이미지 프레임과 기타 기록된 센서 데이터의 처리가 정지됩니다. 이러한 방식으로 삭제된 카메라 이미지 프레임과 센서 프레임 데이터는 session.resume()
를 호출하여 세션이 다시 재개될 때 다시 처리되지 않습니다. 일반적으로 처리된 데이터의 간격으로 인해 세션의 AR 추적에 문제가 발생합니다.
자바
// Configure the ARCore session.
Session session = new Session(context);
// Specify the previously recorded MP4 file.
Uri recordingUri = Uri.fromFile(new File(context.getFilesDir(), "recording.mp4"));
session.setPlaybackDatasetUri(recordingUri);
…
// Start playback from the beginning of the dataset.
session.resume();
…
// Pause the AR session, but silently continue MP4 playback. Camera frames
// and other recorded sensor data is discarded while the session is paused.
session.pause();
…
// Resume the AR session. Camera frames and other sensor data from the MP4
// that was silently played back while the session was paused is not
// processed by ARCore.
session.resume();
Kotlin
// Configure the ARCore session.
val session = Session(context)
// Specify the previously recorded MP4 file.
val recordingUri = Uri.fromFile(File(context.filesDir, "recording.mp4"))
session.playbackDatasetUri = recordingUri
…
// Start playback from the beginning of the dataset.
session.resume()
…
// Pause the AR session, but silently continue MP4 playback. Camera frames
// and other recorded sensor data is discarded while the session is paused.
session.pause()
…
// Resume the AR session. Camera frames and other sensor data from the MP4
// that was silently played back while the session was paused is not
// processed by ARCore.
session.resume()
처음부터 다시 재생
데이터 세트의 시작 부분에서 재생을 다시 시작하려면 세션을 일시중지하고 session.setPlaybackDatasetUri()
를 호출하여 세션을 재개하기 전에 동일한 MP4 녹화를 지정합니다.
자바
session.pause();
// Pause and specify the SAME dataset:
session.setPlaybackDatasetUri(previousRecordingUri);
session.resume(); // Playback starts from the BEGINNING of the dataset.
Kotlin
session.pause()
// Pause and specify the SAME dataset:
session.playbackDatasetUri = previousRecordingUri
session.resume() // Playback starts from the BEGINNING of the dataset.
다른 세션 재생
다른 데이터 세트를 재생하려면 세션을 일시중지하고 새 데이터 세트를 지정한 후 세션을 재개합니다.
자바
// Switch to a different dataset.
session.pause(); // Pause the playback of the first dataset.
// Specify a different dataset to use.
session.setPlaybackDatasetUri(newRecordingUri);
session.resume(); // Start playback from the beginning of the new dataset.
Kotlin
// Switch to a different dataset.
session.pause() // Pause the playback of the first dataset.
// Specify a different dataset to use.
session.playbackDatasetUri = newRecordingUri
session.resume() // Start playback from the beginning of the new dataset.
재생 상태 확인
언제든지 session.getPlaybackStatus()
를 사용하여 현재
PlaybackStatus
자바
// Use any time to determine current PlaybackStatus.
if (session.getPlaybackStatus() != PlaybackStatus.OK) {
// Update the UI to show that the session playback has finished.
}
Kotlin
// Use any time to determine current PlaybackStatus.
if (session.playbackStatus != PlaybackStatus.OK) {
// Update the UI to show that the session playback has finished.
}
다음 단계
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-26(UTC)
[null,null,["최종 업데이트: 2025-07-26(UTC)"],[[["\u003cp\u003eThe Recording & Playback API allows you to record video and AR data from an environment and reuse it to replace a live camera feed in subsequent sessions.\u003c/p\u003e\n"],["\u003cp\u003eARCore APIs may produce slightly different results during playback compared to live sessions due to data processing differences.\u003c/p\u003e\n"],["\u003cp\u003eYou can record and playback AR sessions, including those with Cloud Anchors, by configuring the session and providing an MP4 URI.\u003c/p\u003e\n"],["\u003cp\u003ePlayback sessions run in real-time and cannot be adjusted, but you can pause, resume, and restart them, or switch to a different recorded session.\u003c/p\u003e\n"],["\u003cp\u003eWhile Shared Camera sessions can be recorded, playback using Shared Camera mode is not currently supported.\u003c/p\u003e\n"]]],["The Recording & Playback API allows recording video and AR data into an MP4 URI, which can then replace a live camera session. To record, configure the session, provide the MP4 URI, and call `session.startRecording()` before `session.resume()`. Recording can be stopped via `session.stopRecording()`. Playback uses a recorded session via `session.setPlaybackDatasetUri()` before resuming. Pausing during playback discards camera frames and sensor data. Restart or switch playback sessions by pausing and setting the dataset URI again. You can check recording and playback statuses using `getRecordingStatus()` and `getPlaybackStatus()`, respectively.\n"],null,["# Record and play back an AR session on Android\n\nThe Recording \\& Playback API enables you to record video and AR data once within a given environment and use that content to replace a live camera session.\n\nPrerequisites\n-------------\n\nMake sure that you understand [fundamental AR concepts](/ar/develop/fundamentals)\nand how to [configure an ARCore session](/ar/develop/java/session-config) before proceeding.\n\nCompatibility with other ARCore APIs\n------------------------------------\n\nDue to the way session data is processed, ARCore APIs may produce different results during playback than observed during recording. They may also produce different results during subsequent playback sessions. For example, the number of detected trackables, the precise timing of their detection, and their poses over time may be different during playback.\n\n### Compatibility with Shared Camera\n\nSessions that use [Shared Camera](/ar/develop/java/camera-sharing) can be recorded. However, playback for these sessions using Shared Camera mode is currently unavailable.\n\n### Compatibility with Cloud Anchors\n\nYou can host and resolve [Cloud Anchors](/ar/develop/java/cloud-anchors/overview-android) while recording or playing back a session.\n\nRecording\n---------\n\nStart, stop, and check the status of an ARCore session recording.\n\n### Record an ARCore session\n\nTo record an ARCore session, configure the session and provide an MP4 URI for the recording. Call [`session.startRecording()`](/ar/reference/java/com/google/ar/core/Session#startRecording-recordingConfig) before the first call to [`session.resume()`](/ar/reference/java/com/google/ar/core/Session#resume-). Recording automatically starts when the session resumes. To automatically stop recording when the session is paused, call [`RecordingConfig.setAutoStopOnPause()`](/ar/reference/java/com/google/ar/core/RecordingConfig#getAutoStopOnPause()). To record a partial session, call [`session.startRecording()`](/ar/reference/java/com/google/ar/core/Session#startRecording-recordingConfig) while the session is running. \n\n### Java\n\n // Configure the ARCore session.\n Session session = new Session(context);\n Uri destination = Uri.fromFile(new File(context.getFilesDir(), \"recording.mp4\"));\n RecordingConfig recordingConfig =\n new RecordingConfig(session)\n .setMp4DatasetUri(destination)\n .setAutoStopOnPause(true);\n try {\n // Prepare the session for recording, but do not start recording yet.\n session.startRecording(recordingConfig);\n } catch (RecordingFailedException e) {\n Log.e(TAG, \"Failed to start recording\", e);\n }\n\n // Resume the ARCore session to start recording.\n session.resume();\n\n### Kotlin\n\n // Configure the ARCore session.\n val session = Session(context)\n val destination = Uri.fromFile(File(context.getFilesDir(), \"recording.mp4\"))\n val recordingConfig = RecordingConfig(session)\n .setMp4DatasetUri(destination)\n .setAutoStopOnPause(true)\n session.startRecording(recordingConfig)\n\n // Resume the ARCore session to start recording.\n session.resume()\n\n### Stop a session recording\n\nTo stop recording without pausing the currently running AR session, call [`session.stopRecording()`](/ar/reference/java/com/google/ar/core/Session#stopRecording-). \n\n### Java\n\n try {\n session.stopRecording(); // Stop recording.\n } catch (RecordingFailedException e) {\n Log.e(TAG, \"Failed to stop recording\", e);\n }\n\n### Kotlin\n\n session.stopRecording()\n\n### Check recording status\n\n[`session.getRecordingStatus()`](/ar/reference/java/com/google/ar/core/Session#getRecordingStatus-)\ncan be used at any time to determine the current [`RecordingStatus`](/ar/reference/java/com/google/ar/core/RecordingStatus). \n\n### Java\n\n // Use any time to determine current RecordingStatus.\n if (session.getRecordingStatus() == RecordingStatus.OK) {\n // Update the UI to show that the session is currently being recorded.\n }\n\n### Kotlin\n\n // Use any time to determine current RecordingStatus.\n if (session.recordingStatus == RecordingStatus.OK) {\n // Update the UI to show that the session is currently being recorded.\n }\n\nPlayback\n--------\n\nPlay back previously recorded AR sessions. Sessions play back in real time, and session playback or speed cannot be adjusted.\n\n### Play back a previously recorded session\n\nTo play back a previously recorded session, call [`session.setPlaybackDatasetUri()`](/ar/reference/java/com/google/ar/core/Session#setPlaybackDatasetUri-mp4DatasetUri) before the first call to [`session.resume()`](/ar/reference/java/com/google/ar/core/Session#resume()).\n\nOnce playback has started due to the first call to [`session.resume()`](/ar/reference/java/com/google/ar/core/Session#resume()), pausing the session by calling [`session.pause()`](/ar/reference/java/com/google/ar/core/Session#pause()) will suspend processing of all camera image frames and any other recorded sensor data in the dataset. Camera image frames and sensor frame data that is discarded in this way will not be reprocessed when the session is again resumed by calling [`session.resume()`](/ar/reference/java/com/google/ar/core/Session#resume()). AR tracking for the session will generally suffer due to the gap in processed data. \n\n### Java\n\n // Configure the ARCore session.\n Session session = new Session(context);\n\n // Specify the previously recorded MP4 file.\n Uri recordingUri = Uri.fromFile(new File(context.getFilesDir(), \"recording.mp4\"));\n session.setPlaybackDatasetUri(recordingUri);\n ...\n\n // Start playback from the beginning of the dataset.\n session.resume();\n ...\n\n // Pause the AR session, but silently continue MP4 playback. Camera frames\n // and other recorded sensor data is discarded while the session is paused.\n session.pause();\n ...\n\n // Resume the AR session. Camera frames and other sensor data from the MP4\n // that was silently played back while the session was paused is not\n // processed by ARCore.\n session.resume();\n\n### Kotlin\n\n // Configure the ARCore session.\n val session = Session(context)\n\n // Specify the previously recorded MP4 file.\n val recordingUri = Uri.fromFile(File(context.filesDir, \"recording.mp4\"))\n session.playbackDatasetUri = recordingUri\n ...\n\n // Start playback from the beginning of the dataset.\n session.resume()\n ...\n\n // Pause the AR session, but silently continue MP4 playback. Camera frames\n // and other recorded sensor data is discarded while the session is paused.\n session.pause()\n ...\n\n // Resume the AR session. Camera frames and other sensor data from the MP4\n // that was silently played back while the session was paused is not\n // processed by ARCore.\n session.resume()\n\n### Restart playback from the beginning\n\nTo restart a playback from the beginning of the dataset, pause the session and call [`session.setPlaybackDatasetUri()`](/ar/reference/java/com/google/ar/core/Session#setPlaybackDatasetUri-mp4DatasetUri), specifying the same MP4 recording before resuming the session. \n\n### Java\n\n session.pause();\n // Pause and specify the SAME dataset:\n session.setPlaybackDatasetUri(previousRecordingUri);\n session.resume(); // Playback starts from the BEGINNING of the dataset.\n\n### Kotlin\n\n session.pause()\n // Pause and specify the SAME dataset:\n session.playbackDatasetUri = previousRecordingUri\n session.resume() // Playback starts from the BEGINNING of the dataset.\n\n### Play back a different session\n\nTo play back a different dataset, pause the session and specify the new dataset before resuming the session. \n\n### Java\n\n // Switch to a different dataset.\n session.pause(); // Pause the playback of the first dataset.\n // Specify a different dataset to use.\n session.setPlaybackDatasetUri(newRecordingUri);\n session.resume(); // Start playback from the beginning of the new dataset.\n\n### Kotlin\n\n // Switch to a different dataset.\n session.pause() // Pause the playback of the first dataset.\n // Specify a different dataset to use.\n session.playbackDatasetUri = newRecordingUri\n session.resume() // Start playback from the beginning of the new dataset.\n\n### Check playback status\n\nUse [`session.getPlaybackStatus()`](/ar/reference/java/com/google/ar/core/Session#getPlaybackStatus-) at any time to determine the current\n[`PlaybackStatus`](/ar/reference/java/com/google/ar/core/PlaybackStatus). \n\n### Java\n\n // Use any time to determine current PlaybackStatus.\n if (session.getPlaybackStatus() != PlaybackStatus.OK) {\n // Update the UI to show that the session playback has finished.\n }\n\n### Kotlin\n\n // Use any time to determine current PlaybackStatus.\n if (session.playbackStatus != PlaybackStatus.OK) {\n // Update the UI to show that the session playback has finished.\n }\n\nWhat's next\n-----------\n\n- Learn how to [add custom data](/ar/develop/java/recording-and-playback/custom-data-track) to recorded sessions.\n- Try the [Introduction to the ARCore Recording and Playback API](https://codelabs.developers.google.com/codelabs/arcore-record-and-playback-intro) codelab."]]