Prima di iniziare

Questa pagina spiega come configurare un Google Cloud progetto e gli account di servizio per accedervi.

Configurare un Google Cloud progetto

Segui questi passaggi per configurare un Google Cloud progetto.

  1. Accedi al tuo Google Cloud account. 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 eseguire, testare ed eseguire il deployment di 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.

    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) 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 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) 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

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.

Creare 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 le sole 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.

Crea un account di servizio:

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

    Vai a Crea account di servizio
  3. Seleziona il progetto.
  4. Nel campo Nome service account, inserisci un nome. La Google Cloud console 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, individua 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 account di servizio.

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

Crea una chiave dell'account di servizio:

  1. Nella Google Cloud console, fai clic sull'indirizzo email del account di servizio che hai creato.
  2. Fai clic su Chiavi.
  3. Fai clic su Aggiungi chiave, quindi 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 stai inserendo annunci in un live streaming, segui i passaggi descritti in questa sezione (o consulta i passaggi per il 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 con 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 Gestisci i contenuti video con l'inserimento di annunci dinamici dallo strumento di stitching video di Google Cloud. Ti consigliamo di creare un ruolo personalizzato denominato Live Stream Manager specificamente per la gestione di questo service account. Il ruolo personalizzato deve avere almeno le seguenti autorizzazioni:
    • Gestisci i contenuti video con l'inserimento di annunci dinamici dallo strumento di stitching video di Google Cloud
    • Visualizza creatività (richiesta dall'autorizzazione precedente)
    • Visualizza contenuti video, bundle e metadati
    • Visualizza origini contenuti
  7. Se la tua rete Ad Manager utilizza team, devi assegnare il team "Tutte le entità" all'utente del account di servizio.
  8. Fai clic su Salva e conferma l'aggiunta del account di servizio.

Creare 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 sia MPEG-DASH (vedi i requisiti del manifest di origine). Questa procedura è facoltativa; puoi utilizzare il tuo 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 Liberare spazio 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 container può essere:
    • MPEG-TS muxato
    • MPEG-TS non muxato
    • FMP4 non muxato
  • Almeno una riproduzione nel manifest con i seguenti campi (compilati correttamente):
    • codec
    • bandwidth

MPEG-DASH

  • MPD@type impostato su dynamic (@type="dynamic")
  • MPD@profiles include il profilo ISO Live urn:mpeg:dash:profile:isoff-live:2011
  • Deve essere multiperiodo, con ogni periodo contenente 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 stai inserendo annunci in uno stream VOD, segui i passaggi descritti in questa sezione (o consulta i passaggi per un live streaming).

Creare 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 puoi creare file di origine VOD utilizzando l'API Transcoder.