How to kill a process within my program


Hi, I’ve been working on a project lately to communicate a Blackmagic Decklink capture card with an arduino through ffmpeg. What I need is basically capture some frames from the video stream of the capture card, which are triggered via an arduino through the serial port thanks to a filter of ffmpeg. In other words, a function of the program that I’m writing is to initiate ffmpeg with the necessary parameters to start capturing with this trigger functionality. However, before that I need to have access to the live feed of the Blackmagic camera, which I managed to get with ofxBlackmagic. I thought that a normal workflow would be to close the camera (it has a method .close) before opening ffmpeg, because devices can only be used once while capturing video. However, the camera seems to be still active after closing because ffmpeg fails to start capturing. Any idea on how to close the camera?


You can try destroying the ofxBlackmagic object afters closing it. That should also release the direct link connection.

As a side note using smart pointers its always recommended.

std::shared_ptr<ofxBlackMagic> cam;
and the initialize in setup or where you prefer
cam = std::shared_ptr<ofxBlackMagic>( new ofxBlackMagic);

to destroy it just call
Note that reseting the pointer without arguments will clear it and now its equal to a nullptr, so you must initialize it again before using it.


Thank you! That sounds like an ideal solution. I’m going to give it a try and post my results.


I think I’m doing something wrong. I put this on my header file:

std::shared_ptr cam;

and then this in my setup method:

cam = std::shared_ptr(new ofxBlackMagic);

but the object cam doesn’t carry the methods of ofxBlackmagic so when I stry to use cam.setup it says:

‘class std::shared_ptr’ has no member named ‘setup’

What I’m I doing wrong?


it should be

std::shared_ptr&lt;ofxBlackMagic&gt; cam;

instead of

std::shared_ptr cam;

You must specified the type of the pointer between <>
An then when using pointers, including smart ones, use -> instead of point . to access it’s properties and methods.


Oh I saw my mistake. This is the line in my header:

std::shared_ptr<ofxBlackMagic> cam;

This are the two lines in my setup method:

cam = std::shared_ptr<ofxBlackMagic>(new ofxBlackMagic);

It all seems to be working until I try to reset the pointer


error: ‘using element_type = class ofxBlackMagic {aka class ofxBlackMagic}’ has no member named ‘reset’

This last part is happening when I press a key (ofApp::keyPressed), any idea why that could be? Thank you for your help, I will read more about pointers.


reset is for the shared pinter, so it should be with point:


Ok ok, so all of the methods of pointers in general are called with the dot, and all of the ones of the pointed object with an arrow -> right?


That’s right. Take a look at this post


Thanks a lot!