إرسال محتوى YouTube المباشر عبر بروتوكول RTMPS
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
يوضّح هذا المستند كيفية استخدام بروتوكول RTMPS لبث بيانات مباشرة على YouTube من برنامج ترميز. بروتوكول RTMPS هو بث فيديو عادي باستخدام بروتوكول RTMP (بروتوكول المراسلة في الوقت الفعلي) يتم نقله عبر اتصال SSL. هذا المستند مخصّص لمورّدي برامج الترميز الذين يريدون إضافة إمكانية استخدام بروتوكول RTMPS إلى برامج الترميز التي تتوافق حاليًا مع بروتوكول RTMP.
يُعدّ بروتوكول RTMPS خيارًا جيدًا لمعظم محتوى المستخدمين العاديين، خاصةً إذا كان يتطلّب زمن انتقال منخفضًا. يمكنك الاطّلاع على مقارنة بين بروتوكولات النقل للحصول على نظرة عامة حول بروتوكولات النقل المختلفة التي يتيحها "بث YouTube المباشر".
المتطلبات
يجب استيفاء بعض الشروط الأساسية قبل إرسال محتوى باستخدام بروتوكول RTMPS إلى "بث YouTube المباشر":
- يجب أن تكون كل أجزاء عنوان URL الخاص بالاتصال (
<protocol>://<server>/<path>
) صحيحة:
- يجب أن يكون البروتوكول
rtmps
.
- يجب أن يكون الخادم نقطة نهاية صالحة لاستيعاب بيانات RTMPS في YouTube.
- يجب أن يكون المسار اسم تطبيق صالحًا في YouTube Live RTMP.
- يجب إجراء الاتصال بالمنفذ 443 على خادم الاستيعاب.
- يجب إرسال بث الوسائط المتعددة باستخدام بروتوكول RTMPS، أي باستخدام بروتوكول RTMP عبر اتصال SSL.
الحصول على عنوان URL للاتصال
إذا كان برنامج الترميز يستخدم حاليًا YouTube Live API، ستكون عملية الحصول على عنوان URL لعرض المحتوى وفق بروتوكول RTMPS مشابهة لتلك الخاصة ببروتوكول RTMP. أرسِل طلب LiveStreams insert (POST) لإنشاء بث جديد. في الردّ، يحدّد الحقل
cdn.ingestionInfo.rtmpsIngestionAddress
عنوان URL الخاص ببروتوكول RTMPS. إذا كنت تتيح إمكانية إدخال البيانات المزدوج، سيكون عنوان النسخة الاحتياطية هو cdn.ingestionInfo.rtmpsBackupIngestionAddress
.
إنشاء عملية الربط
استخدِم مكتبة المقابس المفضّلة لديك لإنشاء اتصال SSL/TLS بالمنفذ 443 على الخادم الذي يحدّده عنوان URL الخاص بنقل البيانات. بما أنّ بروتوكول أمان طبقة النقل (TLS) يعمل فقط مع طبقة النقل، لا يُشترط توفّر اسم المضيف للخادم لبدء الاتصال، ولكنّه مطلوب للمصادقة مع خوادمنا. لذا، احرص على إضافة إضافة SNI (الإشارة إلى اسم الخادم) إلى عملية المصافحة عبر SSL، واضبط اسم الخادم على اسم مضيف الخادم الذي تتصل به.
بعد إنشاء اتصال SSL، استخدِم هذا الاتصال لمكتبة عميل RTMP. يحتوي اتصال طبقة المقابس الآمنة الذي تم إعداده على واجهة برمجة التطبيقات نفسها لاتصال TCP العادي، وبالتالي من المفترض أن تتمكّن مكتبة RTMP من العمل مع كليهما بالطريقة نفسها.
تحديد المشاكل وحلّها
الأخطاء في طبقة المقابس الآمنة
إذا حاولت إنشاء اتصال عبر طبقة المقابس الآمنة (SSL) ولكن تلقّيت شهادة غير صالحة، من المحتمل أنّك تتصل بخادم YouTube يتوقّع بروتوكول RTMP. تأكَّد من أنّ اسم الخادم الذي تستخدمه يتضمّن "rtmps"، مع الانتباه إلى حرف "s".
إذا كان عنوان URL يبدو صحيحًا ولكن تظهر لك مع ذلك رسالة خطأ بأنّ طبقة المقابس الآمنة غير صالحة، قد يكون السبب أنّك تتصل بمنفذ غير صحيح. تأكَّد من أنّك تتصل بالمنفذ 443.
إذا كان عنوان URL والمنفذ صحيحَين، قد لا تتعامل مكتبة SSL مع الشهادة بشكلٍ صحيح. ابحث عن رسائل تشخيصية منخفضة المستوى بشأن أخطاء SSL، وتأكَّد من أنّك تستخدم SNI في عملية المصافحة.
انتهت مهلة الاتصال
إذا كان بإمكانك الاتصال بالخادم، ولكن انتهت المهلة المحددة لمكتبة RTMP بدون تلقّي ردّ مفهوم، من المحتمل أنّك أعددت اتصال RTMP بنص عادي بخادم YouTube الذي يتوقّع بروتوكول RTMPS. تأكَّد من أنّك تنشئ اتصالاً عبر بروتوكول SSL، وليس اتصالاً عاديًا عبر بروتوكول TCP.
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة 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."]]