CaptureStills very slow

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

Mike Rauchwerk

  • Posts: 2
  • Joined: Fri Jun 12, 2020 3:11 am
  • Real Name: michael rauchwerk

CaptureStills very slow

PostTue Jun 23, 2020 11:16 am

I am having trouble with the speed of CaptureStills from the SDK examples. The ConvertFrame and WriteBgra32VideoFrameToPNG take so much time that I cannot capture frames in real time. Is there any way to speed this up? I have had no trouble reading, processing and writing frames in real time using CV2 from Python.

Thanks,

Mike Rauchwerk
Offline

Cameron Nichols

Blackmagic Design

  • Posts: 271
  • Joined: Mon Sep 04, 2017 4:05 am

Re: CaptureStills very slow

PostThu Jun 25, 2020 12:07 am

Hi Mike,

The CaptureStills sample wasn't designed to capture real-time video, but a fixed number of still frames.

If you the combined latency of IDeckLinkVideoConversion::ConvertFrame and WriteBgra32VideoFrameToPNG is more than 1 frame duration, then the received frame queue will fill and you will eventually exhaust the memory allocator for video input frames.

My recommendations to improve this are:
  • Bring forward release of receivedVideoFrame to just after ConvertFrame. If conversion is required, then the received frame is no longer required after this point.
  • Consider splitting the CaptureStills worker thread into 2 threads, one for ConvertFrame, the other for WriteBgra32VideoFrameToPNG, with a queue to manage frames between each thread. This will better pipeline your processing to allow working on multiple frames at once.
  • If you find either ConvertFrame or WriteBgra32VideoFrameToPNG tasks are still longer than frame duration, then you will then need to further increase threads, have a look at DispatchQueue in InputLoopThrough for an example how to use multiple threads for video frame processing.
Please let me know if you need me to elaborate on any of these points.

Regards
Cameron

Return to Software Developers

Who is online

Users browsing this forum: No registered users and 4 guests