Virtual studio is a chroma keying feature within the production studio service. It provides automatic and professional chroma keying for blue screens, green screens, and real-world backgrounds. It supports streaming from multiple devices and camera angles and enables remote broadcasting. You can use the cloud-based chroma keying capability to create various live streaming scenes, such as dual screens, split screens, and Picture-in-Picture (PiP), to create an immersive live experience. This topic describes how to use a virtual studio for live video streaming.
Prerequisites
The production studio service is enabled. For more information, see Enable the production studio service.
An accelerated domain name is added and a canonical name (CNAME) record is configured for the domain name. For more information, see Add an accelerated domain name and Configure a CNAME record for a streaming domain.
(Optional) If you want to select a video source from the ApsaraVideo Live console, a streaming domain for the video source is added and a CNAME record is configured. For more information, see Add a streaming domain and Configure a CNAME record for a streaming domain.
(Optional) If you want to select a video source from the media library, a domain name for ApsaraVideo VOD is added and a CNAME record is configured. For more information, see Add a domain name for ApsaraVideo VOD and Configure a CNAME record for an ApsaraVideo VOD domain name.
(Optional) If you want to use the live recording feature, the service for storing recordings is enabled. For more information, see Record live streams to OSS.
You have read the development guide. For more information, see Development guide.
Background information
Virtual studio is a chroma keying feature within the production studio service that supports streaming from multiple devices and camera angles, and enables remote broadcasting. You can use cloud-based chroma keying to create various live streaming scenes, such as dual screens, split screens, and Picture-in-Picture (PiP), to create an immersive live experience. This guide explains the entire process, from entering the virtual studio to outputting the final live stream.
The production studio service provides a set of API operations for adding, deleting, querying, and modifying virtual studio layouts. This guide also describes how to quickly integrate the virtual studio service using API operations.
Workflow
A virtual studio is built on the standard production studio and integrates chroma keying capabilities. The workflow is similar to that of a standard production studio. The following flowchart shows the live streaming workflow.
The complete workflow for using a virtual studio includes the following stages:
Live streaming settings: Use the Cloud Director console to configure features such as live playback domain names, output definition, transcoding, and recording.
Configure the live stream: Add audio and video materials and set the output layout for the added materials.
Start live streaming: Use the Program (PGM) output for the official live stream and the Preview (PVW) output to preview the mixed stream.
Real-time production: Use features such as real-time captions, graphic overlays, and the audio mixer to adjust the live content and effects.
Console operations
Set up live streaming
Log on to the ApsaraVideo Live console. In the navigation pane on the left, choose .
Select the virtual studio that you created and click Open in the Actions column.
When you create a production studio instance and access the UI for the first time, the configuration panel appears. After you configure the parameters, click OK.
If you have configured the instance before, you can click Live Stream Settings in the upper-right corner to open the panel.

Configuration item
Procedure
Domain
Click the Domain text box, and from the Domain drop-down list, select a live streaming domain name that has a CNAME record configured.
Output
In the Output drop-down list, select the original resolution for the live stream (Low Definition, Standard Definition, High Definition, Ultra High Definition 1080p (1920 × 1080), Portrait Low Definition, Portrait Standard Definition, Portrait High Definition, or Portrait Ultra High Definition 1080p (1080 × 1920)).
Transcoding Specifications
Low Definition
Standard Definition
High Definition
Ultra High Definition 1080p (1920 × 1080)
After you complete the output configuration, you can also select the live stream transcoding specifications by clicking the checkboxes for Low Definition, Standard Definition, High Definition, and Ultra High Definition 1080p (1920 × 1080). You can select multiple options.
NoteYou can select multiple transcoding specifications, but their definition cannot exceed that of the original stream. For example, if you select Low Definition, viewers can choose between Original Quality and Low Definition during playback.
Recording Settings
(Optional) Turn on the Recording Settings switch to enable recording.
You can select automatic recording or manual recording. For automatic recording, the recording starts automatically after the live stream begins. For manual recording, you can manually start or stop the recording as needed after the live stream begins.
Set the storage location for the live stream recordings.
NoteThe recording storage location must be in the same region as Cloud Director. Cross-region recording is not supported.
Select one or more storage formats for the recording files.
Set the recording epoch. For example, if you set the epoch to 10 minutes, a new recording file is generated every 10 minutes.
Stream Delay
Optional. Turn on Stream Delay to configure a delay for the output. Valid values: 15 to 300 seconds.
Standby Video
(Optional)
Live Stream: Select Select from ApsaraVideo Live Console or Enter a live URL. as the standby video.
VOD Resource: Click Select and select a VOD video from the VOD source list to use as a standby video when the live stream has not started or is abnormal.
ImportantAll video-on-demand (VOD) product assets that you use (such as VOD sources and standby videos) must be in the same region as Cloud Director. Cloud Director does not support using VOD videos from other regions as assets (for example, if you use Cloud Director in the China (Shanghai) region, your assets must also be stored in VOD products in the China (Shanghai) region).
Image: Click Select From Media Library or Local Upload to select a backup image. You can upload images in JPG or PNG format. The maximum file size is 10 MB.
Multi-way Stream Relay
(Optional) Click Add URL to configure a forwarding address.
ImportantAfter you add or delete an ingest URL, you must disconnect and restart the PGM output for the settings to take effect.
Using third-party platform features incurs additional stream ingest fees. By default, you can have three free ingest URLs under the same domain name. You are charged for any additional ingest URLs. The billing standard is the same as that for stream ingest in the live center. For more information, see Billing of stream ingest in the live center.
Configure the live stream
Add input sources. A virtual studio supports two types of video sources.
Image Matting Input Source: You can add live streams with a green background. The green background can be removed using the chroma key feature. To add this source, select the Chroma Key Input Source tab in the Video Source area.
Multimedia Input Source: You can add on-demand or live streams. These streams are played in multimedia windows. To add this source, select the Multimedia Input Source tab in the Video Source area of the production studio.
Click Add Media to open the Add Resource panel. You can add live or VOD videos as sources as described in the following table.

How to add
Procedure
Live Stream
Select from the ApsaraVideo Live console: Select a domain name. The list of all live streams under that domain name is automatically synchronized. Select the ingest URL that you want to add to the current production studio instance.
Enter a streaming URL: Enter a valid streaming URL. RTMP, FLV, and RTS formats are supported.
VOD
Click Select. In the list of video assets from the media library, select a video. Set the playback mode to Once or Loop. Click OK to add the video.
NoteFor a VOD video asset from VOD, you must select 'For Live Production' from the More dropdown menu in the ApsaraVideo VOD console. The asset is then uploaded and pre-processed before it can be used in Cloud Production. For more information about the pre-processing rules and billing methods, see ApsaraVideo VOD Pricing.
Local Stream Ingest
Ingest method:
Screen sharing: Share your screen. You can select an application window or your desktop as the input source.
Camera ingest: Use your local camera as the input source.
Resolution: Select an appropriate resolution.
Click + Layout to add and configure a studio layout.
In the Layout Settings window, set Layout Type to Studio Layout, and enter a Layout Name. You can add two types of layouts as needed: common layouts and studio layouts. You can use them to switch between standby videos, ads, and the main live stream.

In the Layout Settings window, on the Background Image tab, add a background image. You can select an image from the template library or upload an image from your local machine.
NoteThe background image is displayed in full screen. We recommend that the image dimensions match the screen dimensions. The file size cannot exceed 10 MB.
In the Layout Settings window, on the Chroma Key Materials tab, click Add to add chroma key material. After you associate an input source, configure the automatic chroma keying settings for the source as described in the table below. A live channel supports multiple chroma key input sources.

Setting
Description
Input Source
Select an input source from the drop-down list.
Portrait Type
Supports full-length and half-length portraits.
Color Gamut for Chroma Key
Supports automatic detection of three chroma key color gamuts: green screen, blue screen, and real-world scene.
Position/Size
Supports setting the horizontal offset, vertical offset, and scaling.
In the Layout Settings window, on the Multimedia Materials tab, click Add to add multimedia material. You can add one to three multimedia windows to a live channel. You can insert video or image materials.
In the Layout Settings window, on the Order of Layers tab, you can adjust the stacking order of the materials.
Click OK to complete the virtual studio layout configuration.
Start live streaming
To start live streaming, click the layout you want to use, and then click Start Live Streaming. The video sources are displayed in the PVW window according to the layout.
Click Synchronize to PGM. This is the official live content that your end users will see.
To switch the live content, click the new layout you want to switch to. After the layout appears in the PVW preview window, click Synchronize to PGM to push the live stream to the viewers.
ImportantYou can switch the live content in the PVW preview window by switching between configured studio layouts. To switch the studio or the content within the studio (such as the chroma key source or content in multimedia windows) during a live stream, you must configure different studio layouts beforehand.
When you add different studio layouts, we recommend that you use distinct names to differentiate them.
To end the live stream, click Stop.
Real-time production
While monitoring the live stream, you can use the following features to edit and adjust the live content and effects in real time.
Click the audio mixer block button and slide it up or down to adjust the program volume.
Audio Follows Video (checked): The PVW only displays the video without sound. When you select Audio Follows Video and click Synchronize to PGM, the audio from the video source in the PVW is sent to the PGM output. The audio of other video sources is muted by default. You can use the audio mixer to set the audio of all video sources for output.
Audio Follows Video (unchecked): When you switch from PVW to PGM without selecting Audio Follows Video, the audio of the video source in the PVW preview is not output to the PGM.

Set the caption style and enable bilingual translation.
NoteThe real-time captions feature is not supported in the Singapore live center.
Real-time captions use real-time speech recognition on the audio of a live stream and display the recognized text as captions on the stream. The recognized captions can be translated in real time. You can display captions in the source language of the audio, the translated target language, or both.
Translation is supported between Chinese, English, Spanish, and Russian. The real-time captions feature not only adds a professional touch to your content but also provides an excellent viewing experience in scenarios where audio is inconvenient. Real-time translation makes the live stream content more accessible to international, multilingual users. It has practical applications in cross-border E-commerce live streaming and international event broadcasting.
Click Live Subtitles to open the caption widget window.
Set the widget name, font style, size, position, video source, source language, and translation language. You can preview the effect in the area on the left. After you finish the settings, click OK to save.

Insert effects such as watermarks, logos, and banner text into the live stream.
Add an image
Click Image to open the image widget window.
Click Upload Image and select an image to upload from your local machine. After the image is uploaded, set the widget name, scaling ratio (size), and position. You can preview the effect in the area on the left. After you complete the configuration, click OK to save.

Add text
Click Text to open the text widget window.
Enter the text in the input box. Then, set the widget name, font style, size, display mode, and position. You can preview the effect in the area on the left. After you complete the configuration, click OK to save.

Change the video stream layout. You can create up to 20 layouts at the same time.
Click Switch to Standby. If an issue occurs with the live stream, you can switch to the standby video in real time to ensure the live stream continues without interruption.
API operations
You can call API operations to quickly integrate and use the virtual studio service. The process is as follows:
Create and configure a production studio. The type must be set to virtual studio. For more information, see CreateCaster and SetCasterConfig.
Add video resources to the production studio. For more information, see AddCasterVideoResource.
Add a virtual studio layout. For more information, see AddStudioLayout.
(Optional) Add components to the production studio. For more information, see AddCasterComponent.
Start the production studio. For more information, see StartCaster.
Set the playback scene. For more information, see SetCasterSceneConfig.
Stop the production studio. For more information, see StopCaster.