Blackmagic 3G-SDI Shield input

Ask software engineering and SDK questions for developers working on Mac OS X, Windows or Linux.
  • Author
  • Message
Offline

Trilec

  • Posts: 8
  • Joined: Thu Sep 24, 2020 10:23 am
  • Real Name: Curtis Edward

Blackmagic 3G-SDI Shield input

PostTue Dec 01, 2020 10:58 am

Hi All,
Ive been struggling to find this information:
Can you get to the input stream to extract metadata packet information.
I would like to get the focus/lens and timecode metadata. (HANC and VANC space of the HD-SDI signal.)
or

Is it available but no library to access it? (ie. i would need to code something)

It seem a shame to have such a awesome device, but unable to get this data.
If not , where can I put a request for Black-magic to consider this feature?

Cheers
Curt
Offline

daver2

  • Posts: 7
  • Joined: Fri Dec 04, 2020 7:39 pm
  • Real Name: Dave Roberts

Re: Blackmagic 3G-SDI Shield input

PostTue Dec 08, 2020 8:42 am

I have a similar question...

We have connected a number of PTZ cameras to the VISCA port of our ATEM TV Studio Pro HD. Whilst Zoom is fine, Pan and Tilt is terrible using the trackball (lumpy control).

I have posted a message to see if anyone has had a similar problem with the ATEM or not - and doing further investigation with wireshark to see if there is a VISCA protocol incompatibility between the ATEM and the Cisco cameras we are using.

As a Plan ‘B’ I was looking to extract the Camera and Tally information from the SDI signal using the Arduino shield - but having minimal luck at finding any documentation or examples. I did find an old post indicating that this is difficult and buggy! Not what I am expecting from the quality of the BMD equipment I am seeing!

Can anyone help to kickstart me?

Cheers,

Dave
Offline

daver2

  • Posts: 7
  • Joined: Fri Dec 04, 2020 7:39 pm
  • Real Name: Dave Roberts

Re: Blackmagic 3G-SDI Shield input

PostWed Dec 09, 2020 7:45 pm

I think I am starting to answer my own question here...

I downloaded the BMD code and had a look through the files last night.

It looks like I need something like:

Code: Select all
// includes the Blackmagic Design SDI Control library.
#include <BMDSDIControl.h>

const int shieldAddress = 0x6E; // Match to shield configuration.
BMD_SDICameraControl_I2C ccu( shieldAddress );

int ccuLength = 0; // Number of bytes returned to process.

byte ccuData[256]; // Maximum allowed.

// Once initialisation...
//
void setup() {

  ccu.begin();
  ccu.setOverride( false );
 
} // End of function setup.

// Sit here for eternity...
//
void loop() {

  if( ccu.available() ) {

    ccuLength = ccu.read( ccuData, 256 );
 
    ccu.flushRead();

    // TODO: Process the data.

 } // End if.

} // End of function loop.


This should just sit and wait for an incoming SDI frame containing some data.

When the data frame occurs, .available() should return true.

At this point .read is invoked to extract the data packet itself. The data packet can be no longer than 256 bytes, so the read shouldn't fail because the incoming data packet was larger than the buffer.

The number of bytes in the packet is returned in ccuLength.

The .flushRead() call should prepare the shield for the next incoming frame.

Assuming a 1080p50 configuration, that should give me 20 milliseconds to process the current frame data before the next potential frame comes in.

I assume there is no help in parsing the packet of data that has been received and I have to do that myself.

How close am I to what is needed? Or is what I am stating pure rubbish!?

Assuming I want to pickup camera control packets (pan, tilt, zoom, focus, etc.) and which camera is currently selected to preview and live is this all I need - or would I have to intercept the tally messages as well?

I assume that when I get (say) a ZOOM message, the camera that has been selected by the ATEM will be within the header for the message?

Which SDI output on the ATEM would I be required to connect the 3G-SDI shield to? Or could I just connect it to the main output?

Cheers,

Dave
Offline

Ian Morrish

  • Posts: 557
  • Joined: Sun Jan 18, 2015 9:24 pm
  • Location: New Zealand

Re: Blackmagic 3G-SDI Shield input

PostWed Dec 09, 2020 11:43 pm

There is a lot of data and for all cameras so I check the bytes looking for a match.
In my case I was looking for IRIS value for a camera to send a proportional voltage out a PMW port.
Probably not the best way of doing it and I was wanting the shield to keep passing the remainder of the CCU data onto the camera but it would also stop doing that after some time (probably some buffer overrun)

if ((ccuLength == 11) && (ccuData[0] == cameraID) && (ccuData[5] == 2)) {
int angleValue = map(ccuData[9], 12, 70, 220, 60);
String camMessage = "Camera Iris:";

String camUdateMsg = camMessage + cameraData[0] + ":" + cameraData[9]+ ":" + cameraData[8] + "PMW value:" + angleValue;
Serial.println(camUdateMsg.c_str());

analogWrite(5,angleValue);

}
Regards,
Ian Morrish
Video Integrated Scripting Environment
(Windows PowerShell with ATEM driver + more)
https://ianmorrish.wordpress.com
Offline

Trilec

  • Posts: 8
  • Joined: Thu Sep 24, 2020 10:23 am
  • Real Name: Curtis Edward

Re: Blackmagic 3G-SDI Shield input

PostFri Dec 11, 2020 12:29 am

@daver2 Sounds very promising , please keep us posted on how you get on..


In the SDK the is a file Blackmagic DeckLink SDK 11.7\Examples\VancCapture.cpp

Can the SDK be used on the shield?

The basic setup with the SDK is:

get the card in the system
use first card found
get the interface
get the input
start the input
sample the stream
. get the frame (VideoInputFrameArrived)
. go through the (videoFrameAncillaryPackets)
. get your data
cleanup
Offline

Ian Morrish

  • Posts: 557
  • Joined: Sun Jan 18, 2015 9:24 pm
  • Location: New Zealand

Re: Blackmagic 3G-SDI Shield input

PostSat Dec 12, 2020 12:09 am

No :-(
Regards,
Ian Morrish
Video Integrated Scripting Environment
(Windows PowerShell with ATEM driver + more)
https://ianmorrish.wordpress.com
Offline

daver2

  • Posts: 7
  • Joined: Fri Dec 04, 2020 7:39 pm
  • Real Name: Dave Roberts

Re: Blackmagic 3G-SDI Shield input

PostSat Dec 12, 2020 4:40 pm

Unfortunately the SDK is not for the Arduino...

Ian, thanks for the update.

I have been looking a bit more into the Arduino shield code and what you posted and would like to post a few observations.

The .flushRead() doesn't appear to do what I expect it should do... It appears to arm the Output Command register and not the Input Command register?

The .read( data[], dataLength ) method appears to do everything necessary:

1. It returns 0 as a result if no data packet has been received.
2. It returns -1 as a result if the data buffer is not large enough to hold the received data packet. This error should be avoided if the data buffer is 256 bytes long - as this is the maximum size of data packet that can be accommodated by the hardware.
3. It returns a positive number (indicating the number of valid data bytes in the buffer) if a valid message was received by the hardware.
4. It automatically arms the Input Command flag ready to receive any further data.

I see in your code you used the construct "if( (ccuLength == 11) && ...". This should work if the only command present in the received packet is a valid IRIS command. If the ATEM packs more than one command into the frame, this conditional test would fail.

The other thing I would be dubious about would be to put the Serial code within the loop(). According to the Arduino documentation, the serial code should store the characters to be sent into a buffer that are then transmitted under control of interrupts. However, if the transmit buffer fills up, the Serial.printxx() stalls until the blockage has cleared. Assuming a serial bit rate of 9600 bits/second, this would equate to approximately 1 millisecond/character to transmit. I count approximately 23 fixed printable characters in your string (excluding the variable characters and the terminating <CR><LF>) and this would take approximately 25 milliseconds to clear - longer than 1 frame at 50Hz (20 milliseconds).

This depends majorly upon the rate that the ATEM sends the particular commands at when you twiddle a knob or series of knobs of course.

I was going to buy an Arduino and a BMD 3G-SDI shield to have a 'play with' and see what can be accomplished. Unfortunately, the availability of the shields is virtually zero at the moment. Everywhere I have looked in the UK does not have stock. When my favourite distributors opens up tomorrow I will ask them. They are normally pretty good at ringing around to find stock...

I will let you know what I find out...

Dave
Offline

daver2

  • Posts: 7
  • Joined: Fri Dec 04, 2020 7:39 pm
  • Real Name: Dave Roberts

Re: Blackmagic 3G-SDI Shield input

PostSat Dec 12, 2020 8:13 pm

First off I am using the online arduino IDE and the instructions within the BMD manual for the shield does not work...

Firstly, the library files need to be zipped up.

Secondly, there is a library.properties file required. I have created one of these as follows:

Code: Select all
name=BMD
version=1.0.0
author=BMD
maintainer=BMD
sentence=Blackmagic Design 3G SDI Control Shield Library.
paragraph=XXX
category=Communication
url=https://www.blackmagicdesign.com/uk
architectures=*


I installed this file into the same directory containing the keywords.txt file and zipped everything up at that level and lower (including the examples and include directories).

I was then able to use the Arduino library manager to import this library and my test sketch at least now compiles.

My view so far is that the BMD equipment is extremely good, but the documentation and software appears extremely unhelpful and lacking. I am happy to contribute to both...

Dave
Offline

Ian Morrish

  • Posts: 557
  • Joined: Sun Jan 18, 2015 9:24 pm
  • Location: New Zealand

Re: Blackmagic 3G-SDI Shield input

PostSun Dec 13, 2020 7:12 pm

Thanks Dave, the serial code within the loop() was just for debugging and not normally in there.
I was having problems when looking at larger packets of camera data and probably how inefficient my code was which is why I limited it to just dealing with single command which seemed to work fine for when iris was being changed.

The ATEM API lets you specify which camera parameters are refreshed and at what interval. Unfortunately the software control overrides this as soon as it starts.
I have written my own MiDi based CCU controller and using the shield to drive the iris of a b4 lens.
https://ianmorrish.wordpress.com/2020/05/28/atem-mini-ccu-hardware-interface-for-mbpcc-4k-6k/
Regards,
Ian Morrish
Video Integrated Scripting Environment
(Windows PowerShell with ATEM driver + more)
https://ianmorrish.wordpress.com
Offline
User avatar

Xtreemtec

  • Posts: 4739
  • Joined: Wed Jan 02, 2013 11:48 am
  • Location: The Netherlands

Re: Blackmagic 3G-SDI Shield input

PostMon Dec 14, 2020 2:12 pm

The Shield does have limited support for reading commands. BUT!! It's only on low level commands, not Arduino friendly brought to use, and there is a reason for that because it's buggy!!
That is probably why BMD left this option away from the product, it often misses data packets, there is a terrible bug in the Checksum calculation which is pointed out by a colleague but never got fixed in the firmware...

We designed and build our own solution to capture the data of the SDI as the Shield was incapable of doing this the correct way for us.. ;)
Daniel Wittenaar .:: Xtreemtec Media Productions ::. -= www.xtreemtec.nl =-
4K OBV Trailer, ATEM TVS HD, 4M/E Broadcast Studio 4K, Constelation 8K, Hyperdeck Studio 12G, Ursa Broadcast 4K, 4K fiber converters with Sony Control
Offline

Trilec

  • Posts: 8
  • Joined: Thu Sep 24, 2020 10:23 am
  • Real Name: Curtis Edward

Re: Blackmagic 3G-SDI Shield input

PostMon Dec 14, 2020 5:28 pm

"We designed and build our own solution to capture the data of the SDI "
@Xtreemtec any thing you care to share?

Ive been considering using the "M.2 DeckLink SDI Micro" in an SBC, or at least the smallest device that can take a 2 lane PCI M .2, just need to figure which SBC would be appropriate, so far the nvidia nano seems interesting.

c

Return to Software Developers

Who is online

Users browsing this forum: No registered users and 2 guests