בדף הזה מוסבר איך להגדיר Google Cloud פרויקט וחשבונות שירות כדי לגשת לפרויקט.
הגדרת Google Cloud פרויקט
כדי להגדיר פרויקט ב- Google Cloud , פועלים לפי השלבים הבאים:
- נכנסים לחשבון Google Cloud . אנחנו ממליצים למשתמשים חדשים ב- Google Cloud ליצור חשבון כדי שיוכלו להעריך את הביצועים של המוצרים שלנו בתרחישים מהעולם האמיתי. לקוחות חדשים מקבלים בחינם גם קרדיט בשווי 300$ להרצה, לבדיקה ולפריסה של עומסי העבודה.
-
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 theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Video Stitcher API, if it is not already enabled.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. 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.-
Create a service account:
-
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. -
In the Google Cloud console, go to the Create service account page.
Go to Create service account - Select your project.
-
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. - Click Create and continue.
-
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.
- Click Continue.
-
Click Done to finish creating the service account.
Do not close your browser window. You will use it in the next step.
-
Ensure that you have the Create Service Accounts IAM role
(
-
Create a service account key:
- In the Google Cloud console, click the email address for the service account that you created.
- Click Keys.
- Click Add key, and then click Create new key.
- Click Create. A JSON key file is downloaded to your computer.
- Click Close.
-
Set the environment variable
GOOGLE_APPLICATION_CREDENTIALSto 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. -
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 theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Video Stitcher API, if it is not already enabled.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. 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.-
Create a service account:
-
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. -
In the Google Cloud console, go to the Create service account page.
Go to Create service account - Select your project.
-
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. - Click Create and continue.
-
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.
- Click Continue.
-
Click Done to finish creating the service account.
Do not close your browser window. You will use it in the next step.
-
Ensure that you have the Create Service Accounts IAM role
(
-
Create a service account key:
- In the Google Cloud console, click the email address for the service account that you created.
- Click Keys.
- Click Add key, and then click Create new key.
- Click Create. A JSON key file is downloaded to your computer.
- Click Close.
-
Set the environment variable
GOOGLE_APPLICATION_CREDENTIALSto 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. -
התקינו את ה-CLI של Google Cloud.
-
אם אתם משתמשים בספק זהויות חיצוני (IdP), קודם אתם צריכים להיכנס ל-CLI של gcloud באמצעות המאגר המאוחד לניהול זהויות.
-
כדי לאתחל את ה-CLI של gcloud, הריצו את הפקודה הבאה:
gcloud init - משתמשים ב-CLI של gcloud כדי לבדוק את סביבת האימות.
מוודאים שהפקודה הבאה מפיקה מחרוזת טקסט ללא שגיאות:
gcloud auth application-default print-access-token
הפעלת חשבון השירות
- בטרמינל, מגדירים את הפרויקט הפעיל לפקודות gcloud. מחליפים את
YOUR_PROJECT_IDבמזהה הפרויקט.gcloud config set project YOUR_PROJECT_ID
- מפעילים את חשבון השירות. מחליפים את
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.
יוצרים חשבון שירות:
-
מוודאים שיש לכם את התפקיד "יצירת חשבונות שירות" (
roles/iam.serviceAccountCreator) ואת התפקיד "אדמין של פרויקט" (roles/resourcemanager.projectIamAdmin) ב-IAM. איך נותנים תפקידים? -
במסוף Google Cloud , נכנסים לדף יצירת חשבון שירות.
כניסה לדף Create service account - בוחרים את הפרויקט הרצוי.
-
כותבים שם בשדה Service account name. השדה Service account ID במסוף Google Cloud יאוכלס בהתאם לשם הזה.
כותבים תיאור בשדה Service account description. לדוגמה:
Service account for quickstart. - לוחצים על Create and continue.
-
מקצים לחשבון השירות את התפקיד Video Stitcher User.
כדי להקצות את התפקיד, בוחרים את התפקיד Video Stitcher User מהרשימה Select a role.
- לוחצים על Continue.
-
לוחצים על Done כדי לסיים ליצור את חשבון השירות.
חשוב לא לסגור את חלון הדפדפן, כי תשתמשו בו גם בשלב הבא.
יוצרים מַפְתח לחשבון השירות:
- במסוף Google Cloud Cloud, לוחצים על כתובת האימייל של חשבון השירות שיצרתם.
- לוחצים על Keys.
- לוחצים על Add key ואז על Create new key.
- לוחצים על Create. למחשב שלכם תתבצע הורדה של קובץ JSON עם המפתח.
- לוחצים על Close.
הגדרת שידור חי
אם אתם מוסיפים מודעות לשידור חי, אתם צריכים לפעול לפי השלבים שמפורטים בקטע הזה (או בשלבים שמופיעים כאן לגבי תוכן VOD).
קישור חשבון השירות לחשבון Ad Manager
אחרי שיוצרים את חשבון השירות, צריך לקשר אותו לחשבון Ad Manager. כך Video Stitcher API יכול ליצור אירועים של שידורים חיים בשמכם. כדי לעשות זאת, פועלים לפי השלבים להענקת גישה לחשבון השירות:
- נכנסים לחשבון Google Ad Manager (GAM).
- לוחצים על Admin > Global Settings (אדמין > הגדרות גלובליות).
- מוודאים שהגישה ל-API מופעלת.
- לוחצים על הוספת משתמש לחשבון שירות.
- ממלאים את הטופס, כולל כתובת האימייל של חשבון השירות שנוצר קודם.
- בוחרים תפקיד שחייב לכלול את ההרשאה Manage video content with dynamic ad insertion from Google Cloud Video Stitcher. מומלץ ליצור תפקיד בהתאמה אישית בשם מנהל שידורים חיים במיוחד לניהול חשבון השירות הזה. לתפקיד בהתאמה אישית צריכות להיות לפחות ההרשאות הבאות:
- ניהול תוכן סרטונים עם הטמעת מודעות דינמיות (DAI) מ-Google Cloud Video Stitcher
- לצפייה בנכסי הקריאייטיב (נדרשת על ידי ההרשאה הקודמת)
- צפייה בקטעי וידאו, בחבילות תוכן ובמטא-נתונים
- אל מקורות התוכן
- אם ברשת Ad Manager שלכם נעשה שימוש בצוותים, אתם צריכים להקצות את הצוות 'כל הישויות' למשתמש בחשבון השירות.
- לוחצים על שמירה ומאשרים את הוספת חשבון השירות.
יצירת שידור חי
אתם יכולים להשתמש באחד מהמדריכים למתחילים של 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 Liveurn: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.