すべてのプロダクト
Search
ドキュメントセンター

ApsaraVideo Live:開発者ガイド

最終更新日:Nov 09, 2025

このトピックでは、プロダクションスタジオ機能に関連する API 操作の使用方法について説明します。

注意事項

  • このトピックでは、API 操作のみに基づいたプロダクションスタジオ機能について説明します。これは、実際のプロダクションスタジオとは異なります。API 操作に基づいてプロダクションスタジオ機能を使用するには、インタラクションを可能にするフロントエンド Web ページを開発する必要があります。

  • ApsaraVideo Live コンソールは、ビデオを編成するためのプロダクションスタジオとフロントエンド Web ページを提供します。コンソールでプロダクションスタジオを使用する場合は、このトピックをスキップできます。詳細については、「プロダクションスタジオの使用を開始する」をご参照ください。

対象読者

  • Java または PHP 開発者。詳細については、「Java 用サーバー SDK を使用する」をご参照ください。

  • Director の基本機能を理解していること

  • ApsaraVideo Live の基本機能を理解している開発者。

前提条件

手順

  1. プロダクションスタジオを構成します。

    説明

    プロダクションスタジオを作成した後、必要に応じて、プロダクションスタジオ名、ドメイン名、トランスコーディング、録画、ストリーム遅延、スタンバイリソースなどのプロダクションスタジオの設定を構成できます。

    関連 API 操作

    SetCasterConfig - プロダクションスタジオを構成する

    サンプルコード

    /**
         * プロダクションスタジオを構成します。
         *
         * @param client   ApsaraVideo Live クライアントインスタンス。
         * @param casterId プロダクションスタジオの ID。
         * @throws Exception 構成中にエラーが発生した場合に例外をスローします。
         */
        private void setCasterConfig(Client client, String casterId) throws Exception {
            SetCasterConfigRequest request = new SetCasterConfigRequest();
            request.setCasterId(casterId);
    
            // ドメイン名を構成します。
            request.setDomainName("domainName");
            // トランスコーディング設定。
            JSONObject transcodeConfig = new JSONObject();
            // ライブストリームのトランスコーディング設定。lsd: 標準解像度。lld: 低解像度。lud: 超高解像度。lhd: 自動回転付き高解像度。daobo-lsd: 標準解像度。daobo-lld: 低解像度。daobo-lud: 超高解像度。daobo-lhd: 高解像度。
            JSONObject liveTemplateIds = new JSONObject();
            JSONArray locationId = new JSONArray();
            locationId.add("lld");
            liveTemplateIds.put("LocationId", locationId);
            transcodeConfig.put("LiveTemplateIds", liveTemplateIds);
            // プロダクションスタジオのトランスコーディングテンプレート。lp_ld: 低解像度。lp_sd: 標準解像度。lp_hd: 高解像度。lp_ud: 超高解像度。lp_ld_v: 垂直低解像度。lp_sd_v: 垂直標準解像度。lp_hd_v: 垂直高解像度。lp_ud_v: 垂直超高解像度。
            transcodeConfig.put("CasterTemplate", "lp_sd");
            request.setTranscodeConfig(transcodeConfig.toJSONString());
    
            // プロダクションスタジオのライブストリーム録画パラメーターを構成します。
           JSONObject recordConfig = new JSONObject();
           recordConfig.put("endpoint", "");
           recordConfig.put("ossBucket", "");
           recordConfig.put("videoFormat", "");
           recordConfig.put("interval", 5);
           request.setRecordConfig(recordConfig.toJSONString());
    
            SetCasterConfigResponse response = client.setCasterConfig(request);
            System.out.println("プロダクションスタジオ構成を追加します。応答: " + JSON.toJSONString(response));
        }
  2. ビデオソースを編集します。

    説明

    出力コンテンツの生成に使用されるビデオソースを構成します。ライブストリームとオンデマンドビデオをビデオソースとして使用できます。

    関連 API 操作

    サンプルコード

    
        /**
         * 指定されたプロダクションスタジオにビデオソースを追加します。
         *
         * @param client   ApsaraVideo Live クライアントインスタンス。
         * @param casterId ビデオソースを追加するプロダクションスタジオの ID。
         * @return 追加されたビデオのリソースの ID。
         * @throws Exception API 呼び出しが失敗した場合、またはその他の例外が発生した場合に例外をスローします。
         */
        private String addCasterVideoResource(Client client, String casterId) throws Exception {
            AddCasterVideoResourceRequest addCasterVideoResourceRequest = new AddCasterVideoResourceRequest();
            addCasterVideoResourceRequest.setCasterId(casterId);
            addCasterVideoResourceRequest.setResourceName("testResourceName");
            addCasterVideoResourceRequest.setMaterialId("");
            // リプレイ回数を設定します。値は -1 から 60 の範囲で指定できます。デフォルト値は 0 で、リプレイなしを示します。-1 は無限ループを示します。
            addCasterVideoResourceRequest.setRepeatNum(-1);
            AddCasterVideoResourceResponse addCasterVideoResourceResponse = client.addCasterVideoResource(addCasterVideoResourceRequest);
            System.out.println("ビデオソースを追加します。応答: " + JSON.toJSONString(addCasterVideoResourceResponse));
            return addCasterVideoResourceResponse.getBody().getResourceId();
        }
    
    
        /**
         * 指定されたプロダクションスタジオのビデオソースリソースのリストをクエリします。
         *
         * @param client   ApsaraVideo Live クライアントインスタンス。
         * @param casterId クエリするプロダクションスタジオの ID。
         * @return DescribeCasterVideoResourcesResponse ビデオソースリソースのリストを含む応答オブジェクト。
         * @throws Exception API 呼び出し中にスローされる可能性のある例外。
         */
        private DescribeCasterVideoResourcesResponse describeCasterVideoResources(Client client, String casterId) throws Exception {
            DescribeCasterVideoResourcesRequest describeCasterVideoResourcesRequest = new DescribeCasterVideoResourcesRequest();
            describeCasterVideoResourcesRequest.setCasterId(casterId);
            DescribeCasterVideoResourcesResponse describeCasterVideoResourcesResponse = client.describeCasterVideoResources(describeCasterVideoResourcesRequest);
    
            System.out.println("ビデオソースリストをクエリします。応答: " + JSON.toJSONString(describeCasterVideoResourcesResponse));
            return describeCasterVideoResourcesResponse;
        }
    
    
        /**
         * プロダクションスタジオのビデオのリソースを変更します。
         *
         * @param client     ApsaraVideo Live クライアントインスタンス。
         * @param casterId   プロダクションスタジオの ID。
         * @param resourceId リソースの ID。
         * @throws Exception API 呼び出しが失敗した場合に例外をスローします。
         */
        private void modifyCasterVideoResource(Client client, String casterId, String resourceId) throws Exception {
            ModifyCasterVideoResourceRequest modifyCasterVideoResourceRequest = new ModifyCasterVideoResourceRequest();
            modifyCasterVideoResourceRequest.setCasterId(casterId);
            modifyCasterVideoResourceRequest.setResourceId(resourceId);
            modifyCasterVideoResourceRequest.setResourceName("newResourceName");
            modifyCasterVideoResourceRequest.setMaterialId("");
            modifyCasterVideoResourceRequest.setVodUrl("");
            modifyCasterVideoResourceRequest.setRepeatNum(-1);
    
            ModifyCasterVideoResourceResponse modifyCasterVideoResourceResponse = client.modifyCasterVideoResource(modifyCasterVideoResourceRequest);
            System.out.println("ビデオソースを変更します。応答: " + JSON.toJSONString(modifyCasterVideoResourceResponse));
        }
    
    
        /**
         * ビデオソースを削除します。
         *
         * @param client     ApsaraVideo Live クライアントインスタンス。
         * @param casterId   プロダクションスタジオの ID。
         * @param resourceId リソースの ID。
         * @throws Exception API 呼び出しが失敗した場合に例外をスローします。
         */
        private void deleteCasterVideoResource(Client client, String casterId, String resourceId) throws Exception {
            DeleteCasterVideoResourceRequest deleteCasterVideoResourceRequest = new DeleteCasterVideoResourceRequest();
            deleteCasterVideoResourceRequest.setCasterId(casterId);
            deleteCasterVideoResourceRequest.setResourceId(resourceId);
            DeleteCasterVideoResourceResponse deleteCasterVideoResourceResponse = client.deleteCasterVideoResource(deleteCasterVideoResourceRequest);
            System.out.println("ビデオソースを削除します。応答: " + JSON.toJSONString(deleteCasterVideoResourceResponse));
        }
    
  3. コンポーネントを編集します。

    説明

    出力コンテンツの生成に使用されるコンポーネントを構成します。サポートされているコンポーネントには、テキストとイメージが含まれます。

    関連 API 操作

    説明

    コンポーネントに関する次の情報を構成する必要があります:

    • コンポーネントがテキストの場合は、テキストコンテンツ、フォントの比率、色などのプロパティを設定します。

    • コンポーネントがイメージの場合は、イメージコンポーネントの ID を指定します。

    サンプルコード

    /**
         * 指定されたプロダクションスタジオにテキストコンポーネントを追加します。
         *
         * @param client   ApsaraVideo Live クライアントインスタンス。
         * @param casterId プロダクションスタジオの ID。
         * @return 新しく追加されたコンポーネントの一意の識別子 (ComponentId)。
         * @throws Exception リクエスト中にエラーが発生した場合に例外をスローします。
         */
        private String addCasterComponent(Client client, String casterId) throws Exception {
            // componentLayer パラメーターを構築します: 画面上のコンポーネントのサイズと位置を設定します。
            JSONObject componentLayer = new JSONObject();
            componentLayer.put("HeightNormalized", 0.2);
            componentLayer.put("WidthNormalized", 0.2);
            JSONArray positionNormalized = new JSONArray();
            positionNormalized.add("0.3");
            positionNormalized.add("0.3");
            componentLayer.put("PositionNormalized", positionNormalized);
            componentLayer.put("PositionRefer", "topLeft");
    
            // テキストレイヤーのコンテンツを構築します: テキスト、色、フォントなどのプロパティを設定します。
            JSONObject textLayerContent = new JSONObject(); // TextLayerContent コンポーネント。
            textLayerContent.put("Text", "hello world!");
            textLayerContent.put("Color", 0xff0000);
            textLayerContent.put("FontName", "KaiTi");
            textLayerContent.put("SizeNormalized", 0.3F);
            textLayerContent.put("BorderWidthNormalized", 0.3F);
            textLayerContent.put("BorderColor", 0xff0000);
    
            // コンポーネントを追加するためのリクエストオブジェクトを構築し、関連するパラメーターを設定します。
            AddCasterComponentRequest addCasterComponentRequest = new AddCasterComponentRequest(); // コンポーネント要素のプロパティを設定します。
            addCasterComponentRequest.setCasterId(casterId);
            // コンポーネントの位置を指定するために使用されます。各位置に最大 1 つのコンポーネントを設定できます。フォーマットは "RC01 から RC99" である必要があります。
            addCasterComponentRequest.setLocationId("RC01");
            // コンポーネントの名前。
            addCasterComponentRequest.setComponentName("testComponentName");
            // コンポーネントのタイプ。有効な値: text: テキストコンポーネント。TextLayerContent パラメーターも設定する必要があります。image: イメージコンポーネント。ImageLayerContent パラメーターも設定する必要があります。caption: 字幕コンポーネント。CaptionLayerContent パラメーターも設定する必要があります。
            addCasterComponentRequest.setComponentType("text");
            addCasterComponentRequest.setTextLayerContent(textLayerContent.toJSONString());
            // コンポーネントの効果。有効な値: none: (デフォルト) 効果なし。animateH: 水平スクロール。animateV: 垂直スクロール。
            addCasterComponentRequest.setEffect("animateH");
            // コンポーネントレイヤーのサイズ。
            addCasterComponentRequest.setComponentLayer(componentLayer.toJSONString());
    
            // リクエストを送信し、応答を取得します。
            AddCasterComponentResponse addCasterComponentResponse = client.addCasterComponent(addCasterComponentRequest);
            System.out.println("コンポーネントを追加します。戻り値: " + JSON.toJSONString(addCasterComponentResponse));
    
            // 新しいコンポーネントの ID を返します。
            return addCasterComponentResponse.getBody().getComponentId();
        }
    
    
        /**
         * プロダクションスタジオのコンポーネントリストをクエリします。
         *
         * @param client      ApsaraVideo Live クライアントインスタンス。
         * @param casterId    クエリするプロダクションスタジオの ID。
         * @param componentId クエリするコンポーネントの ID。
         * @return DescribeCasterComponentsResponse コンポーネントリストの応答オブジェクト。
         * @throws Exception API リクエストまたは処理中にエラーが発生した場合に例外をスローします。
         */
        private DescribeCasterComponentsResponse describeCasterComponents(Client client, String casterId, String componentId) throws Exception {
            // プロダクションスタジオのコンポーネントリストをクエリするためのリクエストオブジェクトを構築します。
            DescribeCasterComponentsRequest describeCasterComponentsRequest = new DescribeCasterComponentsRequest();
            describeCasterComponentsRequest.setCasterId(casterId);
            describeCasterComponentsRequest.setComponentId(componentId);
            DescribeCasterComponentsResponse describeCasterComponentsResponse = client.describeCasterComponents(describeCasterComponentsRequest);
            System.out.println("コンポーネントリストをクエリします。戻り値: " + JSON.toJSONString(describeCasterComponentsResponse));
            return describeCasterComponentsResponse;
    
        }
    
    
        /**
         * プロダクションスタジオのコンポーネントを更新します。
         *
         * @param client      ApsaraVideo Live クライアントインスタンス。
         * @param casterId    プロダクションスタジオの ID。
         * @param componentId コンポーネントの ID。
         * @throws Exception API リクエストまたは処理中にエラーが発生した場合に例外をスローします。
         */
        private void modifyCasterComponent(Client client, String casterId, String componentId) throws Exception {
            JSONObject componentLayer = new JSONObject();
            componentLayer.put("HeightNormalized", 0.6);
            componentLayer.put("WidthNormalized", 0.6);
            JSONArray positionNormalized = new JSONArray();
            positionNormalized.add("0.3");
            positionNormalized.add("0.3");
            componentLayer.put("PositionNormalized", positionNormalized);
            componentLayer.put("PositionRefer", "topLeft");
            JSONObject textLayerContent = new JSONObject();// TextLayerContent コンポーネント。
            textLayerContent.put("Text", "hello world!");
            textLayerContent.put("Color", 0xff0000);
            textLayerContent.put("FontName", "KaiTi");
            textLayerContent.put("SizeNormalized", 0.3F);
            textLayerContent.put("BorderWidthNormalized", 0.3F);
            textLayerContent.put("BorderColor", 0xff0000);
            ModifyCasterComponentRequest modifyCasterComponentRequest = new ModifyCasterComponentRequest(); // コンポーネント要素のプロパティを設定します。
            modifyCasterComponentRequest.setCasterId(casterId);
            modifyCasterComponentRequest.setComponentId(componentId);
            modifyCasterComponentRequest.setComponentName("newComponentName");
            modifyCasterComponentRequest.setComponentType("text");
            modifyCasterComponentRequest.setTextLayerContent(textLayerContent.toJSONString());
            modifyCasterComponentRequest.setEffect("none"); // 効果なし。
            modifyCasterComponentRequest.setComponentLayer(componentLayer.toJSONString());
            ModifyCasterComponentResponse modifyCasterComponentResponse = client.modifyCasterComponent(modifyCasterComponentRequest);
            System.out.println("コンポーネントを変更します。戻り値: " + JSON.toJSONString(modifyCasterComponentResponse));
        }
    
        /**
         * キャスターコンポーネントを削除します。
         *
         * @param client      ApsaraVideo Live クライアントインスタンス。
         * @param casterId    プロダクションスタジオの ID。
         * @param componentId コンポーネントの ID。
         * @throws Exception 削除操作中にスローされる可能性のある例外。
         */
        private void deleteCasterComponent(Client client, String casterId, String componentId) throws Exception {
            // コンポーネントを削除するためのリクエストオブジェクトを構築し、パラメーターを設定します。
            DeleteCasterComponentRequest deleteCasterComponentRequest = new DeleteCasterComponentRequest();
            deleteCasterComponentRequest.setCasterId(casterId);
            deleteCasterComponentRequest.setComponentId(componentId);
    
            // クライアントインターフェイスを呼び出して削除操作を実行します。
            DeleteCasterComponentResponse deleteCasterComponentResponse = client.deleteCasterComponent(deleteCasterComponentRequest);
    
            // 削除結果を出力します。
            System.out.println("コンポーネントを削除します。戻り値: " + JSON.toJSONString(deleteCasterComponentResponse));
        }
  4. レイアウトを編集します。

    説明

    出力コンテンツのレイアウトを構成します。画面とその場所をカスタマイズできます。レイアウトには最大 4 つの画面を作成できます。

    関連 API 操作

    サンプルコード

     /**
         * プロダクションスタジオにレイアウトを追加します。
         *
         * @param client   ApsaraVideo Live クライアントインスタンス。
         * @param casterId 操作するプロダクションスタジオの ID。
         * @return 新しく作成されたレイアウトの ID。
         * @throws Exception API 呼び出しが失敗した場合、またはその他の例外が発生した場合に例外をスローします。
         */
        private String addCasterLayout(Client client, String casterId) throws Exception {
            // プロダクションスタジオのレイアウトを追加するためのリクエストオブジェクトを作成し、基本パラメーターを設定します。
            AddCasterLayoutRequest addCasterLayoutRequest = new AddCasterLayoutRequest();
            addCasterLayoutRequest.setCasterId(casterId);
            addCasterLayoutRequest.setBlendList(Arrays.asList("RV01"));
            addCasterLayoutRequest.setMixList(Arrays.asList("RV01"));
    
            // ビデオレイヤーのパラメーターを構成します。
            List<AddCasterLayoutRequest.AddCasterLayoutRequestVideoLayer> videoLayers = new ArrayList<>();
            AddCasterLayoutRequest.AddCasterLayoutRequestVideoLayer videoLayer = new AddCasterLayoutRequest.AddCasterLayoutRequestVideoLayer();
            videoLayer.setFillMode("fit");
            videoLayer.setHeightNormalized(0.5F);
            videoLayer.setWidthNormalized(0.5F);
            videoLayer.setPositionRefer("topLeft");
            videoLayer.setPositionNormalized(Arrays.asList(0.1F, 0.1F));
            videoLayer.setFixedDelayDuration(0);
            videoLayers.add(videoLayer);
            addCasterLayoutRequest.setVideoLayer(videoLayers);
    
            // オーディオレイヤーのパラメーターを構成します。
            List<AddCasterLayoutRequest.AddCasterLayoutRequestAudioLayer> audioLayers = new ArrayList<>();
            AddCasterLayoutRequest.AddCasterLayoutRequestAudioLayer audioLayer = new AddCasterLayoutRequest.AddCasterLayoutRequestAudioLayer();
            audioLayer.setVolumeRate(1.0F);
            audioLayer.setValidChannel("all");
            audioLayer.setFixedDelayDuration(0);
            audioLayers.add(audioLayer);
            addCasterLayoutRequest.setAudioLayer(audioLayers);
    
            // API を呼び出してプロダクションスタジオのレイアウトを追加します。
            AddCasterLayoutResponse addCasterLayoutResponse = client.addCasterLayout(addCasterLayoutRequest);
            System.out.println("プロダクションスタジオのレイアウトを追加します。応答:" + JSON.toJSONString(addCasterLayoutResponse));
            return addCasterLayoutResponse.getBody().getLayoutId();
        }
    
    
        /**
         * プロダクションスタジオのレイアウトリストをクエリします。
         *
         * @param client   ApsaraVideo Live クライアントインスタンス。
         * @param casterId プロダクションスタジオの ID。
         * @param layoutId レイアウトの ID。
         * @return DescribeCasterLayoutsResponse レイアウトリストの応答オブジェクト。
         * @throws Exception API 呼び出し中にスローされる可能性のある例外。
         */
        private DescribeCasterLayoutsResponse describeCasterLayouts(Client client, String casterId, String layoutId) throws Exception {
            // レイアウトリストをクエリするためのリクエストパラメーターを構築します。
            DescribeCasterLayoutsRequest describeCasterLayoutsRequest = new DescribeCasterLayoutsRequest();
            describeCasterLayoutsRequest.setCasterId(casterId);
            describeCasterLayoutsRequest.setLayoutId(layoutId);
    
            // クライアント API を呼び出してレイアウトリストをクエリします。
            DescribeCasterLayoutsResponse describeCasterLayoutsResponse = client.describeCasterLayouts(describeCasterLayoutsRequest);
            System.out.println("レイアウトリストをクエリします。戻り値: " + JSON.toJSONString(describeCasterLayoutsResponse));
            return describeCasterLayoutsResponse;
        }
    
    
        /**
         * プロダクションスタジオのレイアウトを変更します。
         *
         * @param client   ApsaraVideo Live クライアントインスタンス。
         * @param casterId 変更するプロダクションスタジオの ID。
         * @param layoutId 適用するレイアウトテンプレートの ID。
         * @throws Exception API 呼び出しが失敗した場合、またはパラメーターが無効な場合に例外をスローします。
         */
        private void modifyCasterLayout(Client client, String casterId, String layoutId) throws Exception {
            ModifyCasterLayoutRequest modifyCasterLayoutRequest = new ModifyCasterLayoutRequest();
            modifyCasterLayoutRequest.setCasterId(casterId);
            modifyCasterLayoutRequest.setLayoutId(layoutId);
            modifyCasterLayoutRequest.setBlendList(Arrays.asList("RV02"));
            modifyCasterLayoutRequest.setMixList(Arrays.asList("RV02"));
    
            // ビデオレイヤーのパラメーターを構成します。
            List<ModifyCasterLayoutRequest.ModifyCasterLayoutRequestVideoLayer> videoLayers = new ArrayList<>();
            ModifyCasterLayoutRequest.ModifyCasterLayoutRequestVideoLayer videoLayer = new ModifyCasterLayoutRequest.ModifyCasterLayoutRequestVideoLayer();
            videoLayer.setFillMode("fit");
            videoLayer.setHeightNormalized(1.0F);
            videoLayer.setWidthNormalized(1.0F);
            videoLayer.setPositionRefer("topLeft");
            videoLayer.setPositionNormalized(Arrays.asList(0.1F, 0.1F));
            videoLayer.setFixedDelayDuration(0);
            videoLayers.add(videoLayer);
            modifyCasterLayoutRequest.setVideoLayer(videoLayers);
    
            // オーディオレイヤーのパラメーターを構成します。
            List<ModifyCasterLayoutRequest.ModifyCasterLayoutRequestAudioLayer> audioLayers = new ArrayList<>();
            ModifyCasterLayoutRequest.ModifyCasterLayoutRequestAudioLayer audioLayer = new ModifyCasterLayoutRequest.ModifyCasterLayoutRequestAudioLayer();
            audioLayer.setVolumeRate(1.0F);
            audioLayer.setValidChannel("all");
            audioLayer.setFixedDelayDuration(0);
            audioLayers.add(audioLayer);
            modifyCasterLayoutRequest.setAudioLayer(audioLayers);
    
            // API を呼び出してプロダクションスタジオのレイアウトを変更し、応答を出力します。
            ModifyCasterLayoutResponse modifyCasterLayoutResponse = client.modifyCasterLayout(modifyCasterLayoutRequest);
            System.out.println("プロダクションスタジオのレイアウトを変更します。応答:" + JSON.toJSONString(modifyCasterLayoutResponse));
        }
    
    
        /**
         * プロダクションスタジオのレイアウトを削除します。
         *
         * @param client   ApsaraVideo Live クライアントインスタンス。
         * @param casterId 操作するプロダクションスタジオの ID。
         * @param layoutId 削除するレイアウトの ID。
         * @throws Exception 削除操作が失敗した場合に例外をスローします。
         */
        private void deleteCasterLayout(Client client, String casterId, String layoutId) throws Exception {
            // プロダクションスタジオのレイアウトを削除するためのリクエストパラメーターを構築します。
            DeleteCasterLayoutRequest deleteCasterLayoutRequest = new DeleteCasterLayoutRequest();
            deleteCasterLayoutRequest.setCasterId(casterId);
            deleteCasterLayoutRequest.setLayoutId(layoutId);
    
            // クライアントインターフェイスを呼び出して削除操作を実行し、応答を出力します。
            DeleteCasterLayoutResponse deleteCasterLayoutResponse = client.deleteCasterLayout(deleteCasterLayoutRequest);
            System.out.println("プロダクションスタジオのレイアウトを削除します。応答:" + JSON.toJSONString(deleteCasterLayoutResponse));
        }
    
  5. プロダクションスタジオを開始します。

    サンプルコード

    プロダクションスタジオを作成して構成した後、プロダクションスタジオを開始できます。これにより、関連するオーディオおよびビデオ処理タスクが開始されます。

    前提条件

    ドメイン名や出力ビデオの解像度など、プロダクションスタジオの設定が構成されています。

    関連 API 操作

    StartCaster - プロダクションスタジオを開始する

    説明

    プロダクションスタジオを開始すると、シーン ID やライブストリームに関する情報など、PVW および PGM シーンに関する情報が返されます。シーン ID でシーンを指定できます。

    サンプルコード

    /**
         * プロダクションスタジオを開始します。
         *
         * @param client   ApsaraVideo Live クライアントインスタンス。
         * @param casterId 開始するプロダクションスタジオの ID。
         * @return StartCasterResponse プロダクションスタジオを開始するための応答。
         * @throws Exception 起動プロセス中にスローされる可能性のある例外。
         */
        private StartCasterResponse startCaster(Client client, String casterId) throws Exception {
            // プロダクションスタジオを開始するためのリクエストパラメーターを構築します。
            StartCasterRequest startCasterRequest = new StartCasterRequest();
            startCasterRequest.setCasterId(casterId);
            StartCasterResponse startCasterResponse = client.startCaster(startCasterRequest);
            System.out.println("プロダクションスタジオが開始されました。");
            return startCasterResponse;
        }
  6. シーンを更新します。

    説明

    プロダクションスタジオが開始された後、構成されたレイアウトまたはコンポーネントを特定のシーンに適用できます。

    前提条件

    • レイアウトまたはコンポーネントが構成されています。

    • 特定のシーンが作成され、有効になっています。

    関連 API 操作

    UpdateCasterSceneConfig - プロダクションスタジオシーンの構成を更新する

    サンプルコード

    /**
         * プロダクションスタジオのシーン構成を更新します。
         *
         * @param client       ApsaraVideo Live クライアントインスタンス。
         * @param casterId     プロダクションスタジオの ID。
         * @param sceneId      シーンの ID。
         * @param layoutId     レイアウトの ID。
         * @param componentIds コンポーネント ID のリスト。
         * @throws Exception API 呼び出しが失敗した場合に例外をスローします。
         */
        private void updateCasterSceneConfig(Client client, String casterId, String sceneId, String layoutId, List<String> componentIds) throws Exception {
            // プロダクションスタジオのシーン構成を更新するためのリクエストオブジェクトを構築します。
            UpdateCasterSceneConfigRequest updateCasterSceneConfigRequest = new UpdateCasterSceneConfigRequest();
            updateCasterSceneConfigRequest.setCasterId(casterId);
            updateCasterSceneConfigRequest.setSceneId(sceneId);
            updateCasterSceneConfigRequest.setComponentId(componentIds);
            updateCasterSceneConfigRequest.setLayoutId(layoutId);
    
            // クライアントインターフェイスを呼び出して、プロダクションスタジオのシーン構成を更新します。
            UpdateCasterSceneConfigResponse updateCasterSceneConfigResponse = client.updateCasterSceneConfig(updateCasterSceneConfigRequest);
            System.out.println("プロダクションスタジオのシーン構成を更新します。応答:" + JSON.toJSONString(updateCasterSceneConfigResponse));
        }
    
  7. PVW から PGM に切り替えます。

    説明

    プロダクションスタジオが開始された後、PVW シーンのレイアウト設定を PGM シーンに適用できます。

    前提条件

    • PVW シーンが作成され、有効になっています。

    • PGM シーンが作成され、有効になっています。

    関連 API 操作

    CopyCasterSceneConfig - プロダクションスタジオシーンの構成をコピーする

    サンプルコード

    /**
         * プロダクションスタジオのシーン構成をコピーします。
         *
         * @param client      ApsaraVideo Live クライアントインスタンス。
         * @param casterId    プロダクションスタジオの ID。
         * @param fromSceneID ソースシーンの ID。
         * @param toSceneID   宛先シーンの ID。
         * @throws Exception コピー操作が失敗した場合に例外をスローします。
         */
        private void copyCasterSceneConfig(Client client, String casterId, String fromSceneID, String toSceneID) throws Exception {
            // プロダクションスタジオのシーン構成をコピーするためのリクエストオブジェクトを構築します。
            CopyCasterSceneConfigRequest copyCasterSceneConfigRequest = new CopyCasterSceneConfigRequest();
            copyCasterSceneConfigRequest.setCasterId(casterId);
            copyCasterSceneConfigRequest.setFromSceneId(fromSceneID);
            copyCasterSceneConfigRequest.setToSceneId(toSceneID);
    
            // クライアントインターフェイスを呼び出してコピー操作を実行し、結果を出力します。
            CopyCasterSceneConfigResponse copyCasterSceneConfigResponse = client.copyCasterSceneConfig(copyCasterSceneConfigRequest);
            System.out.println("プロダクションスタジオのシーン構成をコピーします。応答:" + JSON.toJSONString(copyCasterSceneConfigResponse));
        }
  8. PVW モードを有効または無効にします。

    説明

    プロダクションスタジオが開始された後、PVW モードを有効または無効にして PVW シーンを制御できます。PVW シーンが無効になると、レイアウトとビデオソースの変更を PGM シーンに直接適用できます。

    前提条件

    PVW シーンが作成されています。

    関連 API 操作

    サンプルコード

    /**
         * PVW モードを有効にします。
         *
         * @param client     ApsaraVideo Live クライアントインスタンス。
         * @param casterId   プロダクションスタジオの ID。
         * @param pvwSceneId シーンの ID。
         * @throws Exception API 呼び出しが失敗した場合に例外をスローします。
         */
        private void startCasterScene(Client client, String casterId, String pvwSceneId) throws Exception {
            // プロダクションスタジオのシーンを開始するためのリクエストパラメーターを構築します。
            StartCasterSceneRequest startCasterSceneRequest = new StartCasterSceneRequest();
            startCasterSceneRequest.setCasterId(casterId);
            startCasterSceneRequest.setSceneId(pvwSceneId);
    
            // インターフェイスを呼び出してプロダクションスタジオのシーンを開始します。
            StartCasterSceneResponse startCasterSceneResponse = client.startCasterScene(startCasterSceneRequest);
            System.out.println("PVW シーンを有効にします。応答:" + JSON.toJSONString(startCasterSceneResponse));
        }
    
     /**
         * PVW モードを無効にします。
         *
         * @param client     ApsaraVideo Live クライアントインスタンス。
         * @param casterId   プロダクションスタジオの ID。
         * @param pvwSceneId シーンの ID。
         * @throws Exception API 呼び出しが失敗した場合に例外をスローします。
         */
        private void stopCasterScene(Client client, String casterId, String pvwSceneId) throws Exception {
            // プロダクションスタジオのシーンを停止するためのリクエストパラメーターを構築します。
            StopCasterSceneRequest stopCasterSceneRequest = new StopCasterSceneRequest();
            stopCasterSceneRequest.setCasterId(casterId);
            stopCasterSceneRequest.setSceneId(pvwSceneId);
    
            // クライアントインターフェイスを呼び出してプロダクションスタジオのシーンを停止します。
            StopCasterSceneResponse stopCasterSceneResponse = client.stopCasterScene(stopCasterSceneRequest);
    
            // PVW シーンを無効にするための応答を出力します。
            System.out.println("PVW シーンを無効にします。応答:" + JSON.toJSONString(stopCasterSceneResponse));
        }
  9. スタンバイリソースに切り替え、ライブストリームに戻します。

    説明

    プロダクションスタジオが開始された後、PGM シーンのスタンバイリソースに切り替えることができます。ライブストリームに戻すこともできます。

    前提条件

    • プロダクションスタジオが開始されています。

    • スタンバイリソースの ID が指定されています。

    関連 API 操作

    サンプルコード

     /**
         * プロダクションスタジオで緊急エフェクト切り替え操作を実行して、PGM シーンをスタンバイスクリーンに切り替えます。
         *
         * @param client     ApsaraVideo Live クライアントインスタンス。
         * @param casterId   プロダクションスタジオの ID。
         * @param pgmSceneId PGM シーンの ID。
         * @throws Exception API 呼び出しまたは実行中にエラーが発生した場合に例外をスローします。
         */
        private void effectCasterUrgent(Client client, String casterId, String pgmSceneId) throws Exception {
            // 緊急エフェクト切り替えのリクエストオブジェクトを構築します。
            EffectCasterUrgentRequest effectCasterUrgentRequest = new EffectCasterUrgentRequest();
            effectCasterUrgentRequest.setCasterId(casterId);
            effectCasterUrgentRequest.setSceneId(pgmSceneId);
    
            // クライアントインターフェイスを呼び出して緊急エfect切り替えを実行します。
            EffectCasterUrgentResponse effectCasterUrgentResponse = client.effectCasterUrgent(effectCasterUrgentRequest);
    
            // 切り替え結果ログを出力します。
            System.out.println("PGM シーンをスタンバイスクリーンに切り替えます。応答: " + JSON.toJSONString(effectCasterUrgentResponse));
        }
    
    
        /**
         * プロダクションスタジオのシーン構成を設定して、ライブストリームに戻します。
         *
         * @param client     ApsaraVideo Live クライアントインスタンス。
         * @param casterId   プロダクションスタジオの ID。
         * @param pgmSceneId PGM シーンの ID。
         * @param layoutId   レイアウトの ID。
         * @throws Exception API 呼び出しが失敗した場合に例外をスローします。
         */
        private void setCasterSceneConfig(Client client, String casterId, String pgmSceneId, String layoutId) throws Exception {
            // プロダクションスタジオのシーン構成を設定するためのリクエストオブジェクトを構築します。
            SetCasterSceneConfigRequest setCasterSceneConfigRequest = new SetCasterSceneConfigRequest();
            setCasterSceneConfigRequest.setCasterId(casterId);
            setCasterSceneConfigRequest.setSceneId(pgmSceneId);
            setCasterSceneConfigRequest.setLayoutId(layoutId); // スタンバイ再生を終了するには、null を渡します。指定したレイアウトに切り替えるには、layoutId を入力します。
    
            // クライアント API を呼び出して、プロダクションスタジオのシーン構成を設定します。
            SetCasterSceneConfigResponse setCasterSceneConfigResponse = client.setCasterSceneConfig(setCasterSceneConfigRequest);
    
            // 応答を出力します。
            System.out.println("スタンバイスクリーンをライブスクリーンに切り替えます。応答: " + JSON.toJSONString(setCasterSceneConfigResponse));
        }
  10. プロダクションスタジオを停止します。

    説明

    プロダクションスタジオが開始された後、プロダクションスタジオとそのオーディオおよびビデオ処理タスクを停止できます。

    前提条件

    プロダクションスタジオが開始されています。

    関連 API 操作

    StopCaster - プロダクションスタジオを停止する

    サンプルコード

     /**
         * 指定されたプロダクションスタジオを停止します。
         *
         * @param client   ApsaraVideo Live クライアントインスタンス。
         * @param casterId 停止するプロダクションスタジオの ID。
         * @throws Exception プロダクションスタジオを停止する操作が失敗した場合に例外をスローします。
         */
        private void stopCaster(Client client, String casterId) throws Exception {
            StopCasterRequest request = new StopCasterRequest();
            request.setCasterId(casterId);
            StopCasterResponse response = client.stopCaster(request);
            System.out.println("プロダクションスタジオを停止します。応答: " + JSON.toJSONString(response));
        }