- Posts: 2
- Joined: Tue Aug 04, 2020 2:38 am
- Real Name: Ray Kim
Hi, We're developing the preview program plays sdi signals by using .Net and WPF on Windows 10.
The signals from the video server for play-out.
I'm using IDeckLinkInputCallback::VideoInputFrameArrived() for gettting video and audio data like the CapturePreviewCSharp SDK sample.
Our problem was choppy audio sound.
I just pass audio from BMD DeckLink to the speaker(exactly monitor with HDMI) directly by setting 'Listen to this device' on Sound of Control Panel, so there's no codes in the app for audio processing.
Like the sample I run IDeckLinkInput::EnableVideoInput() with BMDVideoInputFlags.bmdVideoInputEnableFormatDetection flag for start capturing.
With that flag, the problem has happened.
It's the same with the CapturePreviewCSharp SDK sample, but
When I remove bmdVideoInputEnableFormatDetection flag and apply bmdModeNTSC to IDeckLinkInput::EnableVideoInput(), It works so fine.
The another strange one is that BMDDisplayMode doesn't cause this problem in ohter C++ samples(CapturePreview, LoopThroughWithOpenGLCompositing...)
For more information, when I remove drawing code(like below), It works well(no choppy sound) on any BMDDisplayMode. It's same with the CapturePreviewCSharp sample.
Because of it, I suspected the performance issue at first, but it work well on bmdModeNTSC...
I just want to know why these are happened.
The DeckLink SDK Manual is so simple for it...
Our team have no experience for developing broadcast solutions actually.
The signals from the video server for play-out.
I'm using IDeckLinkInputCallback::VideoInputFrameArrived() for gettting video and audio data like the CapturePreviewCSharp SDK sample.
Our problem was choppy audio sound.
I just pass audio from BMD DeckLink to the speaker(exactly monitor with HDMI) directly by setting 'Listen to this device' on Sound of Control Panel, so there's no codes in the app for audio processing.
Like the sample I run IDeckLinkInput::EnableVideoInput() with BMDVideoInputFlags.bmdVideoInputEnableFormatDetection flag for start capturing.
With that flag, the problem has happened.
It's the same with the CapturePreviewCSharp SDK sample, but
When I remove bmdVideoInputEnableFormatDetection flag and apply bmdModeNTSC to IDeckLinkInput::EnableVideoInput(), It works so fine.
The another strange one is that BMDDisplayMode doesn't cause this problem in ohter C++ samples(CapturePreview, LoopThroughWithOpenGLCompositing...)
For more information, when I remove drawing code(like below), It works well(no choppy sound) on any BMDDisplayMode. It's same with the CapturePreviewCSharp sample.
- Code: Select all
public void Draw()
{
while (true)
{
var vPool = VideoFramePool.Pool.FirstOrDefault(x => x.Status == Enums.ProcessVideoFrameStatus.Converted);
if (vPool == null)
{
Thread.Sleep(10);
continue;
}
vPool.Status = Enums.ProcessVideoFrameStatus.Draw;
var width = vPool.Frame.GetWidth();
var height = vPool.Frame.GetHeight();
vPool.Frame.GetBytes(out var bgrbytes);
var rect = new Int32Rect(0, 0, width, height);
Helpers.RunOnStaThread(() =>
{
Application.Current.Dispatcher.Invoke(() =>
{
if (bitmapSource == null)
{
bitmapSource = new WriteableBitmap(width, height, DPI_X, DPI_Y, PIXEL_FORMAT, null);
var brush = new ImageBrush();
brush.ImageSource = bitmapSource;
this.PreviewImage.Background = brush;
}
if (bitmapSource.Width != width || bitmapSource.Height != height)
{
bitmapSource = new WriteableBitmap(width, height, DPI_X, DPI_Y, PIXEL_FORMAT, null);
var brush = new ImageBrush();
brush.ImageSource = bitmapSource;
this.PreviewImage.Background = brush;
}
try
{
bitmapSource.Lock();
var backBuffer = bitmapSource.BackBuffer;
var byteLen = width * height * 4;
unsafe
{
Buffer.MemoryCopy(bgrbytes.ToPointer(), backBuffer.ToPointer(), byteLen, byteLen);
}
bitmapSource.AddDirtyRect(rect);
}
catch (Exception ex)
{
}
finally
{
bitmapSource.Unlock();
}
Win32.uSleep(sleepUs);
}
);
});
}
}
Because of it, I suspected the performance issue at first, but it work well on bmdModeNTSC...
I just want to know why these are happened.
The DeckLink SDK Manual is so simple for it...
Our team have no experience for developing broadcast solutions actually.