Antes de empezar

En esta página se explica cómo configurar un Google Cloud proyecto y configurar cuentas de servicio para acceder a él.

Configurar un Google Cloud proyecto

Sigue estos pasos para configurar un Google Cloud proyecto.

  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. Si utilizas un proveedor de identidades (IdP) externo, primero debes iniciar sesión en la CLI de gcloud con tu identidad federada.

  16. Para inicializar gcloud CLI, ejecuta el siguiente comando:

    gcloud init
  17. Usa la CLI de gcloud para probar tu entorno de autenticación. Comprueba que el siguiente comando genere una cadena de texto sin errores:
    gcloud auth application-default print-access-token
  18. Activar la cuenta de servicio

    1. En tu terminal, define el proyecto activo para los comandos de gcloud. Sustituye YOUR_PROJECT_ID por el ID de tu proyecto.
      gcloud config set project YOUR_PROJECT_ID
    2. Activa la cuenta de servicio. Sustituye PATH_TO_YOUR_SERVICE_KEY por la ruta al archivo JSON que has descargado en tu máquina local.
      gcloud auth activate-service-account --key-file PATH_TO_YOUR_SERVICE_KEY

    Usarás esta cuenta de servicio para autorizar el acceso y llamar a la API Video Stitcher.

    Crear una cuenta de servicio con permisos para crear sesiones

    Como se va a enviar un token de OAuth a una aplicación cliente, crea una cuenta de servicio independiente con permisos únicamente para crear una sesión. De esta forma, si se filtra un token de OAuth, no se pondrán en peligro tus recursos, como las configuraciones de VOD o de contenido en directo, ni las claves de 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.

    Configuración de la emisión en directo

    Si vas a insertar anuncios en una emisión en directo, sigue los pasos de esta sección (o consulta los pasos para el VOD).

    Una vez creada la cuenta de servicio, debe vincularla a su cuenta de Ad Manager. Esto permite que la API Video Stitcher cree eventos de emisión en directo en tu nombre. Para ello, sigue los pasos para conceder acceso a tu cuenta de servicio:

    1. Inicie sesión en Google Ad Manager (GAM).
    2. Haga clic en Administrar > Configuración global.
    3. Asegúrate de que Acceso a la API esté habilitado.
    4. Haga clic en Añadir un usuario de cuenta de servicio.
    5. Rellene el formulario, incluida la dirección de correo de la cuenta de servicio que ha creado anteriormente.
    6. Selecciona un rol que incluya el permiso Gestionar contenido de vídeo con la inserción dinámica de anuncios de Google Cloud Video Stitcher. Debería crear un rol personalizado llamado Gestor de emisiones en directo específicamente para gestionar esta cuenta de servicio. El rol personalizado debe tener al menos los siguientes permisos:
      • Gestionar contenido de vídeo con la inserción dinámica de anuncios de Google Cloud Video Stitcher
      • Ver creatividades (obligatorio para el permiso anterior)
      • Ver contenido, conjuntos de contenido y metadatos de vídeo
      • Ver fuentes de contenido
    7. Si su red de Ad Manager usa equipos, debe asignar el equipo "Todas las entidades" al usuario de la cuenta de servicio.
    8. Haga clic en Guardar y confirme que quiere añadir la cuenta de servicio.

    Crear una emisión en directo

    Puedes usar una de las guías de inicio rápido de la API Live Stream para configurar una emisión en directo. Se admiten las emisiones en directo HLS y MPEG-DASH (consulta los requisitos del archivo de manifiesto de origen). Este procedimiento es opcional. Puedes usar tu propia emisión en directo.

    En las guías de inicio rápido de la API Live Stream se usan las credenciales predeterminadas de la aplicación para la autenticación, pero puedes usar la cuenta de servicio que ya hayas configurado. Para esta opción, asegúrate de que la cuenta de servicio tenga el rol Editor de transmisiones en directo.

    Asegúrate de que la emisión en directo siga activa. No sigas los pasos de la sección Limpiar hasta que hayas terminado con la emisión en directo.

    Requisitos del manifiesto de origen

    La API Video Stitcher registra la configuración en Ad Manager analizando el manifiesto de origen. El archivo de manifiesto de origen debe tener ciertas características en función del formato.

    HLS

    • El formato del contenedor puede ser:
      • MPEG-TS multiplexado
      • MPEG-TS sin multiplexar
      • FMP4 sin multiplexar
    • Al menos una representación en el archivo de manifiesto con los siguientes campos (rellenados correctamente):
      • códecs
      • bandwidth

    MPEG-DASH

    • MPD@type definido como dinámico (@type="dynamic")
    • MPD@profiles incluye el perfil ISO Live urn:mpeg:dash:profile:isoff-live:2011
    • Debe tener varios periodos, y cada periodo debe contener uno o varios AdaptationSets.
    • Cada Adaptation Set contiene una o varias Representations
    • Las representaciones contienen o heredan un SegmentTemplate con el identificador $Number$ o $Time$.
    • @segmentAlignment se ha definido como true para todos los conjuntos de adaptación
    • Las representaciones no pueden estar vacías

    Configuración de flujos de VOD

    Si va a insertar anuncios en una emisión de vídeo bajo demanda, siga los pasos que se indican en esta sección (o consulte los pasos para una emisión en directo).

    Crear los archivos de origen de VOD

    Este flujo de trabajo requiere un archivo de manifiesto MPEG-DASH (MPD) o un archivo de manifiesto HTTP Live Streaming (HLS) (M3U8), así como los archivos de segmento asociados. Puedes usar tus propios archivos VOD o crear archivos de origen VOD con la API Transcoder.