YouTube Live Streaming API - درک پخشها و جریانها
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
این راهنما یک نمای کلی از پخش ها و جریان ها ارائه می دهد. همچنین موارد استفاده را مورد بحث قرار می دهد که نشان می دهد چگونه پخش کنندگان از YouTube Live Streaming API برای ایجاد و مدیریت آن منابع استفاده می کنند.
پخش رویدادی را نشان میدهد که میتوان آن را در YouTube تماشا کرد. هر پخش یک ویدیوی YouTube مجزا است. یک پخش می تواند و باید دقیقاً به یک جریان متصل شود.
یک جریان به شما امکان میدهد محتوای صوتی و تصویری را به YouTube منتقل کنید و تنظیماتی را برای نحوه پخش محتوای خود در YouTube تعیین میکند. همین جریان را می توان به حداکثر سه پخش زنده متصل کرد. همچنین معمول است که پخشکنندهها از یک جریان برای بسیاری از پخشهای مختلف استفاده مجدد کنند، اگر این پخشها در زمانهای مختلف اتفاق بیفتند.
بخشهای باقیمانده سه مورد استفاده را ارائه میکنند که نحوه استفاده کاربران API معمولاً از پخشها و جریانها را توضیح میدهد.
یک رمزگذار واحد را پیکربندی کنید
در رایجترین موارد استفاده از API، کانال YouTube شما دارای یک سری رویدادهای زنده برنامهریزیشده یا تکرارشونده است. به عنوان مالک کانال، شما یک رمزگذار واحد دارید و فقط یک بار می خواهید رمزگذار را پیکربندی کنید. بنابراین، شما مراحل زیر را انجام دهید:
- یک منبع
liveStream
در API ایجاد کنید. - از تنظیمات تحویل محتوا از آن منبع برای پیکربندی رمزگذار برای کانال استفاده کنید.
توجه داشته باشید که اگر چندین کانال دارید، باید برای هر کانال یک جریان متفاوت ایجاد کنید.
- منابع
liveBroadcast
را در API ایجاد کنید و همه آن منابع را به منبع liveStream
متصل کنید . در این سناریو، هر رویداد زندهای که برای کانال خود برنامهریزی میکنید از همان تنظیمات پخش جریانی استفاده میکند. با این حال، در هر زمان معین فقط یک رویداد زنده است و محتوای ویدیویی برای هر پخش منحصر به فرد است. - هر زمان که رویدادی رخ داد، وضعیت پخش را بهصورت
testing
یا live
بهروزرسانی کنید و به پخش آن رویداد در YouTube ادامه دهید.
ایجاد یک جریان در هر پخش
یکی دیگر از رویکردهای رایج ایجاد یک جریان جداگانه برای هر پخش است. در این سناریو، شما باید یک منبع liveStream
برای هر منبع liveBroadcast
ایجاد کنید و سپس رمزگذار جریان خود را برای استفاده از تنظیمات مناسب برای هر پخش پیکربندی کنید.
این رویکرد ممکن است منطقی باشد اگر کانال شما چندین پخش تکراری داشته باشد به طوری که ممکن است دو پخش به طور همزمان انجام شود و استفاده از تنظیمات پخش یکسان برای هر دو پخش غیرممکن شود. در واقع، کانال شما ممکن است هر پخش تکراری را به عنوان یک نمایش در نظر بگیرد و فقط یک منبع liveStream
در هر نمایش ایجاد کند. سپس، هر قسمت از همان برنامه نشان دهنده یک پخش خواهد بود و همه پخشهای یک نمایش میتوانند به یک جریان متصل شوند.
از یک جریان برای ایجاد پخش همزمان استفاده کنید
در این سناریو، شما می خواهید یک پخش زنده را به چند پخش همزمان تقسیم کنید. به این ترتیب، شما یک منبع liveStream
دارید که به دو (یا چند) منبع liveBroadcast
متصل است که به طور همزمان وضعیت live
دارند.
به عنوان مثال، فرض کنید کانال شما یک فید زنده 24/7 پخش می کند، اما همچنین می خواهید یک ویدیوی جداگانه برای مصاحبه ای که در طول آن پخش اتفاق می افتد ایجاد کنید. در این صورت محتوای مصاحبه زیرمجموعه ای از محتوای پخش 24 ساعته است.
برای رسیدگی به این مورد، دو منبع liveBroadcast
ایجاد میکنید و هر دو پخش را به یک جریان متصل میکنید. پخش 24/7 ادامه دارد و منبع آن مدت ها قبل از شروع مصاحبه وضعیت live
دارد. هنگامی که مصاحبه شروع می شود، وضعیت منبع مرتبط با مصاحبه را بدون تغییر منبع پخش 24 ساعته به live
به روز می کنید. بنابراین، شما در حال پخش همزمان محتوای یکسان به دو ویدیوی مجزا هستید.
هنگامی که مصاحبه به پایان می رسد، منبع پخش مصاحبه را دوباره به روز می کنید، این بار وضعیت آن را complete
تنظیم می کنید. با این حال، از زمانی که پخش 24/7 ادامه دارد، پخش ویدیو را متوقف نمی کنید.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2024-08-15 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2024-08-15 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eA broadcast represents a live event on YouTube, functioning as a distinct video, and it must be linked to one stream.\u003c/p\u003e\n"],["\u003cp\u003eA stream is used to send audio-video content to YouTube, defining the settings for that stream, and one stream can be connected to up to three live broadcasts.\u003c/p\u003e\n"],["\u003cp\u003eBroadcasters often use the same stream for numerous broadcasts that occur at different times, reusing stream settings and reducing redundant setup.\u003c/p\u003e\n"],["\u003cp\u003eThe API can be used in multiple ways, whether it be one stream for multiple broadcasts, one stream per broadcast, or a single stream being split into multiple simultaneous broadcasts.\u003c/p\u003e\n"],["\u003cp\u003eChannels can use the API to schedule recurring live events with a single encoder, configuring it just once for multiple broadcasts.\u003c/p\u003e\n"]]],["Broadcasts represent distinct YouTube live events, each bound to one stream. Streams transmit audio-video content to YouTube and define streaming settings. Broadcasters often reuse streams for multiple broadcasts at different times. Common use cases include: configuring one stream for multiple scheduled broadcasts, creating a unique stream per broadcast, or using a single stream for simultaneous broadcasts. For the last case, one stream can be used to have up to 3 simultaneous live broadcasts. API users create and bind these resources.\n"],null,["# YouTube Live Streaming API - Understanding Broadcasts and Streams\n\nThis guide provides a brief overview of **broadcasts** and **streams**. It also discusses use cases that show how broadcasters use the YouTube Live Streaming API to create and manage those resources.\n\n- A **broadcast** represents an event that can be watched on YouTube as it happens. Each broadcast is a distinct YouTube video. A broadcast can be and needs to be bound to exactly one stream.\n\n- A **stream** enables you to transmit audio-video content to YouTube, and it defines the settings for how you stream your content to YouTube. The same stream can be bound to up to three live broadcasts. It is also common for broadcasters to reuse the same stream for many different broadcasts if those broadcasts occur at different times.\n\nThe remaining sections present three use cases that explain how API users typically use broadcasts and streams.\n\nConfigure a single encoder\n--------------------------\n\nIn the most common API use case, your YouTube channel has a series of scheduled or recurring live events. As the channel owner, you have a single encoder and only want to configure the encoder one time. So, you perform the following steps:\n\n1. Create one [liveStream](/youtube/v3/live/docs/liveStreams) resource in the API.\n2. Use the content delivery settings from that resource to configure the encoder for the channel.\n3. Note that, if you have multiple channels, you must create a different stream for each channel.\n4. Create [liveBroadcast](/youtube/v3/live/docs/liveBroadcasts) resources in the API and [bind](/youtube/v3/live/docs/liveBroadcasts/bind) all of those resources to the [liveStream](/youtube/v3/live/docs/liveStreams) resource. In this scenario, every live event that you schedule for your channel uses the same streaming settings. However, only one event is live at any given time, and the video content for each broadcast is unique.\n5. Any time an event occurs, update the broadcast's status to either `testing` or `live` and proceed to broadcast that event on YouTube.\n\nCreate one stream per broadcast\n-------------------------------\n\nAnother common approach is to create a separate stream for each broadcast. In this scenario, you would create a distinct [liveStream](/youtube/v3/live/docs/liveStreams) resource for each [liveBroadcast](/youtube/v3/live/docs/liveBroadcasts) resource and then configure your streaming encoder to use the appropriate settings for each broadcast.\n\nThis approach might make sense if your channel has multiple recurring broadcasts such that two broadcasts might occur simultaneously, making it infeasible for both broadcasts to use the same streaming settings. In fact, your channel might treat each recurring broadcast as a show and just create one [liveStream](/youtube/v3/live/docs/liveStreams) resource per show. Then, each episode of the same show would represent a broadcast, and all broadcasts of the same show could be bound to the same stream.\n\nUse one stream to create simultaneous broadcasts\n------------------------------------------------\n\nIn this scenario, you want to split a live stream into multiple, simultaneous broadcasts. As such, you have one [liveStream](/youtube/v3/live/docs/liveStreams) resource that is bound to two (or more) [liveBroadcast](/youtube/v3/live/docs/liveBroadcasts) resources that have a `live` status at the same time.\n\nFor example, suppose your channel broadcasts a 24/7 live feed, but you also want to create a separate video for an interview that occurs during that broadcast. In this case, the interview content is a subset of the 24/7 broadcast's content.\n\nTo handle this case, you create two `liveBroadcast` resources and bind both broadcasts to the same stream. The 24/7 broadcast is ongoing and its resource has a `live` status long before the interview begins. When the interview begins, you update the status of the resource associated with the interview to `live` without changing the 24/7 broadcast's resource. Thus, you are streaming the same content to two separate videos at the same time.\n\nWhen the interview ends, you update the interview broadcast's resource again, this time setting its status to `complete`. However, you don't stop streaming video since the 24/7 broadcast continues."]]