Streampunk / macadam

Async node.js interface to Blackmagic Design capture and playback devices.
Apache License 2.0
107 stars 24 forks source link

Playback example - send PNG image to card #7

Closed lklepner closed 7 years ago

lklepner commented 7 years ago

Hi!

I'm attempting to take my first steps with Macadam and a BM Decklink Duo 2 card by loading a local PNG (1920x1080) and trying to pass it to the frame() method... resulting in the error below.

Error: Problem scheduling frame: Failed to create frame. at Playback.frame (C:\electron-demo\node_modules\macadam\index.js:152:13) at Timeout.loadFrame [as _onTimeout] (C:\electron-demo\bmtest.js:25:11) at ontimeout (timers.js:380:14) at tryOnTimeout (timers.js:244:5) at Timer.listOnTimeout (timers.js:214:5)

Here is my code

var macadam = require('macadam'); var fs = require('fs');

// First argument is the DeckLink device number. // Set appropriate values from display mode and pixel format from those macadam provides. var playback = new macadam.Playback(0, macadam.bmdModeHD1080i50, macadam.bmdFormat10BitYUV);

var imageBuffer; fs.readFile(__dirname + '\images\test-image.png', onImageLoaded);

function onImageLoaded(err, data){ if (err) throw err; console.log(data); imageBuffer = data; var frameInterval = setInterval(loadFrame, 1000); }

function loadFrame(){ console.log('play frame'); playback.frame(imageBuffer); }

playback.on('played', function (x) { // Send the next frame in sequence. console.log('played'); });

playback.on('error', function (err) { // Handle errors found during playback. console.log(err); });

I suspect I'm missing a step between loading the PNG and passing the buffer to the frame method? Can you point me in the right direction?

lklepner commented 7 years ago

I just realized the scratch folder contains a demo which outputs a raw file to the card - this might be more appropriate since it avoids PNG decoding, if I understand correctly.

sparkpunkd commented 7 years ago

You need to get the data into a format supported by the card. Typically, these are broadcast-specific formats. The format you selected is known as V210 - an uncompressed image format for 10-bit per sample images. The Blackmagic SDK documentation goes into the detail.

The documentation is available as part of the developer SDK, downloadable from https://www.blackmagicdesign.com/nl/support

Closing as this is not a macadam-specific issue.