Prima di iniziare

Questa pagina mostra come configurare un progetto Google Cloud e i service account per accedere al progetto.

Configurare un progetto Google Cloud

Segui questi passaggi per configurare un progetto Google Cloud .

  1. Accedi al tuo account Google Cloud . Se non conosci Google Cloud, crea un account per valutare le prestazioni dei nostri prodotti in scenari reali. I nuovi clienti ricevono anche 300 $di crediti senza costi per l'esecuzione, il test e il deployment dei carichi di lavoro.
  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. Installa Google Cloud CLI.

  15. Se utilizzi un provider di identità (IdP) esterno, devi prima accedere a gcloud CLI con la tua identità federata.

  16. Per inizializzare gcloud CLI, esegui questo comando:

    gcloud init
  17. Utilizza gcloud CLI per testare l'ambiente di autenticazione. Verifica che il seguente comando restituisca una stringa di testo senza errori:
    gcloud auth application-default print-access-token

Attiva il account di servizio

  1. Nel terminale, imposta il progetto attivo per i comandi gcloud. Sostituisci YOUR_PROJECT_ID con l'ID progetto.
    gcloud config set project YOUR_PROJECT_ID
  2. Attiva il account di servizio. Sostituisci PATH_TO_YOUR_SERVICE_KEY con il percorso del file JSON scaricato sul computer locale.
    gcloud auth activate-service-account --key-file PATH_TO_YOUR_SERVICE_KEY

Utilizzerai questo account di servizio per autorizzare l'accesso e chiamare l'API Video Stitcher.

Crea un account di servizio con le sole autorizzazioni per creare sessioni

Poiché un token OAuth verrà passato a un'applicazione client, crea un account di servizio separato con le autorizzazioni solo per creare una sessione. In questo modo, un token OAuth trapelato non può compromettere le tue risorse, come le configurazioni VOD/live o le chiavi CDN.

Crea un service account:

  1. Assicurati di disporre del ruolo IAM Creazione service account (roles/iam.serviceAccountCreator) e del ruolo Amministratore IAM progetto (roles/resourcemanager.projectIamAdmin). Scopri come concedere i ruoli.
  2. Nella console Google Cloud vai a Crea service account.

    Vai a Crea service account
  3. Seleziona il progetto.
  4. Nel campo Nome service account, inserisci un nome. La console Google Cloud compila il campo ID service account in base a questo nome.

    Nel campo Descrizione service account, inserisci una descrizione. Ad esempio, Service account for quickstart.

  5. Fai clic su Crea e continua.
  6. Concedi il ruolo Utente Video Stitcher al account di servizio.

    Per concedere il ruolo, trova l'elenco Seleziona un ruolo, quindi seleziona Utente Video Stitcher.

  7. Fai clic su Continua.
  8. Fai clic su Fine per completare la creazione del service account.

    Non chiudere la finestra del browser. Lo utilizzerai nel prossimo passaggio.

Crea una chiave dell'account di servizio:

  1. Nella console Google Cloud , fai clic sull'indirizzo email del account di servizio che hai creato.
  2. Fai clic su Chiavi.
  3. Fai clic su Aggiungi chiave, poi su Crea nuova chiave.
  4. Fai clic su Crea. Un file della chiave JSON viene scaricato sul computer.
  5. Fai clic su Chiudi.

Configurazione del live streaming

Se inserisci annunci in un live streaming, segui i passaggi descritti in questa sezione (o consulta i passaggi per i VOD).

Una volta creato il account di servizio, devi collegarlo al tuo account Ad Manager. In questo modo, l'API Video Stitcher può creare eventi di live streaming per tuo conto. Per farlo, segui i passaggi per concedere l'accesso al tuo account di servizio:

  1. Accedi a Google Ad Manager (GAM).
  2. Fai clic su Amministratore > Impostazioni globali.
  3. Assicurati che l'accesso API sia abilitato.
  4. Fai clic su Aggiungi utente dell'account di servizio.
  5. Compila il modulo, incluso l'indirizzo email del service account creato in precedenza.
  6. Seleziona un ruolo che deve includere l'autorizzazione Gestire i contenuti video con l'inserimento di annunci dinamici da Google Cloud Video Stitcher. Devi creare un ruolo personalizzato denominato Live Stream Manager specifico per la gestione di questo service account. Il ruolo personalizzato deve disporre almeno delle seguenti autorizzazioni:
    • Gestire i contenuti video con l'inserimento di annunci dinamici dallo strumento di stitching video di Google Cloud
    • Visualizza creatività (richiesta dall'autorizzazione precedente)
    • Visualizzare contenuti video, bundle e metadati
    • Visualizza le origini di contenuto
  7. Se la tua rete Ad Manager utilizza i team, devi assegnare il team "Tutte le entità" all'utente dell'account di servizio.
  8. Fai clic su Salva e conferma l'aggiunta dell'account di servizio.

Crea un live streaming

Puoi utilizzare una delle guide rapide dell'API Live Stream per configurare un live streaming. Sono supportati sia i live streaming HLS che MPEG-DASH (vedi i requisiti del manifest di origine). Questa procedura è facoltativa; puoi utilizzare un live streaming esistente.

Le guide rapide dell'API Live Stream utilizzano le Credenziali predefinite dell'applicazione per l'autenticazione, ma puoi utilizzare il account di servizio che hai già configurato. Per questa opzione, assicurati che il account di servizio abbia il ruolo Editor live streaming.

Assicurati di mantenere attivo il live streaming. Non seguire i passaggi della sezione Pulizia finché non hai terminato il live streaming.

Requisiti del file manifest dell'origine

L'API Video Stitcher registra la configurazione con Ad Manager analizzando il manifest di origine. Il manifest di origine deve avere determinate caratteristiche a seconda del formato.

HLS

  • Il formato del contenitore può essere:
    • MPEG-TS multiplexato
    • MPEG-TS demuxed
    • FMP4 demuxed
  • Almeno una rappresentazione nel manifest con i seguenti campi (compilati correttamente):
    • codec
    • larghezza di banda

MPEG-DASH

  • MPD@type impostato su dinamico (@type="dynamic")
  • MPD@profiles include il profilo ISO Live urn:mpeg:dash:profile:isoff-live:2011
  • Deve essere composto da più periodi, ognuno dei quali contiene uno o più set di adattamento
  • Ogni set di adattamento contiene una o più rappresentazioni
  • Le rappresentazioni contengono o ereditano un SegmentTemplate con l'identificatore $Number$ o $Time$
  • @segmentAlignment impostato su true per tutti i set di adattamento
  • Le rappresentazioni non devono essere vuote

Configurazione dello stream VOD

Se inserisci annunci in uno stream VOD, segui i passaggi descritti in questa sezione (o consulta i passaggi per un live streaming).

Crea i file di origine VOD

Questo workflow richiede un file manifest MPEG-DASH (MPD) o un file manifest HTTP Live Streaming (HLS) (M3U8) e i file di segmento associati. Puoi utilizzare i tuoi file VOD esistenti o creare file di origine VOD utilizzando l'API Transcoder.