Reputation: 1665
Using the Node JS client, I can't get the Transcoder API to accept the pub/sub destination.
The documentation variously says to configure the pubsub_destination
field or the pubsubDestination
field, but neither appear to work when creating a job using the createJob
method (following and extending the example for ad-hoc job creation).
const config = {
parent: client.locationPath(projectId, location),
job: {
inputUri: inputUri,
outputUri: outputUri,
config: {
elementaryStreams: [
{
key: 'video-stream0',
videoStream: {
h264: {
heightPixels: 360,
widthPixels: 640,
bitrateBps: 550000,
frameRate: 60
}
}
},
{
key: 'audio-stream0',
audioStream: {
codec: 'aac',
bitrateBps: 64000
}
}
],
muxStreams: [
{
elementaryStreams: ['video-stream0', 'audio-stream0'],
key: 'sd',
filename: 'sd.mp4',
container: 'mp4'
}
]
},
pubsubDestination: { topic: `projects/${projectId}/topics/transcoder` }
}
};
return await client.createJob(request);
The job gets created and completes successfully, but the config field of the created job shows "pubsubDestination": null
.
What am I doing wrong?
Upvotes: 1
Views: 451
Reputation: 1464
I have tried creating a job using an ad-hoc configuration template with a pubsubDestination field in the jobConfig and successfully received the job status updates from the Transcoder API to Pub/Sub topic. Try the following code for your requirement:
projectId = 'my-project-id';
location = 'us-central1';
inputUri = 'gs://my-bucket/my-video-file';
outputUri = 'gs://my-bucket/my-output-folder/';
// Imports the Transcoder library
const {TranscoderServiceClient} =
require('@google-cloud/video-transcoder').v1;
// Instantiates a client
const transcoderServiceClient = new TranscoderServiceClient();
async function createJobFromAdHoc() {
// Construct request
const request = {
parent: transcoderServiceClient.locationPath(projectId, location),
job: {
inputUri: inputUri,
outputUri: outputUri,
config: {
elementaryStreams: [
{
key: 'video-stream0',
videoStream: {
h264: {
heightPixels: 360,
widthPixels: 640,
bitrateBps: 550000,
frameRate: 60,
},
},
},
{
key: 'video-stream1',
videoStream: {
h264: {
heightPixels: 720,
widthPixels: 1280,
bitrateBps: 2500000,
frameRate: 60,
},
},
},
{
key: 'audio-stream0',
audioStream: {
codec: 'aac',
bitrateBps: 64000,
},
},
],
muxStreams: [
{
key: 'sd',
container: 'mp4',
elementaryStreams: ['video-stream0', 'audio-stream0'],
},
{
key: 'hd',
container: 'mp4',
elementaryStreams: ['video-stream1', 'audio-stream0'],
},
],
pubsubDestination: {
topic: 'projects/{project-ID}/topics/{topic-ID}'
},
},
},
};
// Run request
const [response] = await transcoderServiceClient.createJob(request);
console.log(`Job: ${response.name}`);
}
createJobFromAdHoc();
Result:
Upvotes: 1