ارائه محتوای زنده YouTube از طریق RTMPS
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
این سند نحوه استفاده از RTMPS را برای پخش جریانی دادههای زنده در YouTube از یک رمزگذار توضیح میدهد. RTMPS یک جریان ویدئویی معمولی RTMP (پروتکل پیامرسانی بیدرنگ) است که از طریق یک اتصال SSL تونل میشود. این سند برای فروشندگان رمزگذار در نظر گرفته شده است که می خواهند پشتیبانی از RTMPS را به رمزگذارهایی که قبلا از RTMP پشتیبانی می کنند اضافه کنند.
RTMPS انتخاب خوبی برای اکثر محتوای کاربر معمولی است، به خصوص اگر نیاز به تاخیر کم داشته باشد. برای بررسی اجمالی پروتکلهای جذب مختلف که YouTube Live Streaming پشتیبانی میکند، به مقایسه پروتکل جذب مراجعه کنید.
الزامات
ارسال RTMPS به YouTube Live چند پیش نیاز دارد:
- هر قسمت از URL اتصال (
<protocol>://<server>/<path>
) باید صحیح باشد:- پروتکل باید
rtmps
باشد. - سرور باید یک نقطه پایانی انتقال معتبر YouTube RTMPS باشد.
- مسیر باید یک نام برنامه معتبر YouTube Live RTMP باشد.
- اتصال باید به پورت 443 در سرور انتقال داده شود.
- جریان چند رسانه ای باید با RTMPS ارسال شود. یعنی استفاده از RTMP از طریق اتصال SSL.
دریافت URL اتصال
اگر رمزگذار شما قبلاً از YouTube Live API استفاده میکند، فرآیند دریافت URL انتقال RTMPS مشابه فرآیند RTMP است. یک درخواست درج LiveStreams (POST) برای ایجاد یک جریان انتقال جدید ارسال کنید. در پاسخ، قسمت cdn.ingestionInfo.rtmpsIngestionAddress
URL RTMPS را مشخص می کند. اگر از انتقال دوگانه پشتیبانی میکنید، آدرس پشتیبان cdn.ingestionInfo.rtmpsBackupIngestionAddress
است.
ایجاد ارتباط
از کتابخانه سوکت دلخواه خود برای ایجاد اتصال SSL/TLS به پورت 443 در سروری که URL انتقال مشخص شده است استفاده کنید. از آنجایی که TLS فقط با لایه انتقال کار می کند، نام میزبان سرور برای شروع اتصال به شدت مورد نیاز نیست. با این حال، برای احراز هویت با سرورهای ما لازم است. بنابراین مطمئن شوید که پسوند SNI (Server Name Indication) را به SSL handshake خود اضافه کرده اید و نام سرور را روی نام میزبان سروری که به آن متصل می شوید تنظیم کنید.
هنگامی که اتصال SSL برقرار شد، از آن به عنوان اتصال برای کتابخانه مشتری RTMP خود استفاده کنید. یک اتصال SSL اولیه دارای همان API یک اتصال TCP استاندارد است و بنابراین کتابخانه RTMP باید بتواند با هر دوی آنها به طور یکسان کار کند.
عیب یابی
خطاهای SSL
اگر سعی می کنید یک اتصال SSL ایجاد کنید اما یک گواهی نامعتبر دریافت می کنید، احتمالاً به سرور YouTube متصل می شوید که انتظار RTMP را دارد. مطمئن شوید که نام سروری که استفاده میکنید دارای "rtmps" باشد - به "s" توجه کنید.
اگر URL درست به نظر می رسد اما همچنان با خطای SSL مواجه می شوید، ممکن است به پورت اشتباهی متصل شده باشید. تأیید کنید که به پورت 443 وصل می شوید.
اگر URL و پورت صحیح باشد، کتابخانه SSL شما ممکن است گواهی را به درستی مدیریت نکند. به دنبال پیامهای تشخیصی سطح پایین در مورد خرابی SSL باشید و دوباره بررسی کنید که از SNI در دست دادن استفاده میکنید.
زمان اتصال تمام شد
اگر میتوانید به سرور متصل شوید، اما کتابخانه RTMP شما بدون دریافت پاسخ معقول تمام میشود، ممکن است یک اتصال RTMP متن واضح را به سرور YouTube که انتظار RTMPS دارد، راهاندازی کرده باشید. مطمئن شوید که در حال ایجاد یک اتصال SSL هستید، نه یک اتصال TCP ساده.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-08-21 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-21 بهوقت ساعت هماهنگ جهانی."],[[["\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."]]