Skip to content

Commit d281aea

Browse files
irataxygcf-owl-bot[bot]sofisl
committed
docs: update Transcoder API samples to v1 (#99)
* feat: update Transcoder API samples to v1 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Address feedback. Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: sofisl <[email protected]>
1 parent 960d3d3 commit d281aea

17 files changed

+91
-62
lines changed

media/transcoder/createJobFromAdHoc.js

+14-11
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ function main(projectId, location, inputUri, outputUri) {
2626
// outputUri = 'gs://my-bucket/my-output-folder/';
2727

2828
// Imports the Transcoder library
29-
const {TranscoderServiceClient} = require('@google-cloud/video-transcoder');
29+
const {TranscoderServiceClient} =
30+
require('@google-cloud/video-transcoder').v1;
3031

3132
// Instantiates a client
3233
const transcoderServiceClient = new TranscoderServiceClient();
@@ -43,21 +44,23 @@ function main(projectId, location, inputUri, outputUri) {
4344
{
4445
key: 'video-stream0',
4546
videoStream: {
46-
codec: 'h264',
47-
heightPixels: 360,
48-
widthPixels: 640,
49-
bitrateBps: 550000,
50-
frameRate: 60,
47+
h264: {
48+
heightPixels: 360,
49+
widthPixels: 640,
50+
bitrateBps: 550000,
51+
frameRate: 60,
52+
},
5153
},
5254
},
5355
{
5456
key: 'video-stream1',
5557
videoStream: {
56-
codec: 'h264',
57-
heightPixels: 720,
58-
widthPixels: 1280,
59-
bitrateBps: 2500000,
60-
frameRate: 60,
58+
h264: {
59+
heightPixels: 720,
60+
widthPixels: 1280,
61+
bitrateBps: 2500000,
62+
frameRate: 60,
63+
},
6164
},
6265
},
6366
{

media/transcoder/createJobFromPreset.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ function main(projectId, location, inputUri, outputUri, preset) {
2727
// preset = 'preset/web-hd';
2828

2929
// Imports the Transcoder library
30-
const {TranscoderServiceClient} = require('@google-cloud/video-transcoder');
30+
const {TranscoderServiceClient} =
31+
require('@google-cloud/video-transcoder').v1;
3132

3233
// Instantiates a client
3334
const transcoderServiceClient = new TranscoderServiceClient();

media/transcoder/createJobFromTemplate.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ function main(projectId, location, inputUri, outputUri, templateId) {
2727
// templateId = 'my-job-template';
2828

2929
// Imports the Transcoder library
30-
const {TranscoderServiceClient} = require('@google-cloud/video-transcoder');
30+
const {TranscoderServiceClient} =
31+
require('@google-cloud/video-transcoder').v1;
3132

3233
// Instantiates a client
3334
const transcoderServiceClient = new TranscoderServiceClient();

media/transcoder/createJobTemplate.js

+14-11
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ function main(projectId, location, templateId) {
2525
// templateId = 'my-job-template';
2626

2727
// Imports the Transcoder library
28-
const {TranscoderServiceClient} = require('@google-cloud/video-transcoder');
28+
const {TranscoderServiceClient} =
29+
require('@google-cloud/video-transcoder').v1;
2930

3031
// Instantiates a client
3132
const transcoderServiceClient = new TranscoderServiceClient();
@@ -41,21 +42,23 @@ function main(projectId, location, templateId) {
4142
{
4243
key: 'video-stream0',
4344
videoStream: {
44-
codec: 'h264',
45-
heightPixels: 360,
46-
widthPixels: 640,
47-
bitrateBps: 550000,
48-
frameRate: 60,
45+
h264: {
46+
heightPixels: 360,
47+
widthPixels: 640,
48+
bitrateBps: 550000,
49+
frameRate: 60,
50+
},
4951
},
5052
},
5153
{
5254
key: 'video-stream1',
5355
videoStream: {
54-
codec: 'h264',
55-
heightPixels: 720,
56-
widthPixels: 1280,
57-
bitrateBps: 2500000,
58-
frameRate: 60,
56+
h264: {
57+
heightPixels: 720,
58+
widthPixels: 1280,
59+
bitrateBps: 2500000,
60+
frameRate: 60,
61+
},
5962
},
6063
},
6164
{

media/transcoder/createJobWithAnimatedOverlay.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ function main(projectId, location, inputUri, overlayImageUri, outputUri) {
2727
// outputUri = 'gs://my-bucket/my-output-folder/';
2828

2929
// Imports the Transcoder library
30-
const {TranscoderServiceClient} = require('@google-cloud/video-transcoder');
30+
const {TranscoderServiceClient} =
31+
require('@google-cloud/video-transcoder').v1;
3132

3233
// Instantiates a client
3334
const transcoderServiceClient = new TranscoderServiceClient();
@@ -44,11 +45,12 @@ function main(projectId, location, inputUri, overlayImageUri, outputUri) {
4445
{
4546
key: 'video-stream0',
4647
videoStream: {
47-
codec: 'h264',
48-
heightPixels: 360,
49-
widthPixels: 640,
50-
bitrateBps: 550000,
51-
frameRate: 60,
48+
h264: {
49+
heightPixels: 360,
50+
widthPixels: 640,
51+
bitrateBps: 550000,
52+
frameRate: 60,
53+
},
5254
},
5355
},
5456
{

media/transcoder/createJobWithPeriodicImagesSpritesheet.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ function main(projectId, location, inputUri, outputUri) {
2626
// outputUri = 'gs://my-bucket/my-output-folder/';
2727

2828
// Imports the Transcoder library
29-
const {TranscoderServiceClient} = require('@google-cloud/video-transcoder');
29+
const {TranscoderServiceClient} =
30+
require('@google-cloud/video-transcoder').v1;
3031

3132
// Instantiates a client
3233
const transcoderServiceClient = new TranscoderServiceClient();
@@ -43,11 +44,12 @@ function main(projectId, location, inputUri, outputUri) {
4344
{
4445
key: 'video-stream0',
4546
videoStream: {
46-
codec: 'h264',
47-
heightPixels: 360,
48-
widthPixels: 640,
49-
bitrateBps: 550000,
50-
frameRate: 60,
47+
h264: {
48+
heightPixels: 360,
49+
widthPixels: 640,
50+
bitrateBps: 550000,
51+
frameRate: 60,
52+
},
5153
},
5254
},
5355
{

media/transcoder/createJobWithSetNumberImagesSpritesheet.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ function main(projectId, location, inputUri, outputUri) {
2626
// outputUri = 'gs://my-bucket/my-output-folder/';
2727

2828
// Imports the Transcoder library
29-
const {TranscoderServiceClient} = require('@google-cloud/video-transcoder');
29+
const {TranscoderServiceClient} =
30+
require('@google-cloud/video-transcoder').v1;
3031

3132
// Instantiates a client
3233
const transcoderServiceClient = new TranscoderServiceClient();
@@ -43,11 +44,12 @@ function main(projectId, location, inputUri, outputUri) {
4344
{
4445
key: 'video-stream0',
4546
videoStream: {
46-
codec: 'h264',
47-
heightPixels: 360,
48-
widthPixels: 640,
49-
bitrateBps: 550000,
50-
frameRate: 60,
47+
h264: {
48+
heightPixels: 360,
49+
widthPixels: 640,
50+
bitrateBps: 550000,
51+
frameRate: 60,
52+
},
5153
},
5254
},
5355
{

media/transcoder/createJobWithStaticOverlay.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ function main(projectId, location, inputUri, overlayImageUri, outputUri) {
2727
// outputUri = 'gs://my-bucket/my-output-folder/';
2828

2929
// Imports the Transcoder library
30-
const {TranscoderServiceClient} = require('@google-cloud/video-transcoder');
30+
const {TranscoderServiceClient} =
31+
require('@google-cloud/video-transcoder').v1;
3132

3233
// Instantiates a client
3334
const transcoderServiceClient = new TranscoderServiceClient();
@@ -44,11 +45,12 @@ function main(projectId, location, inputUri, overlayImageUri, outputUri) {
4445
{
4546
key: 'video-stream0',
4647
videoStream: {
47-
codec: 'h264',
48-
heightPixels: 360,
49-
widthPixels: 640,
50-
bitrateBps: 550000,
51-
frameRate: 60,
48+
h264: {
49+
heightPixels: 360,
50+
widthPixels: 640,
51+
bitrateBps: 550000,
52+
frameRate: 60,
53+
},
5254
},
5355
},
5456
{

media/transcoder/deleteJob.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ function main(projectId, location, jobId) {
2525
// jobId = 'my-job-id';
2626

2727
// Imports the Transcoder library
28-
const {TranscoderServiceClient} = require('@google-cloud/video-transcoder');
28+
const {TranscoderServiceClient} =
29+
require('@google-cloud/video-transcoder').v1;
2930

3031
// Instantiates a client
3132
const transcoderServiceClient = new TranscoderServiceClient();

media/transcoder/deleteJobTemplate.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ function main(projectId, location, templateId) {
2525
// templateId = 'my-job-template';
2626

2727
// Imports the Transcoder library
28-
const {TranscoderServiceClient} = require('@google-cloud/video-transcoder');
28+
const {TranscoderServiceClient} =
29+
require('@google-cloud/video-transcoder').v1;
2930

3031
// Instantiates a client
3132
const transcoderServiceClient = new TranscoderServiceClient();

media/transcoder/getJob.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ function main(projectId, location, jobId) {
2525
// jobId = 'my-job-id';
2626

2727
// Imports the Transcoder library
28-
const {TranscoderServiceClient} = require('@google-cloud/video-transcoder');
28+
const {TranscoderServiceClient} =
29+
require('@google-cloud/video-transcoder').v1;
2930

3031
// Instantiates a client
3132
const transcoderServiceClient = new TranscoderServiceClient();

media/transcoder/getJobState.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ function main(projectId, location, jobId) {
2525
// jobId = 'my-job-id';
2626

2727
// Imports the Transcoder library
28-
const {TranscoderServiceClient} = require('@google-cloud/video-transcoder');
28+
const {TranscoderServiceClient} =
29+
require('@google-cloud/video-transcoder').v1;
2930

3031
// Instantiates a client
3132
const transcoderServiceClient = new TranscoderServiceClient();

media/transcoder/getJobTemplate.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ function main(projectId, location, templateId) {
2525
// templateId = 'my-job-template';
2626

2727
// Imports the Transcoder library
28-
const {TranscoderServiceClient} = require('@google-cloud/video-transcoder');
28+
const {TranscoderServiceClient} =
29+
require('@google-cloud/video-transcoder').v1;
2930

3031
// Instantiates a client
3132
const transcoderServiceClient = new TranscoderServiceClient();

media/transcoder/listJobTemplates.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ function main(projectId, location) {
2424
// location = 'us-central1';
2525

2626
// Imports the Transcoder library
27-
const {TranscoderServiceClient} = require('@google-cloud/video-transcoder');
27+
const {TranscoderServiceClient} =
28+
require('@google-cloud/video-transcoder').v1;
2829

2930
// Instantiates a client
3031
const transcoderServiceClient = new TranscoderServiceClient();

media/transcoder/listJobs.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ function main(projectId, location) {
2424
// location = 'us-central1';
2525

2626
// Imports the Transcoder library
27-
const {TranscoderServiceClient} = require('@google-cloud/video-transcoder');
27+
const {TranscoderServiceClient} =
28+
require('@google-cloud/video-transcoder').v1;
2829

2930
// Instantiates a client
3031
const transcoderServiceClient = new TranscoderServiceClient();

media/transcoder/quickstart.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ async function main(projectId, location) {
2121
*/
2222
// const projectId = 'my-project';
2323
// const location = 'us-central1';
24-
const {TranscoderServiceClient} = require('@google-cloud/video-transcoder');
24+
const {TranscoderServiceClient} =
25+
require('@google-cloud/video-transcoder').v1;
2526
const client = new TranscoderServiceClient();
2627
async function listJobs() {
2728
const [jobs] = await client.listJobs({

media/transcoder/test/transcoder.test.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,17 @@ after(async () => {
105105
describe('Job template functions', () => {
106106
before(() => {
107107
// Delete the job template if it already exists
108-
execSync(
109-
`node deleteJobTemplate.js ${projectId} ${location} ${templateId}`,
110-
{
111-
cwd,
112-
}
113-
);
108+
try {
109+
execSync(
110+
`node deleteJobTemplate.js ${projectId} ${location} ${templateId}`,
111+
{
112+
cwd,
113+
}
114+
);
115+
} catch (err) {
116+
// ignore not found error
117+
}
118+
114119
const output = execSync(
115120
`node createJobTemplate.js ${projectId} ${location} ${templateId}`,
116121
{cwd}

0 commit comments

Comments
 (0)