העברת תוכן לשידור חי ב-YouTube באמצעות RTMPS
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
במסמך הזה מוסבר איך להשתמש ב-RTMPS כדי לשדר נתונים בשידור חי ב-YouTube ממקודד. RTMPS הוא סטרימינג וידאו רגיל של RTMP (RealTime Messaging Protocol) שמועבר דרך חיבור SSL. המסמך הזה מיועד לספקי מקודדים שרוצים להוסיף תמיכה ב-RTMPS למקודדים שכבר תומכים ב-RTMP.
פרוטוקול RTMPS הוא בחירה טובה לרוב התוכן של משתמשים רגילים, במיוחד אם נדרש זמן אחזור נמוך. במאמר השוואה בין פרוטוקולים להטמעת נתונים מופיעה סקירה כללית של הפרוטוקולים השונים להטמעת נתונים שנתמכים ב-YouTube בשידור חי.
דרישות
יש כמה דרישות מוקדמות לשליחת RTMPS ל-YouTube בשידור חי:
- כל חלק בכתובת ה-URL של החיבור (
<protocol>://<server>/<path>
) צריך להיות נכון:
- הפרוטוקול חייב להיות
rtmps
.
- השרת חייב להיות נקודת קצה תקפה להעלאה ב-RTMPS ב-YouTube.
- הנתיב חייב להיות שם אפליקציית RTMP תקין של YouTube בשידור חי.
- החיבור צריך להתבצע ליציאה 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 (Server Name Indication) ללחיצת היד של SSL, ולהגדיר את שם השרת לשם המארח של השרת שאליו מתחברים.
אחרי שנוצר חיבור 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 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-08-21 (שעון UTC).
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 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."]]