RTMPS を介した YouTube ライブ コンテンツの配信
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
このドキュメントでは、RTMPS を使用してエンコーダから YouTube でライブデータをストリーミングする方法について説明します。RTMPS は、SSL 接続を介してトンネリングされた通常の RTMP(リアルタイム メッセージング プロトコル)動画ストリームです。このドキュメントは、RTMP をすでにサポートしているエンコーダに RTMPS のサポートを追加したいエンコーダ ベンダーを対象としています。
RTMPS は、ほとんどの一般的なユーザー コンテンツに適しています。特に、低レイテンシが求められる場合に適しています。YouTube ライブ配信がサポートするさまざまな取り込みプロトコルの概要については、取り込みプロトコルの比較をご覧ください。
要件
RTMPS を YouTube ライブに送信するには、いくつかの前提条件があります。
- 接続 URL(
<protocol>://<server>/<path>
)の各部分が正しい必要があります。
- プロトコルは
rtmps
である必要があります。
- サーバーは有効な YouTube RTMPS 取り込みエンドポイントである必要があります。
- パスは有効な YouTube ライブ RTMP アプリケーション名でなければなりません。
- 接続は取り込みサーバーのポート 443 に対して行う必要があります。
- マルチメディア ストリームは RTMPS で送信する必要があります。つまり、SSL 接続を介して RTMP を使用します。
接続 URL の取得
エンコーダで YouTube Live API をすでに使用している場合、RTMPS 取り込み URL を取得するプロセスは RTMP の場合と似ています。LiveStreams の挿入(POST)リクエストを送信して、新しい取り込みストリームを作成します。レスポンスの cdn.ingestionInfo.rtmpsIngestionAddress
フィールドには、RTMPS URL が指定されています。二重取り込みをサポートしている場合、バックアップ アドレスは cdn.ingestionInfo.rtmpsBackupIngestionAddress
です。
接続の作成
任意のソケット ライブラリを使用して、取り込み URL で指定されたサーバーのポート 443 への SSL/TLS 接続を作成します。TLS はトランスポート レイヤでのみ機能するため、接続の開始にサーバーのホスト名は厳密には必要ありませんが、Google のサーバーでの認証には必要です。そのため、SSL ハンドシェイクに SNI 拡張機能(Server Name Indication)を追加し、接続先のサーバーのホスト名にサーバー名を設定してください。
SSL 接続が確立されたら、RTMP クライアント ライブラリの接続として使用します。初期化された SSL 接続は標準の TCP 接続と同じ API を持つため、RTMP ライブラリは両方を同じように処理できるはずです。
トラブルシューティング
SSL エラー
SSL 接続を作成しようとしたときに無効な証明書が返された場合は、RTMP を想定している YouTube サーバーに接続している可能性があります。使用するサーバー名に「rtmps」が含まれていることを確認します(「s」に注意してください)。
SSL エラーが発生しているが、URL は正しいと思われる場合、間違ったポートに接続している可能性があります。ポート 443 に接続していることを確認します。
URL とポートが正しい場合、SSL ライブラリが証明書を正しく処理していない可能性があります。SSL 障害に関する低レベルの診断メッセージを探し、ハンドシェイクで SNI を使用していることを再確認します。
接続がタイムアウトしました
サーバーに接続できるものの、RTMP ライブラリがタイムアウトして適切なレスポンスが得られない場合は、RTMPS を想定している YouTube サーバーへのクリアテキスト RTMP 接続を設定している可能性があります。プレーンな TCP 接続ではなく、SSL 接続を作成していることを確認します。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-08-21 UTC。
[null,null,["最終更新日 2025-08-21 UTC。"],[[["\u003cp\u003eRTMPS is a secure method for streaming live data to YouTube, using RTMP through an SSL connection.\u003c/p\u003e\n"],["\u003cp\u003eTo use RTMPS, ensure the connection URL is correct, including the \u003ccode\u003ertmps\u003c/code\u003e protocol, a valid YouTube ingestion endpoint, and a valid application name.\u003c/p\u003e\n"],["\u003cp\u003eConnections must be made to port 443, and the server hostname is required for authentication via the SNI extension in the SSL handshake.\u003c/p\u003e\n"],["\u003cp\u003eEncoder vendors can retrieve the RTMPS ingestion URL from the \u003ccode\u003ecdn.ingestionInfo.rtmpsIngestionAddress\u003c/code\u003e field in the response of a LiveStreams insert request, similar to RTMP.\u003c/p\u003e\n"],["\u003cp\u003eCommon issues like SSL errors and connection timeouts often arise from incorrect server names, ports, or improper SSL setup, and usually indicate a cleartext RTMP connection is being attempted instead of RTMPS.\u003c/p\u003e\n"]]],["To stream live on YouTube using RTMPS, ensure the URL protocol is `rtmps`, the server is a valid YouTube RTMPS endpoint, and the path is a valid application name. Connect to port 443 with an SSL/TLS connection, including the SNI extension with the server hostname for authentication. Obtain the RTMPS URL via a `LiveStreams insert` request from the YouTube Live API. After establishing the SSL connection, use it with your RTMP library to send the multimedia stream.\n"],null,["# Delivering Live YouTube Content via RTMPS\n\nThis document explains how to use RTMPS to stream live data on YouTube from an\nencoder. RTMPS is a regular RTMP (RealTime Messaging Protocol) video stream\ntunneled through an SSL connection. This document is intended for encoder\nvendors who want to add support for RTMPS to encoders that already support RTMP.\n\nRTMPS is a good choice for most ordinary user content, especially if it requires\nlow latency. See the\n[Ingestion Protocol Comparison](/youtube/v3/live/guides/ingestion-protocol-comparison)\nfor an overview of the different ingestion protocols that YouTube Live Streaming\nsupports.\n\nRequirements\n------------\n\nSending RTMPS to YouTube Live has a few prerequisites:\n\n- Each part of the connection URL (`\u003cprotocol\u003e://\u003cserver\u003e/\u003cpath\u003e`) must be correct:\n - The protocol must be `rtmps`.\n - The server must be a valid YouTube RTMPS ingestion endpoint.\n - The path must be a valid YouTube Live RTMP application name.\n- The connection must be made to port 443 on the ingestion server.\n- The multimedia stream must be sent with RTMPS; that is, using RTMP over an SSL connection.\n\nGetting the connection URL\n--------------------------\n\nIf your encoder already uses the YouTube Live API, then the process for getting\nan RTMPS ingestion URL is similar to the one for RTMP. Send a\n[LiveStreams insert (POST)](/youtube/v3/live/docs/liveStreams/insert) request to\ncreate a new ingestion stream. In the response, the\n[`cdn.ingestionInfo.rtmpsIngestionAddress`](/youtube/v3/live/docs/liveStreams#cdn.ingestionInfo.rtmpsIngestionAddress)\nfield specifies the RTMPS URL. If you support dual ingestion, the backup address\nis [`cdn.ingestionInfo.rtmpsBackupIngestionAddress`](/youtube/v3/live/docs/liveStreams#cdn.ingestionInfo.rtmpsBackupIngestionAddress).\n\nCreating the connection\n-----------------------\n\nUse your preferred socket library to create an SSL/TLS connection to port 443 at\nthe server that the ingestion URL specifies. Since TLS works only with the\ntransport layer, the server hostname is not strictly required to initiate the\nconnection; however, it is required for authentication with our servers. So make\nsure you add the SNI extension (Server Name Indication) to your SSL handshake,\nand set the server name to the server hostname you're connecting to.\n\nOnce the SSL connection is established, use it as the connection for your RTMP\nclient library. An initialized SSL connection has the same API as a standard TCP\nconnection, and so the RTMP library should be able to work with both of them\nidentically.\n\nTroubleshooting\n---------------\n\n### SSL errors\n\nIf you attempt to create an SSL connection but get an invalid certificate, then\nyou are probably connecting to a YouTube server that expects RTMP. Make sure\nthat the server name you use has \"rtmps\" in it --- note the \"s\".\n\nIf the URL looks correct but you still get an SSL error, you might be connecting\nto the wrong port. Confirm that you're connecting to port 443.\n\nIf the URL and port are correct, your SSL library might not be handling the\ncertificate correctly. Look for low-level diagnostic messages about SSL\nfailures, and double-check that you're using SNI in the handshake.\n\n### Connection timed out\n\nIf you can connect to the server, but your RTMP library times out without\ngetting a sensible response, you might have set up a cleartext RTMP connection\nto a YouTube server that expects RTMPS. Make sure that you're creating an SSL\nconnection, not a plain TCP connection."]]