Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,14 @@ export class NftThumbnailService {
private async extractScreenshotFromVideo(buffer: Buffer, nftIdentifier: string): Promise<Buffer | undefined> {
// we try to extract frames at 0, 10, 30 seconds, and we take the frame that has the biggest size
// (i.e. the bigger the size, the more "crisp" an image should be, since it contains more details)
//
// Screenshots are written as PNG (RGB) rather than JPEG on purpose: the MJPEG/JPEG encoder
// (strict since ffmpeg 8.0) rejects limited-range ("tv") YUV videos with "Non full-range YUV
// is non-standard ..." and fails to open the encoder (-22). PNG has no such range constraint,
// so it works for every video format. The final JPEG thumbnail is produced downstream by sharp
// in extractThumbnailFromImage, so the intermediate format does not affect the output.
const frames = [0, 10, 30];
const filePaths = frames.map(x => path.join(this.apiConfigService.getTempUrl(), `${nftIdentifier}.screenshot.${x}.jpg`));
const filePaths = frames.map(x => path.join(this.apiConfigService.getTempUrl(), `${nftIdentifier}.screenshot.${x}.png`));

const videoPath = path.join(this.apiConfigService.getTempUrl(), nftIdentifier);
await FileUtils.writeFile(buffer, videoPath);
Expand Down
Loading