I am using the latest TS.ED framework which uses Typescript and is based on Express/node.js itself. Below, I am using the FFmpeg library to generate snapshots and then creating a zip folder of all those thumbnails and sending as a response to the client(Angular) or Postman to receive the zip file as a stream).
@Get('/thumbnails')
@Returns(400, BadRequest)
@(Returns(500).Description(`Internal Server Error`))
async generateThumbnails(
@QueryParams('video') videoURL: string
@Res() resp: Res
): Promise<fs.ReadStream> {
resp.setHeader('Content-Disposition', `attachment; filename=thumbnails.zip`);
resp.setHeader('Content-Type', 'application/zip');
return await this.myffmpegService.generateThumbnailsFromVideo(videoURL);
}
My question is how we will be able to find out that the stream transferred is not complete meaning suppose if it is a video stream(of 10 seconds) that might fail at 8th second, then the client will get up to the 8th second of the video data stream only, I just want to figure out that how can we add(somehow) the error that "this is not complete data but with a specific error" (occurred in between)?