How to flip a video frame/source?

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

Scott Heimendinger

  • Posts: 2
  • Joined: Mon Dec 18, 2017 6:58 pm

How to flip a video frame/source?

PostThu Jan 04, 2018 10:52 pm

What's the best way to flip (vertically, for example) my video source?

Specifically, in the CapturePreviewCSharp project, I'd like to flip the video feed that's rendered to the PreviewWindow. It wasn't immediately obvious where I can apply this transform. I tried applying the transform to the m_d3DDevice using the below, but it never made an impact:

Inside PreviewWindow.cs: Render()
Code: Select all
m_d3DDevice.SetTransform(Direct3D.TransformType.Projection, Matrix.RotationX(180));

Code: Select all

Neither throw an error, but neither flip the image either.

I also looked at flipping the incoming IDeckLinkVideoFrame inside IDeckLinkScreenPreviewCallback.DrawFrame, but it wasn't clear how to flip a video frame.

Any guidance is greatly appreciated!

Cameron Nichols

Blackmagic Design

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

Re: How to flip a video frame/source?

PostMon Jan 08, 2018 11:07 pm

Hi Scott,

The IDeckLinkDX9ScreenPreviewHelper has it's own transform function implemented, so it will override attempt to call SetTransform externally. However, it is possible to rotate the preview by 180 degrees (in case camera is mounted up-side-down), by swapping left/right and top/bottom coordinates of the viewport rectangle.

For flipping, the solution will be to either:
1) Iterate through frame lines and manually swap lines (CPU intensive).
2) Implement own DirectX or OpenGL helper to perform own custom transforms.


Return to Software Developers

Who is online

Users browsing this forum: No registered users and 5 guests