C# ScheduleVideoFrame output wrong color and position
Posted: Wed May 05, 2021 7:39 am
Hello,
I have a Decklink Quad 2 and I'm trying to push frames from a video file to his SDI output.
I downloaded the example projects and I tried editing SignalGenCSharp, I am currently able to extract frames from the video, convert them to a Bitmap (Format32bppArgb) and push them to the SDI output using pixel format bmdFormat8BitARGB.
When I watch the result on my Blackmagic video assist the image is out of offset and it seems like there is a red filter covering it.
I tried different formats and resolutions but I found similar results.
how I enable the video output
how I convert the Bitmap to argb32
how I create the decklink frame (CreateOutputVideoFrame)
m_currentFrame is a byte array that stores the Argb frame, I used that to fill the frame
This is the result, a couple of pixel offset on the X and with the red filter
This is m_currentFrame when I save it to my computer
Any help would be appreciated.
Thank you for your time.
I have a Decklink Quad 2 and I'm trying to push frames from a video file to his SDI output.
I downloaded the example projects and I tried editing SignalGenCSharp, I am currently able to extract frames from the video, convert them to a Bitmap (Format32bppArgb) and push them to the SDI output using pixel format bmdFormat8BitARGB.
When I watch the result on my Blackmagic video assist the image is out of offset and it seems like there is a red filter covering it.
I tried different formats and resolutions but I found similar results.
how I enable the video output
- Code: Select all
m_selectedDevice.deckLinkOutput.EnableVideoOutput(m_selectedDisplayMode.GetDisplayMode(), _BMDVideoOutputFlags.bmdVideoOutputFlagDefault);
how I convert the Bitmap to argb32
- Code: Select all
Bitmap original = imageData.ToBitmap();
Trace.WriteLine("PixelFormat " + original.PixelFormat); //Format24bppRgb
Bitmap clone = new Bitmap(original.Width, original.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
using (Graphics gr = Graphics.FromImage(clone))
{
gr.DrawImage(original, new System.Drawing.Rectangle(0, 0, clone.Width, clone.Height));
}
using (var stream = new MemoryStream())
{
clone.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);
m_currentFrame = stream.ToArray();
}
m_videoFrameBars = CreateOutputVideoFrame(FillVideoFrame);
how I create the decklink frame (CreateOutputVideoFrame)
- Code: Select all
private IDeckLinkMutableVideoFrame CreateOutputVideoFrame(Action<IDeckLinkVideoFrame> fillFrame)
{
m_selectedDevice.deckLinkOutput.CreateVideoFrame(m_frameWidth, m_frameHeight, m_frameWidth * 4, _BMDPixelFormat.bmdFormat8BitARGB, _BMDFrameFlags.bmdFrameFlagFlipVertical, out scheduleFrame);
fillFrame(scheduleFrame);
return scheduleFrame;
}
m_currentFrame is a byte array that stores the Argb frame, I used that to fill the frame
- Code: Select all
void FillVideoFrame(IDeckLinkVideoFrame theFrame)
{
IntPtr buffer;
theFrame.GetBytes(out buffer);
Marshal.Copy(m_currentFrame, 0, buffer, m_currentFrame.Length);
}
This is the result, a couple of pixel offset on the X and with the red filter
This is m_currentFrame when I save it to my computer
Any help would be appreciated.
Thank you for your time.