How to write an audio-video playback engine using C # .Net and DirectX (comprehensive analysis)?

Premises:

I work in a company with a broadcast solution, and we buy sdk for playback from an external provider, which reduces the load on downloading, rendering, playback, etc. It provides us with many features such as character generator, image overlay, text, flash (* .swf), streaming, etc. We mainly focus on application development (not technology development). Thus, we make simple API calls from our C # code in the SDK DLL, such as play, pause, seak, overlay, etc., and it simplifies our life.

Meanwhile, we also face problems because sdk is provided by a third party in another country, so the quality of support depends on them. In addition, the feature additions made by them are general in nature and they give a new release every two weeks. There are a lot of errors in their code. We also face licensing issues, even when we bought their full product.


Requirements:

  • We want to evaluate the possibility of writing our own playback / rendering engine - initially with minimal features, but in the end we will add more functions to it, for example, overlay an image or text or a swf swf file, look for fast forward, etc.
  • We also accept direct input tape from hardware devices and send the video to the TV via hardware devices and record direct channels to the disc. We switch between live input and locally saved video files.
  • We need to play all kinds of videos (fast time, mp4, flv, etc.), so we will also depend on third-party codecs.
  • We can use different hardware cards for input and output, and you will need to sort through and get an affordable hardware configuration.
  • We are working on C #, and we have experienced developers in C #, and we do not want to use C ++ for development, as we currently do not have an expert in C ++.

Questions:

  • What should be our approach - can we write playback with the indicated functions using pure C # and DirectX 11 (is this the right way or is some other way better)?
  • How easy or difficult is it to achieve the same (subjective question - a subjective answer would be sufficient)?
  • Well-written C # code is slower than C ++ code (for DirectX and multimedia playback, where may I need up to 30 video frames per second for NTSC standards)?
  • What is a good way (resource) to run it (including concepts and coding)?

This is a comprehensive question, but you, an adviser, will make my direction and progress easy.

+4
source share
2 answers

While working on a project in which I built a 3D television graphics system using C # and .NET, I must say yes, it is definitely possible.

To answer your specific questions,

  • C # and DX 11 (SlimDX) can definitely do the job, I did it with DX 9 and hardware that was much less capable.
  • I would say if you were faced with a problem with the goal of generating a little garbage (GC produces graphic hiccups) And, taking a very data-oriented approach to animation (we called them templates), you will see the road I'm pointing to.
  • Yes, C # code has a workload, but you can reduce this cost by reducing the number of calls you make to DX and reducing the amount of data you pass into it.
  • See answer No. 2

Hope this helps!

+1
source

I would recommend working with the MS Expression Encoder SDK - a very, very easy to use, has a very useful code example.

If you insist on working with DirectShow, there is a DirectShow port for .NET that works very well. Here is a tutorial showing how to work with it.

+1
source

Source: https://habr.com/ru/post/1389809/


All Articles