Prima di iniziare

Questa pagina mostra come configurare un progetto Google Cloud e configurare gli account di servizio per accedere al progetto.

Configurare un progetto Google Cloud

Segui questi passaggi per configurare un progetto Google Cloud .

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  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 (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 Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. 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). 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 (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 Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. 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). 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. Install the 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
  18. Attivare 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 che hai scaricato nella macchina 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à trasmesso a un'applicazione client, crea un account di servizio separato con solo le autorizzazioni per creare una sessione. In questo modo, un token OAuth compromesso non può compromettere le tue risorse, come le configurazioni VOD/live o le chiavi CDN.

    Create a service account:

    1. Ensure that you have the Create Service Accounts IAM role (roles/iam.serviceAccountCreator). 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 User role to the service account.

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

    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.

    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.

    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. Ciò consente all'API Video Stitcher di 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 con account di servizio.
    5. Compila il modulo, incluso l'indirizzo email dell'account di servizio creato in precedenza.
    6. Seleziona un ruolo che deve includere l'autorizzazione Gestire i contenuti video con l'inserimento di annunci dinamici dallo strumento di stitching video di Google Cloud. Devi creare un ruolo personalizzato denominato Live Stream Manager specifico per la gestione di questo account di servizio. 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
      • Visualizzare creatività (richiesto dall'autorizzazione precedente)
      • Visualizzare contenuti video, pacchetti e metadati
      • Visualizzare 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.

    Creare un live streaming

    Puoi utilizzare uno degli avvii rapidi 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 manifest di 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 muxed
      • MPEG-TS demultiplexato
      • FMP4 demuxed
    • Almeno un rendering 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 deve contenere uno o più set di adattamento
    • Ogni Adaptation Set 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 flusso di lavoro 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 oppure creare file sorgente VOD utilizzando l'API Transcoder.