All Products
Search
Document Center

:Local video playback

Last Updated:Jul 27, 2023

This topic describes how to play video files stored in the memory card of a local network video recorder (NVR) or an IP camera.

Prerequisites

  • An IoT Platform instance of the video type is purchased, and a video device is connected to IoT Platform. For more information, see Device Connection.

  • One or more video files exist in the local storage of the video device.

Background information

  • LinkVisual supports the following methods that can be used to play local video files:

    • Select video files for playback based on the recording time.

    • Select video files for playback based on the file name.

  • If you connect your device to IoT Platform by using an edge machine of the V series (LE-V), you can select and play local video files only by file name.

Device-side development

  • If you connect your device to IoT Platform by using an LE-V, device-side development is not required to play local video files.

  • If you directly connect an IP camera to IoT Platform, you must perform device-side development to select and play local video files. LinkVisual allows you to use a Linux or Android SDK based on your operating system.

Cloud-side development

Limits

You can play local videos on demand over Real-Time Messaging Protocol (RTMP), HTTP Flash Video (HTTP-FLV), and HTTP Live Streaming (HLS). We recommend that you use RTMP and HTTP-FLV. If you use HLS, the following limits apply:

  • IoT Platform supports only HLS-based live streaming. If you want to seek within a video, re-obtain the streaming URL of the video to play based on the seek point.

  • After a device pushes a video stream, you must stop playing the video on demand. Otherwise, the player may fail to stop playing the video. For example, the player remains in the Buffering state. For more information, see Step 24 in the "Data forwarding process" section of the Local video playback topic.

  • HLS allows you to play videos on demand based on short-lived connections. If a streaming URL fails to receive a request within 20 seconds, the streaming URL becomes invalid.

  • Compared with RTMP and HTTP-FLV, HLS requires an additional 5 to 10 seconds to generate an image.

Procedure

  1. Call the InvokeThingService operation to obtain the playlist of video files that are selected by file name or recording time.

    • Main request parameters:

      Parameter

      Example

      Description

      Identifier

      QueryRecordList

      The identifier that distinguishes IP camera services.

      • By file name: Set this parameter to QueryRecordList.

      • By recording time: Set this parameter to QueryRecordTimeList.

        Note

        QueryRecordList and QueryRecordTimeList are service requests defined in the Thing Specification Language (TSL) model of the IP camera. You can view the service details by performing the following steps: Log on to the IoT Platform console. On the Products page, find the product to which your IP camera belongs. Click the product name to go to the Product Details page. On the Define Feature tab of the page, find the service that you want to view, and click View in the Actions column.

        For more information about the TSL model, see What is a TSL model?

      Args

      {
      "BeginTime":10,
      "Type":0,
      "QuerySize":2,
      "EndTime":1541662222
      }
      

      The input parameters that are required to enable the service. The parameter values are in the JSON string format.

      • BeginTime: the start recording time of the video files that you want to select and play. Valid values: 0 to 2147483647. Unit: seconds.

      • EndTime: the end recording time of the video files that you want to select and play. Valid values: 0 to 2147483647. Unit: seconds.

      • Type: the type of the video.

        • 0: video that is captured based on a recording plan.

        • 1: video that is captured in alert-event-triggered recording.

        • 2: video that is captured in manually triggered recording.

        • 99: all videos.

      • QuerySize: the number of video files that you obtain after you specify the selection conditions. Valid values: 0 to 128.

    • Sample request:

      https://iot.cn-shanghai.aliyuncs.com/?Action=InvokeThingService
      &ProductKey=a1BwAGV****
      &DeviceName=device1
      &Identifier=QueryRecordList  
      &Args={
                    "BeginTime":10,
                    "Type":0,
                    "QuerySize":2,
                    "EndTime":1541662222
                     }
      &<Common request parameters>
  2. Obtain the URL of the local video files that you selected by performing Step 1.

    • By file name: call the QueryDeviceVodUrl operation to obtain the URL of the local video files that you selected.

    • By recording time: call the QueryDeviceVodUrlByTime operation to obtain the URL of the local video files that you selected.

      Note

      You can implement this function only if your IP camera is directly connected to IoT Platform.

Application-side development

LinkVisual allows you to configure players on web applications, iOS applications, or Android applications. For more information about how to develop media player applications, see Application Developer Guide.

The following table describes the streaming protocols and coding formats supported by media player applications for different platforms.

Media player application

Playback protocol

Video coding format

Audio coding format

Web

  • HTTP-FLV

  • HLS

H.264

AAC

iOS

RTMP

  • H.264

  • H.265

Android

RTMP

  • H.264

  • H.265

The media player application plays local video files after it obtains the URL of the files.