Talk to us
Talk to us
menu

How to Record Streaming Video

How to Record Streaming Video

If you’re looking to record streaming video for later viewing or archiving purposes, ZEGOCLOUD Cloud Recording could be a great solution for you. With it, you can easily integrate and call APIs to record video and store it on the cloud. In this article, we will walk you through how to record streaming video with ZEGOCLOUD Cloud Recording, so you can capture and save your favorite video content hassle-free.

Why ZEGOCLOUD Cloud Recording to Record Streaming Video

Cloud Recording is a powerful solution for recording streaming video, which allows you to capture and store high-quality video content on the cloud. With the ZEGOCLOUD Cloud Recording SDK, you can easily integrate video recording functionality into your app or website, and provide a seamless video recording experience for your users.

zegocloud cloud recording

It offers a wide range of features, making it a versatile solution for developers looking to add video recording capabilities to their app or website.

Here are some key features of the Cloud Recording SDK from ZEGOCLOUD:

1. Support for multiple formats

The ZEGOCLOUD Cloud Recording SDK supports a variety of video and audio formats, including MP4, AAC, and H.264. This means that you can record videos in the format that works best for your specific use case.

2. High-quality video and audio capture

The SDK is designed to capture high-quality video and audio, ensuring that your recorded content looks and sounds great.

3. Real-time video processing

The ZEGO Cloud Recording SDK supports real-time video processing, which means that you can process and edit your video content while it is being recorded.

4. Cloud storage

The recorded video content is automatically stored on the cloud, making it easy to access and share with others.

5. Flexible customization options

The SDK offers a range of customization options, including the ability to adjust video quality, add watermarks, and customize video metadata. This allows you to tailor the video recording experience to the specific needs of your app or website.

How to Start Recording Streaming Video with ZEGOCLOUD SDK

Recording streaming video with ZEGOCLOUD Cloud Recording SDK is a straightforward process. You can start by integrating the SDK into your app or website and initiating the recording by calling the relevant APIs. The SDK supports multiple video and audio formats, offers real-time video processing, and enables easy cloud storage of high-quality video content. Follow our comprehensive guide for a seamless recording experience.

Preparation

Follow the steps to get your recording activities up and running:

1. Start Cloud Recording

To initiate cloud recording, utilize the StartRecord method and obtain the room ID to join a particular room. Once the method is called successfully, retrieve the taskID (UID) from the response, the body proceeds.

2. Check the Recording Status

To monitor recording progress, use the DescribeRecordStatus method repeatedly. Upon successful execution, retrieve the current recording status and upload the address from the response body.

3. Modify Mixed-Stream Layout

Update mixed stream layout during video recording by repeatedly implementing the UpdateLayout method. Find more details on modifying stream mixing layout under the Set Stream Mixing Layout feature.

4. Update the Whiteboard

Update Whiteboard ID while recording by repeatedly using the UpdateWhiteboard method. Refer to the Whiteboard Recording feature for more details.

5. Stop Cloud Recording

Terminate cloud recording by executing the StopRecord method.

6. Managing Recorded Files

Follow the steps below to manage your recorded files in the ZEGOCLOUD Cloud Recording SDK.

Upload recorded files

Upon completion of the cloud recording task, the recorded files are uploaded to the designated third-party cloud storage. To review uploading details, utilize the DescribeRecordStatus method.

FileUrl: Provides the URL for uploaded recorded files.

Status: Reports the uploading status of the recorded files.

VideoId: Vod returns the VideoId for recorded files.

Once the recorded files are uploaded, the cloud recording triggers a callback to the specified callback URL.

Manage recorded file names

The name of the recording file contains critical data, including the StreamId start recording timestamp. For detailed information, review the OutputFileRule parameter specified in the StartRecord method.

How to Record Different Types of Streams

In the previous section, we covered some fundamental concepts of cloud recording. Now, let’s delve into the practical aspects of recording streams with ZEGOCLOUD Cloud Recording SDK. So, let’s get right into it!

1. Recording a Single Stream

Activate single-stream recording by setting the RecordMode parameter to 1 while calling the StartRecord method. Choose the required recorded file format by setting the OutputFileFormat parameter to mp4, flv, or hls.

Here’s a sample request:

{
    "RoomId": "xxxx",
    "RecordInputParams": {
        "RecordMode": 1,
        "StreamType": 3,
        "MaxIdleTime": 60
    },
    "RecordOutputParams": {
        "OutputFileFormat": "mp4",
        "OutputFolder": "record/"
    },
    "StorageParams": {
        "Vendor": 2,
        "Region": "oss-xxxx",
        "Bucket": "xxxx",
        "AccessKeyId": "xxxx",
        "AccessKeySecret": "xxxx"
    }
}

2. Mixed-stream Recording

Initiate mixed-stream recording by setting the RecordMode parameter to 2 while calling the StartRecord method. Set the OutputFileFormat parameter to mp4, flv, or hls to select the desired recorded file format.

Here’s a mixed-stream recording sample:

{
    "RoomId": "xxxx",
    "RecordInputParams": {
        "RecordMode": 2,
        "StreamType": 3,
        "MaxIdleTime": 60,
        "MixConfig": {
            "MixMode": 2,
            "MixOutputStreamId": "mix",
            "MixOutputVideoConfig": {
                    "Width": 1280, 
                    "Height": 720, 
                    "Fps": 15, 
                    "Bitrate": 1130000
            }
        }
    },
    "RecordOutputParams": {
        "OutputFileFormat": "mp4",
        "OutputFolder": "record/"
    },
    "StorageParams": {
        "Vendor": 2,
        "Region": "oss-xxxx",
        "Bucket": "xxxx",
        "AccessKeyId": "xxxx",
        "AccessKeySecret": "xxxx"
    }
}

3. Define Mixed-Stream Layout

While calling the StartRecord method, define the MixMode parameter to set the video layout. Update the layout during mixed-stream recording by calling the UpdateLayout method.

Here’s an example request for UpdateLayout:

{
    "TaskId": "xxxx",
    "MixMode": 1,
    "MixInputList": [
        {
            "StreamId": "xxxx", 
            "ViewType": 1, 
            "Top": 0, 
            "Left": 0, 
            "Bottom": 720, 
            "Right": 540, 
            "Layer": 1
        },
        {
            "StreamId": "", 
            "ViewType": 1, 
            "Top": 0, 
            "Left": 540, 
            "Bottom": 360, 
            "Right": 1080, 
            "Layer": 1
        },
        {
            "StreamId": "", 
            "ViewType": 1, 
            "Top": 360, 
            "Left": 540, 
            "Bottom": 720, 
            "Right": 1080, 
            "Layer": 1
        }
    ]
}

4. Multi-sector recording (Whiteboard)

Enable whiteboard recording by setting the HasWhiteboard parameter to true while calling the StartRecord method. The Whiteboard is an array in JSON format containing whiteboard configurations, and only one whiteboard can be configured at the moment.

Example request for enabling whiteboard recording in mixed-stream recording mode:

{
    "RoomId": "xxxx",
    "RecordInputParams": {
        "RecordMode": 2,
        "StreamType": 3,
        "HasWhiteboard": true,
        "Whiteboard": [
            {
                "HorizontalRatio": 16,
                "VerticalRatio": 9,
                "Width": 1280,
                "Height": 720,
                "WhiteboardId": "0000"
            }
        ],
        "MaxIdleTime": 60,
        "MixConfig": {
            "MixMode": 3,
            "MixOutputStreamId": "mix",
            "MixOutputVideoConfig": {
                    "Width": 1280, 
                    "Height": 720, 
                    "Fps": 15, 
                    "Bitrate": 1130000
            }
        }
    },
    "RecordOutputParams": {
        "OutputFileFormat": "mp4",
        "OutputFolder": "record/"
    },
    "StorageParams": {
        "Vendor": 2,
        "Region": "oss-xxxx",
        "Bucket": "xxxx",
        "AccessKeyId": "xxxx",
        "AccessKeySecret": "xxxx"
    }
}

5 . Capture Screenshots

To capture screenshots during single-stream recording, set the OutputFileFormat to jpg and adjust the SnapshotInterval parameter as needed in the StartRecord method. Screenshots can’t be taken in mixed-stream recording mode or for StreamType 1. Use the DescribeRecordStatus method to query task information. Captured screenshots are uploaded to your third-party cloud storage, and you’ll receive a callback notification for each completed task.

{
    "RoomId": "xxxx",
    "RecordInputParams": {
        "RecordMode": 1,
        "StreamType": 3,
        "MaxIdleTime": 60
    },
    "RecordOutputParams": {
        "OutputFileFormat": "jpg",
        "OutputFolder": "record/",
        "SnapshotInterval": 10
    },
    "StorageParams": {
        "Vendor": 2,
        "Region": "oss-xxxx",
        "Bucket": "xxxx",
        "AccessKeyId": "xxxx",
        "AccessKeySecret": "xxxx"
    }
}

Final Thoughts

With ZEGOCLOUD Cloud Recording SDK, capturing and storing high-quality streaming video content is now hassle-free. By following our simple integration guide and utilizing the robust features of the SDK, you can create a seamless and immersive video recording experience for your app or website. Sign up to start recording streaming video with ZEGO Cloud Recording SDK today!

Talk to Expert

Learn more about our solutions and get your question answered.

Talk to us

Take your apps to the next level with our voice, video and chat APIs

Free Trial
  • 10,000 minutes for free
  • 4,000+ corporate clients
  • 3 Billion daily call minutes

Stay updated with us by signing up for our newsletter!

Don't miss out on important news and updates from ZEGOCLOUD!

* You may unsubscribe at any time using the unsubscribe link in the digest email. See our privacy policy for more information.