Skip to content

RTMP Module

rtmp module for insta360 allows real-time communication with the camera based on a TCP socket.

Classes:

Name Description
Client

Client for interacting with the camera using the rtmp protocol.

CommandFailedException

Exception raised when a command fails.

CameraNotConnectedException

Exception raised when the camera is not connected.

Client

Client for interacting with the camera using the rtmp protocol.

Parameters:

Name Type Description Default
host str

The IP address of the camera (usually always 192.168.42.1).

'192.168.42.1'
port int

The port of the camera (usually alwaays 6666).

6666
logger Optional[Logger]

A custom logger to use.

None
callback Optional[Callable[[Dict], Any]]

A callback function to call when a message is received.

None
output_filepath Optional[str]

The output file path for saving the video stream.

None

Methods:

Name Description
check_connected_to_camera_wifi

Check if the device is connected to the camera wifi.

open

Open a TCP socket to the camera.

close

Close the TCP socket.

sync_local_time_to_camera

Sync the local time to the camera.

get_camera_info

Get updated data about the camera, battery, storage, etc.

get_camera_type

Get the camera type.

take_picture

Take a picture.

get_serial_number

Get the camera serial number.

get_camera_files_list

Get the list of files on the camera.

set_normal_video_options

Set the normal video options.

get_normal_video_options

Get the normal video options.

start_capture

Start capturing video.

stop_capture

Stop capturing video.

get_exposure_settings

Get the exposure settings.

set_exposure_settings

Set the exposure settings.

set_capture_settings

Set the capture settings.

get_capture_settings

Get the capture settings.

start_live_stream

Start the live stream.

start_preview_stream

Start the preview stream.

stop_live_stream

Stop the live stream.

stop_preview_stream

Stop the preview stream.

convert_livestream_raw_to_mp4

Convert the live stream raw file to mp4.

get_camera_uuid

Get the camera UUID.

get_capture_current_status

Get the current capture status.

set_time_lapse_option

Set the time lapse option.

start_time_lapse

Start the time lapse.

stop_time_lapse

Stop the time lapse.

is_camera_connected

Check if the camera is connected.

get_battery_status

Get the battery status.

get_storage_state

Get the storage state.

Classes:

Name Description
KeepAliveTimer

Timer to call the KeepAlive function.

KeepAliveTimer

Bases: Timer

Timer to call the KeepAlive function.

check_connected_to_camera_wifi()

Check if the device is connected to the camera wifi.

close()

Stops the keep alive timer and closes the TCP socket.

convert_livestream_raw_to_mp4()

Convert the raw video stream file to mp4 format.

get_battery_status()

Get the battery status from the camera.

get_camera_files_list()

Get the list of files on the camera.

Returns:

Type Description
int

The sequence number of the sent message.

get_camera_info()

Get updated data about the camera, battery, storage, etc.

Returns:

Type Description
int

The sequence number of the sent message.

get_camera_type()

Get the camera type.

get_camera_uuid()

Get the camera UUID.

get_capture_current_status()

Get the current capture status from the camera.

Returns:

Type Description
int

The sequence number of the sent message

get_capture_settings()

Get capture settings from the camera.

get_exposure_settings()

Get exposure settings from the camera.

get_normal_video_options()

Get the normal video options.

Returns:

Type Description
int

The sequence number of the sent message.

get_serial_number()

Get the camera serial number.

get_storage_state()

Get the storage state from the camera.

is_camera_connected()

Check if the camera is connected.

open()

Opens a TCP socket to the camera.

set_capture_settings(record_resolution=None, fov_type=None, focal_length_value=None, gamma_mode=None)

Set capture settings to the camera.

set_exposure_settings()

Set exposure settings to the camera.

set_normal_video_options(record_resolution=None, fov_type=None, focal_length_value=None, gamma_mode=None, white_balance=None, white_balance_value=None, function_mode='FUNCTION_MODE_NORMAL_VIDEO')

Set the normal video options.

Parameters:

Name Type Description Default
record_resolution Optional[str]

The recording resolution to set in the camera.

None
fov_type Optional[str]

The FOV type to set in the camera.

None
focal_length_value Optional[float]

The focal length value to set in the camera.

None
gamma_mode Optional[str]

The gamma mode to set in the camera.

None
white_balance Optional[str]

The white balance mode to set in the camera.

None
white_balance_value Optional[float]

The white balance value to set in the camera.

None
function_mode str

The function mode to set in the camera.

'FUNCTION_MODE_NORMAL_VIDEO'

Returns:

Type Description
int

The sequence number of the sent message.

set_time_lapse_option()

Set time-lapse options in the camera.

start_capture()

Start capturing video.

Returns:

Type Description
int

The sequence number of the sent message.

start_live_stream()

Start a high resolution live stream.

Returns:

Type Description
int

The Sequence number of the sent message

Note

You can start recording simultaneously but the live stream will glitch.

Example
from insta360.rtmp import Client

client = Client()
client.open()

client.start_live_stream()

start_preview_stream()

Starts a low resolution preview stream.

Returns:

Type Description
int

The Sequence number of the sent message

Note
  1. The stream is low resolution.
  2. You can start recording simultaneously without any glitches.
Example
from insta360.rtmp import Client

client = Client()
client.open()

client.start_preview_stream()

# Optionally, start recording
client.start_capture()

start_time_lapse()

Start time-lapse in the camera.

stop_capture()

Stop capturing video.

Returns:

Type Description
int

The sequence number of the sent message.

stop_live_stream()

Stop the live stream.

Returns:

Type Description
int

The Sequence number of the sent message

stop_preview_stream()

Stops the preview stream.

Returns:

Type Description
int

The Sequence number of the sent message

Note

Internally, command for stopping preview stream is same as stopping live stream. Hence, this function is a wrapper around stop_live_stream() function.

Example
import time
from insta360.rtmp import Client

client = Client()
client.open()

client.start_preview_stream()
time.sleep(10)

client.stop_preview_stream()

stop_time_lapse()

Stop time-lapse in the camera.

sync_local_time_to_camera(timestamp=None, seconds_from_gmt=None)

Sync the local time and timezone to the camera.

Parameters:

Name Type Description Default
timestamp Optional[int]

The epoch timestamp to set.

None
seconds_from_gmt Optional[int]

The timezone offset from GMT in seconds.

None

Returns:

Type Description
int

The sequence number of the sent message.

take_picture()

Take a picture.

Returns:

Type Description
int

The sequence number of the sent message.