Blackmagic Capture Card Ubuntu

Hello. I am trying to capture from a Blackmagic Decklink Mini Monitor 4k in Ubuntu under Qt Creator. I found the addons ofxBlackmagicGrabber and ofxDeckLink but the first one doesn’t come with examples and the second one seems to be coded for mac, so it asks for some dependencies that I don’t have. Does anyone have any experience with this? Thanks!

Hey, I had this working a while ago, it is a fork of kyle mcdonalds addon with a few changes

You can find it here

Works for ubuntu 18.0.4 with macbook pro hardware (thunderbolt capture) if your hardware is working with media express then this should work fine. Use the project generator or the update project wizard in qtcreator to add the addon.

Thanks a lot, I had some problems configuring the project with the qbs file but I think I got it now, I’ll try to use it and see what I can get.

Do you have an example that I could check maybe? I’m very new to programming in general and I get lost easily. Thanks!

There is an example in the repo.

cd to the openframeworks/addons folder on your machine
then run

git clone https://github.com/fred-dev/ofxBlackmagic

then make a new project with qtcreator, if you followed the install instructions you should have a wizard for creating or updating an openframeworks project, choose update and then navigate to the examples inside the addons folder (ofxBlackMagic_Capture_Example), continue through the process and you will have a project that should build fine.

Thanks again. I tested it and the console says the following:

[warning] ofGLRenderer: draw(): texture is not allocated
[warning] ofGLRenderer: draw(): texture is not allocated
[ error ] ofGLUtils: ofGetGLFormatFromPixelFormat(): unknown OF pixel formatOF_PIXELS_UNKNOWN, returning GL_LUMINANCE
[ error ] ofGLUtils: ofGetGLInternalFormatFromPixelFormat(): unknown OF pixel formatOF_PIXELS_UNKNOWN, returning GL_RGBA
[ error ] ofTexture: allocate(): ofTextureData has 0 width and/or height: 0x0 

It draws a framerate of around 13fps on the top left corner, but there is no video, just a black background. I setup the Blackmagic object for the resolution and the framerate of my camera, which works with the software of Blackmagic (which is also not open at the moment). What I’m I doing wrong? I checked an example of ofxVideoGrabber and what it does is that after each update the method vidGrabber.getPixels() is called into an ofPixels object, which then is allocated into an ofTexture object, which gets drawn in the end. Do you think this kind of approach would work?

Can you tell me what device you are using and what resolution and frame rate you are capturing at?

I made a change, but before you update from the github, can you try initing the capture with the other setup method
setup(int width, int height, float framerate);
Instead of using the blackmagic capture name. Let me know what happens. I don’t have a capture card close by to test.

Ok, I had a chance to check it out, I only have access to one machine, a macbook pro running ubuntu. I I also get the errors but this is in initialization. If I delay drawing for a few seconds there are no errors.

 if (ofGetElapsedTimeMillis()>3000){
            cam.drawColor(0,0,1920,1080);
        }

I do find that there might be something up with the current blackmagic driver, it sometimes does not seem to release the device for me when I close it, even with the blackmagic software.

I also only have an intensity extreme, thunderbolt model. I cannot capture higher than 1080i60 or 1080p30. I get consistent framerates across all capture modes.

I don’t have a lot of experience with Linux, and this works ok for me. I could suggest updating the blackmagic driver, (although I am on the latest and it seems like it does not always release the hardware).

Thank you very much for your help and sorry for the delay in the reply. It became too difficult or some days and I run into some deadlines but I finally got it working with a Mini Decklink 4K Recorder and a Blackmagic Micro 4K. I tried with other cameras but I could only get it working with that one, maybe I was doing something wrong. Do you know by chance how to grab a frame from the video stream at a specific event, like a key press or something like it? The methods are the ones of the official Blackmagic SDK right? Thanks again.

Thankyou fresla for fixing the blackmagic addon. It works with of 0.11 with linux ubuntu.
One question though, capturing HD video doesn’t run faster than 10fps. Is this a limitation of linux or am I doing something wrong? I work on a decent PC (i7/gtx1070/32gb ram), is this setup capable to obtain higher framerates?

Hi - I don’t have a nix system at the moment so I cannot test, but this should give full frame rates - there is something not right if you get 10fps with your system specs. Unfortunately I cannot troubleshoot now.

Thank you for the fast reply! Good to hear that the machine should be able to handle higher framerates.

I’m not asking you to solve my problem but if you or anyone else can share some hints on my PC’s performance, that would be great. It’s a fresh Ubuntu install (20.04 LTS), using the recommended Nvidia display driver and the app runs from the X desktop. The capture card is a PCI Decklink Mini Recorder and it’s using the latest Desktop Video Software.

I really don’t know where to look for a solution so any help is appreciated!

Does the blackmagic media express app give you better frame rates?

what frame rate do you get running the openframeworks video grabber example?

Thanks for the questions!
The Media Express app runs full framerates and the videograbber example shows 45fps (usb cam). So these seem to work fine.
I also tried the blackmagic addon with of version 10.1 but that also gives only 10 fps.
Are there other things I can try? Thanks for your support!

@phaseIV make sure you are in Release and not Debug. The performance difference can be quite big between those two on some platforms and that could explain the slow framerate.

Hello Theo, thanks but i knew that one. I did build of by using the compileOF script (that builds both versions, right?) and i have set release mode in qtcreator. I lack expertise to check wheather the executable actually is a release mode version…

Some ideas

Are you sure you are using the same capture mode in media express app as in oF? Also at least on my case qt ide sometimes eats my cpu… (force me to move to vscode) maybe is also your case and that makes the app to throttle down, with qt closed try launching your app from a terminal