Skip to content

Media SDK API Reference ​

The Media SDK (sdk-media) provides playback, export, image stitching, and live preview rendering for media captured by Insta360 cameras. This document lists the interface definitions and parameters of all public APIs.


Contents ​

  1. Media File Management
  2. Image Stitching
  3. Media Export
  4. Players
  5. Player Parameters
  6. Player Listeners
  7. Rendering Configuration and Enums
  8. Shared Data Types

1. Media File Management ​

WorkManager ​

The singleton entry point for media file listings; implements WorkOperations.

kotlin
object WorkManager : WorkOperations

WorkOperations ​

kotlin
interface WorkOperations
MethodStyleDescription
getAllCameraWorks(): Result<List<WorkWrapper>>CoroutineList all media files on the camera
getAllLocalWorks(): List<WorkWrapper>SynchronousList all local media files

IWorkWrapper ​

Wraps a single capture result, exposing its metadata, type checks, and file operations.

kotlin
interface IWorkWrapper

URL properties

PropertyDescription
allUrls: Array<String>URLs of every related file (including LRV)
mainUrls: Array<String>URLs of the main (full-resolution) files
rawUrls: Array<String>URLs of the RAW files
lrvUrls: Array<String>URLs of the low-resolution preview (LRV) files

Metadata

MethodParametersDescription
getCount()—Number of file segments (greater than 1 for multi-segment video)
getIdenticalKey(index)index defaults to 0Unique file identifier key
getWidth(index) / getHeight(index)index defaults to 0Resolution (pixels)
getBitrate(index)index defaults to 0Bitrate (bps)
getFps(index)index defaults to 0Frame rate
getCreationTime(index)index defaults to 0Creation time (millisecond timestamp)
getFirstFrameTimeOffset(index)index defaults to 0First-frame time offset (milliseconds)
getRollingShutterTime(index)index defaults to 0Rolling shutter time (seconds)
getDurationInMs(index)index defaults to 0Duration of one segment (milliseconds)
getTotalDurationInMs()—Total duration of all segments (milliseconds)
getFileSize()—Total file size (bytes)
getCameraType()—Model name of the capturing camera
loadThumbnail(index)index defaults to 0Load the thumbnail; returns null on failure
loadExtraData(index)index defaults to 0Load extra metadata such as gyroscope and exposure data
isExtraDataLoaded(index)index defaults to 0Whether the extra metadata has been loaded
getGyroData()—Gyroscope data array; see GyroData
getExposureData()—Exposure data array; see ExposureData

File type checks

MethodDescription
isCameraFile()Stored on the camera (not yet downloaded)
isLocalFile()Local file
isPanoramaFile()Panoramic file
isVideo() / isPhoto()Video / photo
isHDRVideo() / isHDRPhoto()HDR video / photo
isBulletTime()Bullet Time
isBurst()Burst
isTimeLapse()TimeLapse
isTimeShift()TimeShift
isNormalPhoto() / isNormalVideo()Regular photo / video
isSuperNight()Super Night
isStarLapse()Starlapse
isLooperVideo()Loop recording
isSuperVideo()Super Video
isIntervalShooting()Interval shooting
isSelfieVideo()Selfie video
isSlowMotion()Slow motion
isPureVideo()PureVideo
supportHdrGenerate()Whether HDR compositing is supported
supportPureShotGenerate()Whether PureShot compositing is supported

File operations

MethodStyleDescription
download(progressCallback?)CoroutineDownload to local storage; returns the local paths. progressCallback receives (total size, downloaded size)
delete()CoroutineDelete this file from the camera

WorkWrapper ​

The abstract base class of IWorkWrapper; subclasses provide concrete implementations depending on the file's source (camera or local).

kotlin
abstract class WorkWrapper(
    val httpPrefix: String = "",
    val downloadHttpPrefix: String = httpPrefix
) : IWorkWrapper, Comparable<WorkWrapper>
PropertyDescription
httpPrefixThe file server's HTTP prefix (used for camera files). Over Wi-Fi Aware this is a bare IPv6 address
downloadHttpPrefixThe prefix the SDK should use when downloading assets. Over Wi-Fi Aware this is a placeholder hostname (resolved through dynamic DNS) so that OkHttp does not reject the zone-id syntax of a bare IPv6 address; for all other connection types it matches httpPrefix

GyroData ​

Gyroscope data for a single frame.

kotlin
data class GyroData(
    val accelerateX: Double, val accelerateY: Double, val accelerateZ: Double,
    val rotationX: Double, val rotationY: Double, val rotationZ: Double,
    val timestamp: Long
)
PropertyDescription
accelerateX/Y/ZThree-axis acceleration (m/s²)
rotationX/Y/ZThree-axis angular velocity (rad/s)
timestampTimestamp (milliseconds)

ExposureData ​

Exposure data for a single frame.

kotlin
data class ExposureData(val shutterSpeeds: Double, val timestamp: Long)
PropertyDescription
shutterSpeedsShutter speed (seconds)
timestampTimestamp (milliseconds)

2. Image Stitching ​

StitchManager ​

The singleton entry point for stitching; implements Stitcher.

kotlin
object StitchManager : Stitcher

Stitcher ​

kotlin
interface Stitcher
MethodDescription
stitchSeparatedFisheye(workWrapper, outputFilePath): Result<Unit>Detect the contents of the WorkWrapper automatically and stitch the fisheye images
stitchSeparatedFisheye(templateBlenderParams): Result<Unit>Stitch two fisheye images into a panorama
generateHDR(workWrapper, outputFilePath): Result<Unit>HDR compositing
generatePureShot(workWrapper, outputFilePath, algoFolderPath): Result<Unit>PureShot compositing

TemplateBlenderParams ​

Configuration for stitching fisheye images.

kotlin
class TemplateBlenderParams(
    val inputFilePath1: String,   // Path of the first fisheye image
    val inputFilePath2: String,   // Path of the second fisheye image
    val outputFilePath: String,   // Output file path
)
PropertyTypeDefaultDescription
isColorAdjustmentBooleanfalseEnable color correction
blendAngleFloat8fBlend region angle (degrees)
mapSizeWidthInt200Mapping texture width
mapSizeHeightInt100Mapping texture height
fisheyeArrangementFisheyeArrangementSEPERATEDFisheye image arrangement

FisheyeArrangement ​

ValueDescription
CONNECTEDHorizontally joined (side by side)
VCONNECTEDVertically joined (stacked)
SEPERATEDSeparated (two independent images)

3. Media Export ​

ExporterManager ​

The singleton entry point for export; implements Exporter.

kotlin
object ExporterManager : Exporter

Exporter ​

kotlin
interface Exporter
MethodDescription
exportImage(imageExportParams, callback)Export an image
exportVideo(videoExportParams, callback)Export a video
exportVideoToImage(imageExportParams, callback)Extract frames from a video and export them as images
stopExport(exportId: Int)Cancel the given export task (exportId comes from IExportCallback.onStart)

IExportCallback ​

Callback interface for export tasks.

kotlin
interface IExportCallback
CallbackParametersDescription
onStart(id: Int)id: task IDExport started; use the ID to cancel the task
onSuccess()—Export succeeded
onFail(throwable: Throwable)throwable: failure causeExport failed
onCancel()—Export was cancelled
onProgress(progress: Float)progress: 0.0–1.0Export progress (empty default implementation)

ExportParams ​

The base class for export parameters; every export parameter class extends it.

kotlin
open class ExportParams(workWrapper: WorkWrapper) : MediaParams(workWrapper)
PropertyTypeDefaultDescription
exportModeExportModePANORAMAExport projection mode
targetPathString?nullOutput path; null uses the default path
isUseSoftwareDecoderBooleanfalseUse the software decoder
width / heightInt-1Output resolution (-1 means default)
isDenoiseBooleanfalseDenoising toggle
distanceFloat0fViewing distance
fovFloat0fField of view (degrees)
yaw / pitchFloat0fYaw / pitch (degrees)

For the properties inherited from MediaParams, see §5 MediaParams.


VideoExportParams ​

Video export parameters.

kotlin
class VideoExportParams(workWrapper: WorkWrapper) : ExportParams(workWrapper)
PropertyTypeDefaultDescription
isUseSoftwareEncoderBooleanfalseUse the software encoder (hardware by default)
bitrateInt-1Target bitrate (bps; -1 uses the default)
fpsInt-1Target frame rate (-1 uses the default)
rollFloat0fImage roll angle (degrees)

ImageExportParams ​

Image export parameters.

kotlin
class ImageExportParams(workWrapper: WorkWrapper) : ExportParams(workWrapper)
PropertyTypeDefaultDescription
indexInt0Index of the frame to export
timestampListList<Double>emptyTimestamps (seconds) of the frames to export; takes precedence over index when not empty

4. Players ​

Player hierarchy ​

BasePlayer
├── VideoPlayer  (: StreamPlayer, BasePlayer, LocalPlayer)
├── ImagePlayer  (: BasePlayer, LocalPlayer)
└── PreviewPlayer (: StreamPlayer, BasePlayer)

StreamPlayer   — pause / resume / isPlaying
LocalPlayer    — marker interface indicating local file playback support

BasePlayer ​

The base interface for every player.

kotlin
interface BasePlayer

Playback control

MethodDescription
play()Start playback
isLoading(): BooleanWhether the player is loading
isPrepared(): BooleanWhether preparation has completed
destroy()Destroy the player and release all resources

Gesture control

MethodDescription
setGestureEnabled(enabled)Master switch for gesture interaction
isGestureEnabled(): BooleanGet the master gesture switch state
setGestureHorizontalEnabled(enabled)Horizontal gestures (rotate the view left/right)
setGestureVerticalEnabled(enabled)Vertical gestures (rotate the view up/down)
setGestureZoomEnabled(enabled)Zoom gesture (pinch)
setGestureListener(listener: PlayerGestureListener?)Set the gesture event listener

Lens modes

MethodDescription
switchNormalMode()Normal (flat) mode
switchFisheyeMode()Fisheye mode
switchPerspectiveMode()Perspective mode

View control

MethodDescription
setConstraint(widthRatio, heightRatio, minFov, maxFov, defaultFov, minDistance, maxDistance, defaultDistance)Set the view constraints
getFov(): FloatCurrent field of view (degrees)
getDistance(): FloatCurrent viewing distance
getYaw(): FloatYaw (radians)
getPitch(): FloatPitch (radians)
getRoll(): FloatRoll (radians)

Rendering settings

MethodDescription
setScreenRatio(ratioX, ratioY)Set the render view's aspect ratio
getScreenRatio(): Pair<Int, Int>Get the current aspect ratio
setStabType(type: StabType)Set the stabilization type
getStabType(): StabTypeGet the current stabilization type
setOffsetType(type: OffsetType)Set the lens offset type (lens guard, dive case, and other accessories)
getOffsetType(): OffsetTypeGet the current offset type
setColorFusionEnabled(enabled)Color fusion (chromatic aberration removal) toggle
isColorFusionEnabled(): BooleanWhether color fusion is enabled
setDynamicStitchEnabled(enabled)Dynamic stitching toggle
isDynamicStitchEnabled(): BooleanWhether dynamic stitching is enabled
setColorPlusEnabled(enabled)Color Plus toggle
isColorPlusEnabled(): BooleanWhether Color Plus is enabled
setColorPlusFilterIntensity(intensity)Color Plus intensity (0.0–1.0)
getColorPlusFilterIntensity(): FloatGet the Color Plus intensity
setDePurpleFilterEnable(enabled)Purple-fringe removal filter toggle
getDePurpleFilterEnable(): BooleanWhether the purple-fringe removal filter is enabled
setListener(listener: PlayerViewListener?)Set the player view event listener

StreamPlayer ​

The common interface for streaming players (implemented by both the video player and the preview player).

kotlin
interface StreamPlayer
MethodDescription
pause()Pause playback
resume()Resume playback
isPlaying(): BooleanWhether playback is in progress

VideoPlayer ​

The video player; extends StreamPlayer + BasePlayer with seeking, looping, and related capabilities.

kotlin
interface VideoPlayer : StreamPlayer, BasePlayer, LocalPlayer
MethodDescription
prepare(params: VideoPlayerParams)Initialize and prepare the video player
setVideoStatusListener(listener: VideoStatusListener?)Set the playback status listener
seekTo(position: Long)Seek to the given position (milliseconds)
isSeeking(): BooleanWhether a seek is in progress
getCurrentPosition(): LongCurrent playback position (milliseconds)
getDuration(): LongTotal video duration (milliseconds)
isLooping(): BooleanWhether looping is enabled
setLooping(isLooping: Boolean)Enable or disable looping
setVolume(volume: Float)Set the volume (0.0–1.0)
setLrvEnable(enabled: Boolean)Enable the low-resolution preview (LRV)
isLrvEnable(): BooleanWhether LRV is enabled

ImagePlayer ​

The panoramic photo player.

kotlin
interface ImagePlayer : BasePlayer, LocalPlayer
MethodDescription
prepare(params: ImagePlayerParams)Initialize and prepare the image player

PreviewPlayer ​

The camera live preview player; extends StreamPlayer + BasePlayer with preview stream integration, resolution settings, and related capabilities.

kotlin
interface PreviewPlayer : StreamPlayer, BasePlayer
MethodDescription
prepare(params: PreviewParams)Initialize and prepare the preview player
destroyRender()Destroy the renderer (required before restarting the player)
setPreviewResolution(width, height)Set the preview resolution
setFps(fps: Int)Set the preview frame rate
getPreviewWidth(): Int / getPreviewHeight(): IntCurrent preview resolution
getFps(): IntCurrent preview frame rate
setOffset(offsetData, stabOffset)Update the lens offset and stabilization offset
setWindowCropInfo(cropInfo: WindowCropInfo)Set the window crop information
getWindowCropInfo(): WindowCropInfo?Get the current window crop information
showPlayView() / hidePlayView()Show / hide the playback view
getPipeline(): KMPCameraPreviewPipeline?Get the current rendering pipeline
updateRotate(rotateDegreeContent, rotateDegree, cameraPosture, cameraPostureCorrected)Update the image rotation
redetectCameraRotation()Re-detect the camera's rotation

5. Player Parameters ​

MediaParams ​

The common base class for every media parameter class.

kotlin
open class MediaParams(val workWrapper: WorkWrapper)
PropertyTypeDefaultDescription
isDePurpleFilterOnBooleanfalsePurple-fringe removal
isColorFusionBooleanfalseChromatic aberration removal
isDynamicStitchBooleantrueDynamic stitching
stabTypeStabTypeAUTOStabilization type
offsetTypeOffsetTypeORIGINALLens offset type
screenRatioIntArray[-1, -1]Aspect ratio (-1 means unconstrained)
colorPlusEnableBooleanfalseColor Plus
colorPlusFilterIntensityFloat1.0fColor Plus intensity
urlForActionString""The URL to play or export

PlayerParams ​

Common player parameters; extends MediaParams.

kotlin
open class PlayerParams(workWrapper: WorkWrapper) : MediaParams(workWrapper)
PropertyTypeDefaultDescription
renderModelRenderModelAUTORendering mode
isGestureEnabledBooleantrueMaster switch for gesture interaction
isGestureHorizontalEnabledBooleantrueHorizontal gestures
isGestureVerticalEnabledBooleantrueVertical gestures
isGestureZoomEnabledBooleantrueZoom gesture
isWithSwitchingAnimationBooleanfalseAnimate lens mode switches

VideoPlayerParams ​

Video player parameters; extends PlayerParams.

kotlin
class VideoPlayerParams(workWrapper: WorkWrapper) : PlayerParams(workWrapper)
PropertyTypeDefaultDescription
loadingImageResIdInt-1Resource ID of the loading placeholder image (-1 means none)
loadingBackgroundColorIntblackLoading background color (ARGB)
isAutoPlayAfterPreparedBooleantruePlay automatically once prepared
isLoopingBooleantrueLoop playback
isLrvEnableBooleanfalseEnable the low-resolution preview (LRV)
isVideoHwaccelEnabledBooleantrueEnable hardware-accelerated video decoding

ImagePlayerParams ​

Image player parameters; extends PlayerParams.

kotlin
class ImagePlayerParams(workWrapper: WorkWrapper) : PlayerParams(workWrapper)
PropertyTypeDefaultDescription
indexInt0Index of the image frame to display

PreviewParams ​

Camera preview player parameters.

kotlin
data class PreviewParams(...)
PropertyTypeDefaultDescription
width / heightInt-1Preview resolution (-1 uses the default)
fpsInt-1Preview frame rate
screenRatioPair<Int, Int>-1 to -1Render view aspect ratio
stabTypeStabType?nullStabilization type
isGestureEnabledBooleantrueGesture interaction toggle
isCopyVideoHwaccelBooleantrueHardware-accelerated frame copying
isVideoHwaccelEnabledBooleantrueEnable hardware-accelerated video decoding
isColorFusionBooleantrueColor fusion (chromatic aberration removal)
stabCacheFrameNumInt-1Number of frames cached for stabilization
isOnlyStitchSurfaceRenderBooleanfalseRender only to the specified Surface
renderModelRenderModel?nullRendering mode
isRenderAtOnceBooleanfalseStart rendering immediately (do not wait for the first frame)
cameraRenderSurfaceKMPSurface?nullThe target render Surface
cameraRenderSurfaceWidth / HeightInt-1Dimensions of that Surface

6. Player Listeners ​

VideoStatusListener ​

Video playback status callbacks, set via VideoPlayer.setVideoStatusListener().

kotlin
interface VideoStatusListener
CallbackParametersDescription
onProgressChanged(position, length)millisecondsPlayback progress changed
onPlayStateChanged(isPlaying)—Play / pause state changed
onSeekComplete()—The seek finished
onComplete()—Playback finished
onPlayingFluencyResult(fluentFactor, srcTime, detectTime)fluentFactor: Double, srcTime: Double, detectTime: DoublePlayback smoothness measurement, taken once per second. fluentFactor is a smoothness coefficient in [0,1] — [0.65,1] counts as smooth, and -1 means the measurement failed. Empty default implementation

PlayerViewListener ​

Player view event callbacks, set via BasePlayer.setListener().

kotlin
interface PlayerViewListener
CallbackParametersDescription
onLoadingStatusChanged(isLoading)isLoading: whether loading is in progressLoading state changed
onLoadingFinish()—Loading finished
onFail(exception: InstaException)exception: error detailsAn error occurred
onFirstFrameRendered()—The first frame has been rendered
onReleaseCameraPipeline()—The camera preview pipeline was released

PlayerGestureListener ​

Player gesture event callbacks, set via BasePlayer.setGestureListener(). Every method has an empty default implementation; override only what you need.

kotlin
interface PlayerGestureListener
CallbackDescription
onDown(event): BooleanFinger down; return true to consume the event
onTap(event): BooleanTap; return true to consume the event
onUp()Finger up
onLongPress(event)Long press
onZoom()Zoom gesture started
onZoomAnimation()Zoom animation in progress
onZoomAnimationEnd()Zoom animation finished
onScroll()Scroll gesture
onFlingAnimation()Fling animation in progress
onFlingAnimationEnd()Fling animation finished

7. Rendering Configuration and Enums ​

ExportMode ​

ValueDescription
PANORAMAFlat panoramic projection (equirectangular)
SPHERESpherical projection

OffsetType ​

Specifies which accessory is mounted on the camera so the matching lens distortion correction parameters are applied.

ValueDescription
ORIGINALNo accessory; use the original offset
PROTECTOR_FASTENSnap-on lens guard
DIVING_WATERDive case, underwater (legacy)
DIVING_AIRDive case, above water (legacy)
WATERPROOFWaterproof case
PROTECTOR_ADHEREAdhesive lens guard
DIVING_INVISIBLE_WATERInvisible dive case, underwater
DIVING_INVISIBLE_AIRInvisible dive case, above water
PROTECTOR_AGrade A lens guard (plastic, X3/X4)
PROTECTOR_SGrade S lens guard (glass, X3/X4)
PROTECTOR_AS_AVERAGEAveraged A/S lens guard (virtual combined parameters)

StabType ​

ValueDescription
AUTOAutomatically choose the best stabilization algorithm
PANORAMAPanoramic stabilization
CALIBRATE_HORIZONHorizon leveling stabilization
FOOTAGE_MOTION_SMOOTHMotion smoothing stabilization

StabilizerStabMode ​

ValuerawValueDescription
Off-1Stabilization off
Still0Fixed stabilization
ZDirectional1Z-axis stabilization
FullDirectional2Omnidirectional stabilization
FreeFootage4Free-motion stabilization
FlipEffect22Flip effect
RelativeRefine8Relative fine stabilization
AbsoluteRefine9Absolute fine stabilization
BulletTime5Bullet Time
PanoFPV23Panoramic FPV
Immersion24Immersive mode

RenderModel ​

ValuenativeValueDescription
AUTO0Automatically fuse the two video streams
PLANE_STITCH11Flat stitching (dual-lens fusion, laid flat)
PLANE20Split plane (fisheye split-screen display)

DisplayType ​

ValuerawValueDescription
Auto0Automatic
SphereStitch2Spherical stitching
SphereEquirectangular3Spherical equirectangular
SphereFisheyeDewarp4Spherical fisheye dewarping
PlaneStitch11Flat stitching
PlaneEquirectangular12Flat equirectangular
PlaneFisheyeDewarp13Flat fisheye dewarping
Plane20Plain flat
(and others)—See DisplayType.kt in the source for the full list

OpticalFlowType ​

ValuerawValueDescription
DynamicStitch0Dynamic stitching
Disflow1Disflow optical flow algorithm
AiFlow2AI optical flow algorithm

ImageLayout ​

ValuerawValueDescription
HorizontalMerged0Horizontally merged
OneBulletTime1Single Bullet Time frame
Respective2Images2Two independent images (default)
LeftHalf / RightHalf3 / 4Left half / right half
TopHalf / BottomHalf5 / 6Top half / bottom half
LeftRight7Left-right split
TopBottom8Top-bottom split

ProtectOffsetConvertOption ​

A bit-flag enum that specifies the lens guard or accessory type; values can be combined with a bitwise OR.

ValueDescription
NoneNo accessory
EnableWaterProofWaterproof case
EnableDivingAir / EnableDivingWaterDive case (legacy, above water / underwater)
EnableDivingAirV2 / EnableDivingWaterV2Dive case (new, above water / underwater)
EnableBuckleShellSnap-on protective shell
EnableAdhesiveShellAdhesive protective shell
EnableGlassShellGlass protective shell
EnablePlasticCementPlastic protective shell
EnableAverageShellAveraged protective shell
EnableNDFilterND filter
EnableDivingWaterPro / EnableDivingAirProDive case Pro

StabilizerParam ​

kotlin
data class StabilizerParam(
    val offset: String,
    val preferredStabMode: StabilizerStabMode
)
PropertyDescription
offsetLens offset string used in stabilization calculations
preferredStabModePreferred stabilization mode

RenderModelParam ​

Combined configuration for rendering behavior.

kotlin
data class RenderModelParam(
    val imageLayout: ImageLayout = ImageLayout.Respective2Images,
    val renderType: DisplayType = DisplayType.PlaneStitch,
    val stabMode: StabilizerStabMode = StabilizerStabMode.Still,
    val offset: String,
    val colorFusion: Boolean
)

RenderView ​

kotlin
data class RenderView(val width: Int, val height: Int)

Render view dimensions (pixels).


VideoClipInfo ​

Specifies a video's source and playback range. Provide either inputUrl or wrapper; when both are set, wrapper wins.

kotlin
data class VideoClipInfo(
    val inputUrl: String?,     // File path (file:/// or absolute); alternative to wrapper
    val wrapper: WorkWrapper?, // Takes precedence over inputUrl
    val startTimeMs: Int,      // Start position (milliseconds)
    val endTimeMs: Int         // End position (milliseconds)
)

8. Shared Data Types ​

The types below are shared between the Media and Camera modules and are listed here for reference.

KMPCameraPreviewPipeline ​

Defined in verticalCommon and used on both the Camera and Media sides:

  • Camera side: CameraPreview.setPipeline(pipeline) — inject the pipeline into the camera preview
  • Media side: PreviewPlayer.getPipeline() — get the current rendering pipeline

The pipeline object is created on the media side and passed to the camera side, where it serves as the transport channel for preview data.


PreviewStreamParamsUpdate (Camera → Media) ​

When the camera's preview stream parameters change, this object is delivered through CameraStreamListener.onParamsChanged(). On the media side you typically use its data to call PreviewPlayer.setOffset() and setWindowCropInfo() and keep the player in sync.

kotlin
data class PreviewStreamParamsUpdate(
    val windowCropInfo: WindowCropInfo?,
    val offsetData: CameraPreviewOffsetData?,
    val stabOffset: String?,
    val previewWidth: Int,
    val previewHeight: Int,
    val previewFps: Int,
)

For details, see §4 Live Preview in the Camera API reference.