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

בדף הזה מוסבר איך להגדיר 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, if it is not already enabled.

    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, if it is not already enabled.

    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. מוודאים שיש לכם את התפקיד "יצירת חשבונות שירות" (roles/iam.serviceAccountCreator) ואת התפקיד "אדמין של פרויקט" (roles/resourcemanager.projectIamAdmin) ב-IAM. איך נותנים תפקידים?
  2. במסוף Google Cloud , נכנסים לדף יצירת חשבון שירות.

    כניסה לדף Create service account
  3. בוחרים את הפרויקט הרצוי.
  4. כותבים שם בשדה Service account name. השדה Service account ID במסוף 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. במסוף Google Cloud 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. בוחרים תפקיד שחייב לכלול את ההרשאה Manage video content with dynamic ad insertion from Google Cloud Video Stitcher. מומלץ ליצור תפקיד בהתאמה אישית בשם מנהל שידורים חיים במיוחד לניהול חשבון השירות הזה. לתפקיד בהתאמה אישית צריכות להיות לפחות ההרשאות הבאות:
    • ניהול תוכן סרטונים עם הטמעת מודעות דינמיות (DAI) מ-Google Cloud Video Stitcher
    • לצפייה בנכסי הקריאייטיב (נדרשת על ידי ההרשאה הקודמת)
    • צפייה בקטעי וידאו, בחבילות תוכן ובמטא-נתונים
    • אל מקורות התוכן
  7. אם ברשת Ad Manager שלכם נעשה שימוש בצוותים, אתם צריכים להקצות את הצוות 'כל הישויות' למשתמש בחשבון השירות.
  8. לוחצים על שמירה ומאשרים את הוספת חשבון השירות.

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

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

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

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

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

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

HLS

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

MPEG-DASH

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

הגדרה של שידור VOD

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

יצירת קובצי המקור של ה-VOD

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