לפני שמתחילים

בדף הזה מוסבר איך להגדיר פרויקט וחשבונות שירות כדי לגשת לפרויקט. Google Cloud

הגדרת Google Cloud פרויקט

כדי להגדיר Google Cloud פרויקט, מבצעים את השלבים הבאים.

  1. נכנסים לחשבון Google Cloud . אם אתם משתמשים חדשים ב- Google Cloud, צרו חשבון כדי שתוכלו להעריך את הביצועים של המוצרים שלנו בתרחישים מהעולם האמיתי. לקוחות חדשים מקבלים בחינם גם קרדיט בשווי 300$ להרצה, לבדיקה ולפריסה של עומסי העבודה.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Enable the Video Stitcher API.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the API

  5. Create a service account:

    1. Ensure that you have the Create Service Accounts IAM role (roles/iam.serviceAccountCreator) and the Project IAM Admin role (roles/resourcemanager.projectIamAdmin). Learn how to grant roles.
    2. In the Google Cloud console, go to the Create service account page.

      Go to Create service account
    3. Select your project.
    4. In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.

      In the Service account description field, enter a description. For example, Service account for quickstart.

    5. Click Create and continue.
    6. Grant the Video Stitcher Admin role to the service account.

      To grant the role, find the Select a role list, then select Video Stitcher Admin.

    7. Click Continue.
    8. Click Done to finish creating the service account.

      Do not close your browser window. You will use it in the next step.

  6. Create a service account key:

    1. In the Google Cloud console, click the email address for the service account that you created.
    2. Click Keys.
    3. Click Add key, and then click Create new key.
    4. Click Create. A JSON key file is downloaded to your computer.
    5. Click Close.
  7. Set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the path of the JSON file that contains your credentials. This variable applies only to your current shell session, so if you open a new session, set the variable again.

  8. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  9. Verify that billing is enabled for your Google Cloud project.

  10. Enable the Video Stitcher API.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the API

  11. Create a service account:

    1. Ensure that you have the Create Service Accounts IAM role (roles/iam.serviceAccountCreator) and the Project IAM Admin role (roles/resourcemanager.projectIamAdmin). Learn how to grant roles.
    2. In the Google Cloud console, go to the Create service account page.

      Go to Create service account
    3. Select your project.
    4. In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.

      In the Service account description field, enter a description. For example, Service account for quickstart.

    5. Click Create and continue.
    6. Grant the Video Stitcher Admin role to the service account.

      To grant the role, find the Select a role list, then select Video Stitcher Admin.

    7. Click Continue.
    8. Click Done to finish creating the service account.

      Do not close your browser window. You will use it in the next step.

  12. Create a service account key:

    1. In the Google Cloud console, click the email address for the service account that you created.
    2. Click Keys.
    3. Click Add key, and then click Create new key.
    4. Click Create. A JSON key file is downloaded to your computer.
    5. Click Close.
  13. Set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the path of the JSON file that contains your credentials. This variable applies only to your current shell session, so if you open a new session, set the variable again.

  14. התקינו את ה-CLI של Google Cloud.

  15. אם אתם משתמשים בספק זהויות חיצוני (IdP), קודם אתם צריכים להיכנס ל-CLI של gcloud באמצעות המאגר המאוחד לניהול זהויות.

  16. כדי לאתחל את ה-CLI של gcloud, הריצו את הפקודה הבאה:

    gcloud init
  17. משתמשים ב-CLI של gcloud כדי לבדוק את סביבת האימות. מוודאים שהפלט של הפקודה הבאה הוא מחרוזת טקסט ללא שגיאות:
    gcloud auth application-default print-access-token

הפעלת חשבון השירות

  1. בטרמינל, מגדירים את הפרויקט הפעיל לפקודות gcloud. מחליפים את YOUR_PROJECT_ID במזהה הפרויקט.
    gcloud config set project YOUR_PROJECT_ID
  2. מפעילים את חשבון השירות. מחליפים את PATH_TO_YOUR_SERVICE_KEY בנתיב לקובץ ה-JSON שהורדתם למחשב המקומי.
    gcloud auth activate-service-account --key-file PATH_TO_YOUR_SERVICE_KEY

תשתמשו בחשבון השירות הזה כדי לאשר גישה ולבצע קריאה ל-Video Stitcher API.

יצירת חשבון שירות עם הרשאות ליצירת סשנים בלבד

מכיוון שטוקן OAuth יועבר לאפליקציית לקוח, צריך ליצור חשבון שירות נפרד עם הרשאות ליצירת סשן בלבד. כך, אם טוקן OAuth ידלוף, הוא לא יוכל לסכן את המשאבים שלכם, כמו הגדרות של VOD או שידורים חיים או מפתחות של CDN.

יוצרים חשבון שירות:

  1. מוודאים שיש לכם את תפקיד ה-IAM ‏Create Service Accounts ‏(roles/iam.serviceAccountCreator) ואת תפקיד ה-IAM ‏Project Admin ‏(roles/resourcemanager.projectIamAdmin). איך מקצים תפקידים
  2. במסוף Google Cloud , נכנסים לדף יצירת חשבון שירות.

    כניסה לדף Create service account
  3. בוחרים את הפרויקט הרצוי.
  4. כותבים שם בשדה Service account name. המסוף Google Cloud ממלא את השדה מזהה חשבון שירות בהתאם לשם הזה.

    כותבים תיאור בשדה Service account description. לדוגמה: Service account for quickstart.

  5. לוחצים על Create and continue.
  6. מקצים לחשבון השירות את התפקיד Video Stitcher User.

    כדי להקצות את התפקיד, בוחרים את התפקיד Video Stitcher User מהרשימה Select a role.

  7. לוחצים על Continue.
  8. לוחצים על Done כדי לסיים ליצור את חשבון השירות.

    חשוב לא לסגור את חלון הדפדפן, כי תשתמשו בו גם בשלב הבא.

יוצרים מַפְתח לחשבון השירות:

  1. במסוף Cloud, לוחצים על כתובת האימייל של חשבון השירות שיצרתם. Google Cloud
  2. לוחצים על Keys.
  3. לוחצים על Add key ואז על Create new key.
  4. לוחצים על Create. למחשב שלכם תתבצע הורדה של קובץ JSON עם המפתח.
  5. לוחצים על Close.

הגדרת שידור חי

אם אתם מוסיפים מודעות לשידור חי, אתם צריכים לפעול לפי השלבים שמפורטים בקטע הזה (או לפי השלבים להוספת מודעות לתוכן VOD).

אחרי שיוצרים את חשבון השירות, צריך לקשר אותו לחשבון Ad Manager. ההרשאה הזו מאפשרת ל-Video Stitcher API ליצור אירועים של שידורים חיים בשמכם. כדי לעשות זאת, פועלים לפי השלבים להענקת גישה לחשבון השירות:

  1. נכנסים לחשבון Google Ad Manager ‏ (GAM).
  2. לוחצים על Admin > Global Settings (אדמין > הגדרות גלובליות).
  3. מוודאים שגישה ל-API מופעלת.
  4. לוחצים על הוספת משתמש לחשבון שירות.
  5. ממלאים את הטופס, כולל כתובת האימייל של חשבון השירות שנוצר קודם.
  6. בוחרים תפקיד שכולל את ההרשאה ניהול תוכן סרטונים עם הטמעת מודעות דינמיות (DAI) מ-Google Cloud Video Stitcher. מומלץ ליצור תפקיד בהתאמה אישית בשם Live Stream Manager במיוחד לניהול חשבון השירות הזה. לתפקיד בהתאמה אישית צריכות להיות לפחות ההרשאות הבאות:
    • ניהול תוכן סרטונים עם הטמעת מודעות דינמיות (DAI) מ-Google Cloud Video Stitcher
    • צפייה בנכסי קריאייטיב (נדרשת על ידי ההרשאה הקודמת)
    • צפייה בתוכן של סרטונים, בחבילות תוכן ובמטא-נתונים
    • לצפייה במקורות התוכן
  7. אם ברשת Ad Manager שלכם נעשה שימוש בצוותים, אתם צריכים להקצות את הצוות 'כל הישויות' למשתמש בחשבון השירות.
  8. לוחצים על שמירה ומאשרים את הוספת חשבון השירות.

יצירת שידור חי

אפשר להשתמש באחד מהמדריכים לתחילת העבודה עם Live Stream API כדי להגדיר שידור חי. המערכת תומכת בשידורים חיים בפורמטים HLS ו-MPEG-DASH (ראו דרישות לגבי מניפסט המקור). התהליך הזה הוא אופציונלי, ואפשר להשתמש בשידור חי קיים משלכם.

במדריכי ההתחלה המהירה של Live Stream API נעשה שימוש ב-Application Default Credentials לאימות, אבל אתם יכולים להשתמש בחשבון השירות שכבר הגדרתם. אם בוחרים באפשרות הזו, צריך לוודא שלחשבון השירות יש את התפקיד Live Stream Editor (עורך שידורים חיים).

חשוב להקפיד שהשידור החי יהיה פעיל. אל תפעלו לפי השלבים שבקטע ניקוי עד שתסיימו את השידור החי.

הדרישות לגבי קובץ המניפסט של המקור

ממשק Video Stitcher API רושם את ההגדרה ב-Ad Manager על ידי ניתוח של מניפסט המקור. מניפסט המקור חייב לכלול מאפיינים מסוימים, בהתאם לפורמט.

HLS

  • פורמט המאגר יכול להיות:
    • muxed MPEG-TS
    • ‫MPEG-TS לא מופרד
    • unmuxed FMP4
  • לפחות רכיב אחד במניפסט עם השדות הבאים (מאוכלסים בצורה תקינה):
    • קודקים
    • רוחב פס

MPEG-DASH

  • MPD@type מוגדר לערך dynamic ‏ (@type="dynamic")
  • MPD@profiles כולל את הפרופיל של ISO Live urn:mpeg:dash:profile:isoff-live:2011
  • צריך להיות רב-תקופתי, כאשר כל תקופה מכילה קבוצת התאמות אחת או יותר
  • כל קבוצת התאמות מכילה לפחות ייצוג אחד
  • הייצוגים מכילים או מקבלים בירושה את הערך SegmentTemplate עם המזהה $Number$ או $Time$
  • @segmentAlignment מוגדר כ-true לכל קבוצות ההתאמה
  • הייצוגים לא יכולים להיות ריקים

הגדרה של מקור נתונים מסוג VOD

אם אתם מוסיפים מודעות לשידור VOD, פועלים לפי השלבים שמפורטים בקטע הזה (או לפי השלבים להוספת מודעות לשידור חי).

יצירת קובצי המקור של הסרטון על פי דרישה

תהליך העבודה הזה דורש קובץ מניפסט של MPEG-DASH ‏ (MPD) או קובץ מניפסט של HTTP Live Streaming ‏ (HLS) ‏ (M3U8), וקובצי הפלחים המשויכים. אתם יכולים להשתמש בקובצי VOD קיימים משלכם או ליצור קובצי מקור של VOD באמצעות Transcoder API.