Local Storage of AOV Recordings

Last Updated on : 2025-01-15 07:54:30download

Always On Video (AOV) differs from regular video recording in its generation mechanism, and parameters such as frame rate and bitrate are also different. Given this feature, you must add a new storage logic to handle AOV recordings in the existing storage system.

Feature description

Devices with AOV functionality will generate video data with parameters different from those of regular recordings. The following relationships are displayed in terms of time:

Local Storage of AOV Recordings

As shown in the diagram above, AOV recordings and regular event recordings are mutually exclusive in terms of time. There are no restrictions on the duration ratio between AOV recordings and regular recordings. Therefore, AOV recordings can be considered a new type of event recording, but the storage process is slightly different from that of regular recordings.

Components

  • svc_local_storage
  • svc_aov_buffer

Storage directory

The directory structure for storing AOV recordings is consistent with that for regular recordings. For more information, see Directory and file structure.

Video format

The video format for storing AOV recordings is consistent with that for regular recordings. For more information, see Video format.

Recording mode

Add a new storage mode option in product requirements to distinguish whether to store AOV recordings.

The SDK only provides AOV storage interfaces and parameters, and applications invoke them on demand to implement the specified storage mode.

Data structure and APIs

Initial parameters for local (AOV) storage

AOV initial parameters are consistent with local storage initial parameters. For more information, see Initial parameters.

The local storage initial parameters include the following parameter sets:

TUYA_IPC_AOV_STORAGE_INFO_T aov_info;       // AOV recording parameters

Initialize and configure AOV storage separately.

Start AOV video storage

/**
 * @brief Start AOV local storage
 *
 * @param[in] chan stream channel
 * @return OPRT_OK on success. Others on error
 */
OPERATE_RET tuya_ipc_ss_start_aov_local_storage(IN IPC_STREAM_E chan);

After the local storage module and AOV ring buffer (referred to as ringbuf) are initialized, call this interface to start the AOV video writing process.

Stop AOV video storage

/**
 * @brief Stop AOV local storage
 *
 * @param[in] chan stream channel
 * @return OPRT_OK on success. Others on error
 */
OPERATE_RET tuya_ipc_ss_stop_aov_local_storage(IN IPC_STREAM_E chan);

Call this interface to stop writing the current AOV video.

AOV video write status

/**
 * @brief Get the write status of AOV local storage
 *
 * @param[in] chan stream channel
 * @return STORAGE_AOV_STATUS_E
 */
STORAGE_AOV_STATUS_E tuya_ipc_ss_get_aov_storage_status(IN IPC_STREAM_E chan);

Call this interface to get the write status of AOV local storage.

Development guide

Local storage

SDK
Write to storage media based on regular recording rules
SDK local storage module gets AOV frames
Process frames
AOV video file
Import video files into AOV ringbuf frame by frame

As shown above, the SDK provides a new AOV ringbuf interface, which is used separately from the regular ringbuf interface.
The application needs to import AOV video files into the ringbuf according to the rules. After that, the AOV video files will be automatically stored on a TransFlash (TF) card and other media.

Playback

The playback process and steps of AOV recordings are consistent with those of regular recordings, and no special processing is required.

Cloud storage

Similar to local storage, cloud storage also relies on AOV ringbuf. Local storage and cloud storage services use the same AOV ringbuf and do not need to be separated. For information on how to start and stop cloud storage, see the demo code in the file you downloaded.

SDK
Upload shard by shard after the upload conditions are met
SDK cloud storage module gets AOV frames
Process frames
AOV video file
Import video files into AOV ringbuf frame by frame

Things to note

  • Writing and uploading timing: When the AOV video cache reaches the maximum limit, or after an event of a low-power device is triggered to wake up the MCU, it starts uploading to the cloud storage and writing to the local storage.
  • When AOV recordings are uploaded to the cloud:
    • Even if no events occur, the video recordings generated during the upload still need to be written into the cache as AOV recordings, waiting for the next upload and write.
    • If an event is triggered, switch to the regular mode. The audio and video data is transferred to the regular ringbuf, and uploaded as regular recordings.
    • Switch to the regular mode in case of a preview on the app.
  • In the app preview mode, the device records video at a regular frame rate and uploads it to the cloud storage in regular mode.
  • When an event is triggered during AOV video uploading, control the priority of the AOV video and event video (according to product requirements). Meanwhile, consider network bandwidth limitations when uploading.
  • When the local storage of AOV recordings spans two days, they will be saved in a new folder.

FAQs

Why is there no video recording when the AOV switch is turned on?

  • When you select event recording only and turn off AOV, only events will be recorded.
  • When you select event recording and turn on AOV, the video will be recorded regularly when there is an event, and AOV mode will be used when there is no event.

Why is there a high probability that AOV clips will fail to upload to cloud storage?

Low power devices can enter sleep mode only after the video event push is completed.

Why is there a gap or overlap between event clips and AOV clips on the app playback timeline?

This issue occurs when event video and AOV video are generated alternately. The issue becomes more obvious when cloud storage is turned on.

  • Possible causes: It takes time to upload videos to the cloud. No videos can be generated during this period. Therefore, the start time of the next video needs to cover this time point.
  • Solution: The end time of the previous clip and the start time of the next clip should be the same, so there will be no gaps in the app rendering process.

The application’s recording logic can be adjusted as shown below:

Event/AOV ends
Start AOV/event recording
Adjust the time of the first frame based on the timestamp of the last recording
Write frame data to AOV/regular ringbuf
Stop writing data to (AOV/regular) ringbuf
Record the timestamp of last frame
Call API to end event/AOV recording
  • When previewing on the app in AOV mode, no matter whether an event occurs, frames must continue to be written to the ringbuf until the preview ends. Then, stop writing to the ringbuf and call the event end API.
  • When previewing on the app in event mode, if an event occurs, call the event end API directly after the event ends, without stopping writing frames.

Can AOV recordings have different resolutions than regular recordings?

No. Different resolutions will cause issues with playback on the app and download.

Why are the playback and download speed capabilities not reported?

You need to perform tuya_ipc_ss_init before calling tuya_ipc_upload_skills(VOID).