Cette page explique comment ins�rer des superpositions dans des vid�os transcod�es. Une superposition
est constitu�e d'une image ins�r�e en haut de la vid�o de sortie.
un effet de fondu � l'ouverture ou � la fermeture
sur une p�riode donn�e. Pour ins�rer une superposition, utilisez le tableau overlays
dans le mod�le JobConfig
.
Consultez le liste des formats de fichiers image accept�s
Importer une image dans Cloud�Storage
Pour commencer, proc�dez comme suit pour importer une image en superposition dans votre bucket Cloud�Storage�:
- Dans la console Google�Cloud, acc�dez � la page du navigateur Cloud�Storage.
Acc�der � la page du navigateur Cloud�Storage - Cliquez sur le nom de votre bucket pour l'ouvrir.
- Cliquez sur Importer des fichiers.
- S�lectionnez un fichier image � importer � partir de votre ordinateur local.
Cr�er une superposition
Vous pouvez cr�er deux�types de superpositions�: statique ou anim�e. Les deux�types de superpositions utilisent une image statique. Vous pouvez afficher ou masquer les superpositions statiques. Les superpositions anim�es sont compatibles avec les effets de fondu.
Vous pouvez ins�rer plusieurs superpositions dans une seule vid�o de sortie.
Cr�er une superposition statique
Dans l'objet image
, sp�cifiez l'image de superposition dans Cloud�Storage � l'aide du champ uri
. Dans l'objet resolution
, d�finissez les valeurs x et y de 0 � 1.0. Une valeur de 0 conserve la r�solution de l'image source pour cette dimension. Une valeur de 1.0 �tire l'image pour qu'elle corresponde � la dimension de la vid�o de sortie. Par exemple, utilisez les valeurs x: 1
et y:
0.5
pour �tirer l'image en superposition sur toute la largeur et la moiti� de la hauteur de la vid�o de sortie.
Dans le tableau animations
, cr�ez un objet animationStatic
avec les coordonn�es x et y de 0 � 1.0. Ces coordonn�es sont bas�es sur la r�solution de la vid�o de sortie. Utilisez les valeurs x: 0
et y: 0
pour placer l'angle sup�rieur gauche de la superposition dans l'angle sup�rieur gauche de la vid�o de sortie. Sp�cifiez le moment o� la superposition doit appara�tre dans la timeline de la vid�o de sortie � l'aide du champ startTimeOffset
.
Pour retirer l'animation statique, cr�ez un objet animationEnd
. Sp�cifiez le moment o� l'animation doit prendre fin (quand la superposition doit dispara�tre) dans la timeline de la vid�o de sortie � l'aide du champ startTimeOffset
.
Vous pouvez ajouter cette configuration � un mod�le de t�che ou l'inclure dans une configuration de t�che ad hoc�:
REST
Avant d'utiliser les donn�es de requ�te ci-dessous, effectuez les remplacements suivants�:
PROJECT_ID
�: ID de votre projet Google�Cloud r�pertori� dans les param�tres IAM.LOCATION
�: emplacement dans lequel votre t�che sera ex�cut�e. Utilisez l'une des r�gions disponibles.Afficher les emplacementsus-central1
us-west1
us-west2
us-east1
us-east4
southamerica-east1
northamerica-northeast1
asia-east1
asia-northeast1
asia-northeast3
asia-south1
asia-southeast1
australia-southeast1
europe-west1
europe-west2
europe-west4
STORAGE_BUCKET_NAME
�: nom du bucket Cloud�Storage que vous avez cr��.STORAGE_INPUT_VIDEO
�: nom de la vid�o dans votre bucket Cloud�Storage que vous transcodez, par exemplemy-vid.mp4
. Ce champ doit tenir compte des dossiers cr��s dans le bucket (par exemple,input/my-vid.mp4
).STORAGE_INPUT_OVERLAY
�: nom de l'image dans votre bucket Cloud�Storage que vous utilisez pour la superposition, tel quemy-overlay.png
. Ce champ doit tenir compte des dossiers cr��s dans le bucket (par exemple,input/my-overlay.png
).STORAGE_OUTPUT_FOLDER
�: nom du dossier Cloud�Storage dans lequel vous souhaitez enregistrer les sorties vid�o encod�es.
Pour envoyer votre requ�te, d�veloppez l'une des options suivantes�:
Vous devriez recevoir une r�ponse JSON de ce type�:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION/jobs/JOB_ID", "config": { ... }, "state": "PENDING", "createTime": CREATE_TIME, "ttlAfterCompletionDays": 30 }
gcloud
- Cr�ez un fichier
request.json
qui d�finit les champs de l'offre d'emploi. Effectuez les remplacements suivants pour la commandegcloud
�:- STORAGE_BUCKET_NAME�: nom du bucket Cloud�Storage que vous avez cr��.
- STORAGE_INPUT_VIDEO: le
de la vid�o dans votre bucket Cloud�Storage que vous
des conversions, par exemple
my-vid.mp4
. Ce champ doit tenir compte de tous les dossiers que vous avez cr��s dans le bucket (par exemple,input/my-vid.mp4
). - STORAGE_INPUT_OVERLAY: nom du
fichier image dans le bucket Cloud�Storage que vous utilisez pour la superposition, tel que
my-overlay.png
Ce champ doit tenir compte de tous les dossiers que vous avez cr��s dans (par exemple,input/my-overlay.png
). - LOCATION�: emplacement dans lequel votre t�che sera ex�cut�e. Utilisez un emplacement issu de la liste suivante.
Afficher les emplacements
us-central1
us-west1
us-west2
us-east1
us-east4
southamerica-east1
northamerica-northeast1
asia-east1
asia-northeast1
asia-northeast3
asia-south1
asia-southeast1
australia-southeast1
europe-west1
europe-west2
europe-west4
- STORAGE_OUTPUT_FOLDER: le Nom du dossier Cloud�Storage dans lequel vous souhaitez enregistrer la vid�o encod�e de sortie.
{ "config": { "inputs": [ { "key": "input0", "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_INPUT_VIDEO" } ], "elementaryStreams": [ { "key": "video-stream0", "videoStream": { "h264": { "heightPixels": 360, "widthPixels": 640, "bitrateBps": 550000, "frameRate": 60 } } }, { "key": "audio-stream0", "audioStream": { "codec": "aac", "bitrateBps": 64000 } } ], "muxStreams": [ { "key": "sd", "container": "mp4", "elementaryStreams": [ "video-stream0", "audio-stream0" ] } ], "output": { "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_OUTPUT_FOLDER/" }, "overlays": [ { "image": { "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_INPUT_OVERLAY", "resolution": { "x": 1, "y": 0.5 }, "alpha": 1 }, "animations": [ { "animationStatic": { "xy": { "x": 0, "y": 0 }, "startTimeOffset": "0s" } }, { "animationEnd": { "startTimeOffset": "10s" } } ] } ] } }
- Ex�cutez la commande suivante�:
Un r�sultat semblable � celui-ci doit s'afficher�:gcloud transcoder jobs create --location=LOCATION --file="request.json"
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION/jobs/JOB_ID", "config": { ... }, "state": "PENDING", "createTime": CREATE_TIME, "ttlAfterCompletionDays": 30 }
C#
Avant d'essayer cet exemple, suivez les instructions de configuration de C# dans le Guide de d�marrage rapide de l'API Transcoder avec biblioth�ques clientes. Pour en savoir plus, consultez les API Transcoder C# documentation de r�f�rence.
Pour vous authentifier aupr�s de l'API Transcoder, configurez les identifiants par d�faut de l'application. Pour en savoir plus, consultez Configurer l'authentification pour un environnement de d�veloppement local.
Go
Avant d'essayer cet exemple, suivez les instructions de configuration pour Go du guide de d�marrage rapide de l'API Transcoder � l'aide des biblioth�ques clientes. Pour en savoir plus, consultez les API Transcoder Go documentation de r�f�rence.
Pour vous authentifier aupr�s de l'API Transcoder, configurez le service Identifiants par d�faut de l'application. Pour en savoir plus, consultez Configurer l'authentification pour un environnement de d�veloppement local.
Java
Avant d'essayer cet exemple, suivez les instructions de configuration de Java dans le Guide de d�marrage rapide de l'API Transcoder avec biblioth�ques clientes. Pour en savoir plus, consultez les API Transcoder Java documentation de r�f�rence.
Pour vous authentifier aupr�s de l'API Transcoder, configurez le service Identifiants par d�faut de l'application. Pour en savoir plus, consultez Configurer l'authentification pour un environnement de d�veloppement local.
Node.js
Avant d'essayer cet exemple, suivez les instructions de configuration de Node.js dans le Guide de d�marrage rapide de l'API Transcoder avec biblioth�ques clientes. Pour en savoir plus, consultez les API Transcoder Node.js documentation de r�f�rence.
Pour vous authentifier aupr�s de l'API Transcoder, configurez les identifiants par d�faut de l'application. Pour en savoir plus, consultez Configurer l'authentification pour un environnement de d�veloppement local.
PHP
Avant d'essayer cet exemple, suivez les instructions de configuration pour PHP du guide de d�marrage rapide de l'API Transcoder � l'aide des biblioth�ques clientes. Pour en savoir plus, consultez les API Transcoder PHP documentation de r�f�rence.
Pour vous authentifier aupr�s de l'API Transcoder, configurez le service Identifiants par d�faut de l'application. Pour en savoir plus, consultez Configurer l'authentification pour un environnement de d�veloppement local.
Python
Avant d'essayer cet exemple, suivez les instructions de configuration pour Python du guide de d�marrage rapide de l'API Transcoder � l'aide des biblioth�ques clientes. Pour en savoir plus, consultez la documentation de r�f�rence sur l'API Transcoder pour Python.
Pour vous authentifier aupr�s de l'API Transcoder, configurez le service Identifiants par d�faut de l'application. Pour en savoir plus, consultez Configurer l'authentification pour un environnement de d�veloppement local.
Ruby
Avant d'essayer cet exemple, suivez les instructions de configuration pour Ruby du guide de d�marrage rapide de l'API Transcoder � l'aide des biblioth�ques clientes. Pour en savoir plus, consultez la documentation de r�f�rence sur l'API Transcoder pour Ruby.
Pour vous authentifier aupr�s de l'API Transcoder, configurez le service Identifiants par d�faut de l'application. Pour en savoir plus, consultez Configurer l'authentification pour un environnement de d�veloppement local.
Dans la vid�o de sortie, la superposition statique pr�sente les caract�ristiques suivantes�:
- Elle s'affiche au d�but de la chronologie et reste visible pendant 10�secondes.
- Elle s'�tire jusqu'� la largeur maximale et la moiti� de la hauteur de la vid�o de sortie.
- Elle est positionn�e dans l'angle sup�rieur gauche de la vid�o de sortie.
Consultez l'exemple de vid�o de sortie pour cette configuration. Cette vid�o utilise un exemple d'image en superposition.
Cr�er une superposition anim�e
Dans l'objet image
, sp�cifiez l'image de superposition dans Cloud�Storage � l'aide du champ uri
. Dans l'objet resolution
, d�finissez les valeurs x et y de 0 � 1.0. Une valeur de 0 conserve la r�solution de l'image source pour cette dimension. Une valeur de 1.0 �tire l'image pour qu'elle corresponde � la dimension de la vid�o de sortie. Par exemple, utilisez les valeurs x: 0
et y: 0
pour conserver la r�solution d'origine de l'image en superposition.
Dans le tableau animations
, cr�ez un objet animationFade
avec un fadeType
d�fini sur FADE_IN
. D�finissez les coordonn�es x et y de 0 � 1.0. Ces coordonn�es sont bas�es sur la r�solution de la vid�o de sortie. Utilisez les valeurs x: 0.5
et y: 0.5
pour placer l'angle sup�rieur gauche de la superposition au centre de la vid�o de sortie.
Sp�cifiez le moment o� la superposition doit commencer � appara�tre dans la timeline de la vid�o de sortie � l'aide du champ startTimeOffset
. La superposition devient enti�rement visible suivant le moment d�fini dans le champ endTimeOffset
.
Pour faire dispara�tre progressivement la superposition, cr�ez un autre objet animationFade
. Cette fois-ci, d�finissez le fadeType
sur FADE_OUT
. Saisissez les coordonn�es de position ainsi que les points de d�part et de fin de l'animation, comme auparavant.
Vous pouvez ajouter cette configuration � un mod�le de t�che ou l'inclure dans une configuration de t�che ad hoc�:
REST
Avant d'utiliser les donn�es de requ�te ci-dessous, effectuez les remplacements suivants�:
PROJECT_ID
�: ID de votre projet Google�Cloud r�pertori� dans les param�tres IAM.LOCATION
�: emplacement dans lequel votre t�che sera ex�cut�e. Utilisez l'une des r�gions disponibles.Afficher les emplacementsus-central1
us-west1
us-west2
us-east1
us-east4
southamerica-east1
northamerica-northeast1
asia-east1
asia-northeast1
asia-northeast3
asia-south1
asia-southeast1
australia-southeast1
europe-west1
europe-west2
europe-west4
STORAGE_BUCKET_NAME
�: nom du bucket Cloud�Storage que vous avez cr��.STORAGE_INPUT_VIDEO
�: nom de la vid�o dans votre bucket Cloud�Storage que vous transcodez, par exemplemy-vid.mp4
. Ce champ doit tenir compte des dossiers cr��s dans le bucket (par exemple,input/my-vid.mp4
).STORAGE_INPUT_OVERLAY
�: nom de l'image dans votre bucket Cloud�Storage que vous utilisez pour la superposition, tel quemy-overlay.png
. Ce champ doit tenir compte des dossiers cr��s dans le bucket (par exemple,input/my-overlay.png
).STORAGE_OUTPUT_FOLDER
�: nom du dossier Cloud�Storage dans lequel vous souhaitez enregistrer les sorties vid�o encod�es.
Pour envoyer votre requ�te, d�veloppez l'une des options suivantes�:
Vous devriez recevoir une r�ponse JSON de ce type�:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION/jobs/JOB_ID", "config": { ... }, "state": "PENDING", "createTime": CREATE_TIME, "ttlAfterCompletionDays": 30 }
gcloud
- Cr�ez un fichier
request.json
qui d�finit les champs de la t�che. Effectuez les remplacements suivants pour la commandegcloud
�:- STORAGE_BUCKET_NAME: le du bucket Cloud�Storage que vous avez cr��.
- STORAGE_INPUT_VIDEO: le
de la vid�o dans votre bucket Cloud�Storage que vous
des conversions, par exemple
my-vid.mp4
. Ce champ doit tenir compte de tous les dossiers que vous avez cr��s dans le bucket (par exemple,input/my-vid.mp4
). - STORAGE_INPUT_OVERLAY: nom du
fichier image dans le bucket Cloud�Storage que vous utilisez pour la superposition, tel que
my-overlay.png
Ce champ doit tenir compte de tous les dossiers que vous avez cr��s dans (par exemple,input/my-overlay.png
). - LOCATION�: emplacement dans lequel votre t�che sera ex�cut�e. Utilisez un emplacement issu de la liste suivante.
Afficher les emplacements
us-central1
us-west1
us-west2
us-east1
us-east4
southamerica-east1
northamerica-northeast1
asia-east1
asia-northeast1
asia-northeast3
asia-south1
asia-southeast1
australia-southeast1
europe-west1
europe-west2
europe-west4
- STORAGE_OUTPUT_FOLDER: le Nom du dossier Cloud�Storage dans lequel vous souhaitez enregistrer la vid�o encod�e de sortie.
{ "config": { "inputs": [ { "key": "input0", "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_INPUT_VIDEO" } ], "elementaryStreams": [ { "key": "video-stream0", "videoStream": { "h264": { "heightPixels": 360, "widthPixels": 640, "bitrateBps": 550000, "frameRate": 60 } } }, { "key": "audio-stream0", "audioStream": { "codec": "aac", "bitrateBps": 64000 } } ], "muxStreams": [ { "key": "sd", "container": "mp4", "elementaryStreams": [ "video-stream0", "audio-stream0" ] } ], "output": { "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_OUTPUT_FOLDER/" }, "overlays": [ { "image": { "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_INPUT_OVERLAY", "resolution": { "x": 0, "y": 0 }, "alpha": 1 }, "animations": [ { "animationFade": { "fadeType": "FADE_IN", "xy": { "x": 0.5, "y": 0.5 }, "startTimeOffset": "5s", "endTimeOffset": "10s" } }, { "animationFade": { "fadeType": "FADE_OUT", "xy": { "x": 0.5, "y": 0.5 }, "startTimeOffset": "12s", "endTimeOffset": "15s" } } ] } ] } }
- Ex�cutez la commande suivante�:
Un r�sultat semblable aux lignes suivantes doit s'afficher:gcloud transcoder jobs create --location=LOCATION --file="request.json"
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION/jobs/JOB_ID", "config": { ... }, "state": "PENDING", "createTime": CREATE_TIME, "ttlAfterCompletionDays": 30 }
C#
Avant d'essayer cet exemple, suivez les instructions de configuration pour C# du guide de d�marrage rapide de l'API Transcoder � l'aide des biblioth�ques clientes. Pour en savoir plus, consultez les API Transcoder C# documentation de r�f�rence.
Pour vous authentifier aupr�s de l'API Transcoder, configurez les identifiants par d�faut de l'application. Pour en savoir plus, consultez Configurer l'authentification pour un environnement de d�veloppement local.
Go
Avant d'essayer cet exemple, suivez les instructions de configuration de Go dans le Guide de d�marrage rapide de l'API Transcoder avec biblioth�ques clientes. Pour en savoir plus, consultez la documentation de r�f�rence sur l'API Transcoder pour Go.
Pour vous authentifier aupr�s de l'API Transcoder, configurez les identifiants par d�faut de l'application. Pour en savoir plus, consultez Configurer l'authentification pour un environnement de d�veloppement local.
Java
Avant d'essayer cet exemple, suivez les instructions de configuration de Java dans le Guide de d�marrage rapide de l'API Transcoder avec biblioth�ques clientes. Pour en savoir plus, consultez la documentation de r�f�rence sur l'API Transcoder pour Java.
Pour vous authentifier aupr�s de l'API Transcoder, configurez le service Identifiants par d�faut de l'application. Pour en savoir plus, consultez Configurer l'authentification pour un environnement de d�veloppement local.
Node.js
Avant d'essayer cet exemple, suivez les instructions de configuration pour Node.js du guide de d�marrage rapide de l'API Transcoder � l'aide des biblioth�ques clientes. Pour en savoir plus, consultez les API Transcoder Node.js documentation de r�f�rence.
Pour vous authentifier aupr�s de l'API Transcoder, configurez le service Identifiants par d�faut de l'application. Pour en savoir plus, consultez Configurer l'authentification pour un environnement de d�veloppement local.
PHP
Avant d'essayer cet exemple, suivez les instructions de configuration de PHP dans le Guide de d�marrage rapide de l'API Transcoder avec biblioth�ques clientes. Pour en savoir plus, consultez les API Transcoder PHP documentation de r�f�rence.
Pour vous authentifier aupr�s de l'API Transcoder, configurez les identifiants par d�faut de l'application. Pour en savoir plus, consultez Configurer l'authentification pour un environnement de d�veloppement local.
Python
Avant d'essayer cet exemple, suivez les instructions de configuration pour Python du guide de d�marrage rapide de l'API Transcoder � l'aide des biblioth�ques clientes. Pour en savoir plus, consultez les API Transcoder Python documentation de r�f�rence.
Pour vous authentifier aupr�s de l'API Transcoder, configurez le service Identifiants par d�faut de l'application. Pour en savoir plus, consultez Configurer l'authentification pour un environnement de d�veloppement local.
Ruby
Avant d'essayer cet exemple, suivez les instructions de configuration de Ruby dans le Guide de d�marrage rapide de l'API Transcoder avec biblioth�ques clientes. Pour en savoir plus, consultez la documentation de r�f�rence sur l'API Transcoder pour Ruby.
Pour vous authentifier aupr�s de l'API Transcoder, configurez les identifiants par d�faut de l'application. Pour en savoir plus, consultez Configurer l'authentification pour un environnement de d�veloppement local.
Dans la vid�o obtenue, la superposition anim�e pr�sente les caract�ristiques suivantes�:
- Elle commence � appara�tre au bout de 5�secondes de lecture dans la vid�o de sortie. La valeur alpha de la superposition commence � 0 et se termine � 1.0. Le coin sup�rieur gauche de la superposition appara�t au centre de la vid�o de sortie. La superposition appara�t dans sa r�solution d'image initiale.
- Une fois l'image en superposition affich�e, elle appara�t pendant 2�secondes.
- Elle commence � dispara�tre au bout de 12�secondes de lecture dans la vid�o de sortie. La valeur alpha de la superposition commence � 0 et se termine � 1.0.
- L'animation dispara�t avant d'atteindre 15�secondes de lecture.
Consultez l'exemple de vid�o de sortie pour cette configuration. Cette vid�o utilise un exemple d'image en superposition.