I’m trying to record video from camera and post it to google cloud. My frontend is in VueJS and I have Node.js server.
Basically on front I’ve got method to start recording:
const startVideo = async () => {
await room.localParticipant.enableCameraAndMicrophone()
const tracks = await createLocalTracks({
audio: true,
video: true,
})
if (room && room.localParticipant) {
tracks.forEach(track => {
room.localParticipant.publishTrack(track)
})
}
try {
const response = await fetch('http://localhost:3000/start-recording', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ roomName: room.name })
})
const data = await response.json()
console.log('Recording started...', data)
} catch (error) {
console.error('Error while starting recording:', error)
}
}
I’m connected to the proper room, have proper token etc.
On Node.js server side I have method which run startRecording:
app.post('/start-recording', async (req, res) => {
const { roomName } = req.body
try {
const egressId = await startRecording(roomName)
res.send({ message: 'Recording started', egressId })
} catch (error) {
res.status(500).send({ message: 'Error while start recording', error })
}
})
and method which should start room composite egress to capture video and sent it to google cloud:
async function startRecording(roomName) {
try {
const filepath = `recordings/${roomName}_${Date.now()}.mp4`
const fileOutput = new EncodedFileOutput({
filepath,
output: {
case: 'gcp',
value: new GCPUpload({
credentials,
bucket: bucket.id
})
}
})
const response = await egressClient.startRoomCompositeEgress(
roomName,
{
layout: 'grid',
video_bitrate: 4500,
width: 1280,
height: 720
}
)
return response.egress_id
} catch (error) {
console.error('Error while starting recording:', error)
throw error
}
}
I’m passing proper room name, bucket name, all credentials are fine. But from some reason I have that error. I’ve tried debug and error occurs in TwirRpc.js while making some POST request.
https://docs.livekit.io/home/egress/room-composite/#roomcomposite-egress Here is documentation which I’ve used. But there is no information about GCP.. I got all required fields from library code.
Maybe I’m missing smth in configuration?