News Marquee over analog TV stream - C# - c#

I want to put a news marquee over an analog TV stream using c#, I can stream analog TV using DirectShow but I can't figure out how to mix it with rotating text, should I create a filter? or I have to use another technology than DirectShow?

DirectShow is the simplest way of doing this but it does have a bit of a learning curve, particularly coming from C#. The Wikipedia page gives you a basic overview of DirectShow.
DirectShow tools are available in the latest Windows SDK. Using C++ for DirectShow programming is more straightforward but you can use DirectShow fairly easily via COM interop or DirectShow.net (which I haven't tried yet). If using COM interop the following article is helpful:
http://blogs.msdn.com/b/ericgu/archive/2004/09/20/232027.aspx
You may be able to use the VMR overlay filter if the animation performance is smooth enough. See the following articles
http://www.codeproject.com/KB/audio-video/VideoPicture.aspx
http://www.codeproject.com/KB/audio-video/Ticker.aspx
http://msdn.microsoft.com/en-us/library/dd407344(v=vs.85).aspx
Alternatively you will need to write your own filter that renders the text on each frame adjusting its position in synch with the time stamps of the video frames. If you only need to do this inside your own application then the following approach might be easiest
http://www.sichbo.ca/Free_Code/100_C_Sharp_directshow_filters
Microsoft officially recommend that DirectShow filters should be created in C++ for performance reasons but overlaying scrolling text should be OK in C# as the bottleneck will be the APIs used to overlay the text if you program carefully.

Actually you don't have to write a filter to draw some text over your video. Just make a graph where uncompressed video goes through sample grabber (one of standard DirectShow filters), set up a callback for the sample grabber and you'll be able to modify the video data in your callback. Doing it in C# is very easy using DirectShow.NET but not optimal due to marshalling. You can first build such a graph in GraphEditPlus, then it will show you source code in C# or C++ of how to build this graph and use sample grabber.

Related

Writing a Simple Video Viewer/Frame Grabber in C# for a USB Camera

I'm a complete beginner in C#, but I'm trying to write a very simple application in C# (VS2013) to simply view video stream or capture frames from a Sony FCB-EV7500 camera. The camera connects to a small USB3 board using CN401, and the board connects to the laptop via USB3. I can view video in VLC for example, but i'd like to write code in a C# application to get video/grab frames.
Google searching this brought me to DirectShow which apparently is only a C++ library. There used to be a DirectShow.NET wrapper available here: http://directshownet.sourceforge.net/about.html but it seems they haven't updated the project since 2010 and a lot of functions/interfaces at that time remained untested.
Are there any commonly used libraries for accomplishing this in C#? Perhaps something included in the .NET framework? Thanks for any advice or direction.
You really don't want to be marshaling full frame rate video into a C# application.
You should probably take a look at the .net bindings for gstreamer, I have personally only used the C and python bindings so YMMV. If that doesn't work you will need to:
Use direct show, gstreamer, or ffmpeg to deal with media.
Write a native wrapper around your media handling code.
Write C# code to interop with your wrapper.
depending on if you are using winforms or wpf you will either use a NativeWindow or D3DImageSource as your render target.

How to learn DirectShow Encoder/decoder programming?

I have created a project using directShow that takes the captured video from a webcam and preview it.
Now I want to encode on run time video captured alive and save it on desk then play it back I want to use it as part from my code(dll for example) not a standalone part.
Any links can help me to get how to do that please I am in search process for a week and feel not understood with the methodology?
If you're writting new app, or you're interested in learn about video processing you should consider using Microsoft Media Foundation.
DirectShow is an 'obsolete' and shortly will be discontinued technology.
If despite this, you're still interested in DirectShow, you could start with MSDN DirectShow Documentation (Examples are in C++ but the idea is the same).
As short summary you must understand this concepts.
What is a DirectShow Filter, and wich types exists (Source,Transform,Renderers and Capture).Introduction to DirectShow
How can I connect multiple Filters in a Graph,how filters are connected between them, and how I can control the playback. Start with Building the Filter Graph.
Some utils that can help you:
DirectShow Graph Spy DLL Allows to watch Graphs created by others app
Monogram Graph Studio Improved version of Microsoft Graph Edit.
NOTE: As you tagged this post with 'C#' and 'Directshow.NET' tags, I will consider that you're using DirectShow.NET library (the unofficial port of DirectShow to .NET).

How to control HD video play position and speed in XNA?

I am developing a game for Windows in C# using Visual Studio 2010 and XNA 4.0. I would like to be able to set and change the play position of an HD video and also play the video in reverse, depending on user input.
I am having trouble finding where to start. XNA's videoPlayer class does not provide these type of functions. I've read that XNA DirectShow is now out of date and slow when using HD video.
I don't quite understand how I would be able to use or implement tools such as ffmpeg with my project. It seems some people have had similar questions and posted solutions but without much detail. These are below.
interop out to talk to the core DX functionality.
write a managed c++ wrapper to interop ffmpeg.
write an mpeg decoder.
I am not sure what would be best and where to begin.
Thanks!
The VideoPlayer class has a "PlayPosition" property, which you should be able to play with.
Otherwise (and I don't know how big your video file is nor how long) try an image sequence and animate the current image sequence and control that with user input. Of course working with image sequences would make audio reversal (if there is audio) etc very complicated.
Last but not least, you can see if you can figure anything out from this mpeg decoder here:
https://www.box.com/shared/ojzfv0qzfx
Something else that might help with mpeg decoding:
http://chrisa.wordpress.com/2007/11/21/decoding-mpeg2-information/

Get image from webcam

I'm trying to find the way for getting image (only image, not video stream) from webcam in managed C#.
Usually people suggesting libraries, but they are old or commercial or under gpl.
How get image from webcam without third-party libraries?
upd.: thanks for Media Foundation, I shall use that.
Web cameras are supposed to deliver video feeds, not stills. So the native API you might be interested in is the one for video capture, which are DirectShow and Media Foundation.
The one you would most likely want is DirectShow, but it is not well suited to be interfaced from managed code, so you will need a DirectShow.NET which is open source wrapper. You typically start video streaming there and once you have a good image you stop the activity.
Or instead you might keep looking for a ready to use library which does the mentioned above for you.
One of DirectShow.NET samples does what you look for.
DxSnap – Use DirectShow to take snapshots from the Still pin of a
capture device. Note the MS encourages you to use WIA for this, but if
you want to do in with DirectShow and C#, here's how.
It mentions WIA, however WIA API is not available for all (or any in recent OSes?) web cameras, WIA more targets device like scanners.
Other APIs are perhaps less suitable.
VFW ("avicap32.dll") limits you to a subset of devices, is simple yet not well interfaced into managed code
Media Foundation is not well available in earlier OS versions
I wrote this many years ago
http://www.vbforums.com/showthread.php?344471-Vb.Net-WebCam-Class-(ICam)) in VB.net
You could easily port it to c#?
Is avicap32.dll out of the question?
Otherwise I think this is a simple and straightforward way:
http://www.creativecodedesign.com/node/66
http://www.c-sharpcorner.com/uploadfile/yougerthen/integrate-the-web-webcam-functionality-using-C-Sharp-net-and-com-part-viii/

.NET Options Stream Video Files as WebCam Image

I am interested in developing an application that will allow me to build a list of videos from xml (containing video title, duration, etc) and play that list as my webcam stream. Meaning, if I were to visit ustream.tv, or activate my webcam on live messenger my video playlist would register as my active webcam.
Does anybody have experience in this area, and perhaps have some advice to offer?
If you want this to work so that third party apps see your video as a standard webcam stream (and is sounds very much like you do) then the only way to do it is to write a virtual webcam driver. You will then then be able to "play" your video content as your webcam's streaming output. This will involve writing code to decode the video content - probably using DirectShow - and then copying the raw video stream to the webcam's output stream. You'll need to either write a custom DirectShow renderer filter or use the sample grabber to access the raw, decoded frames.
It's certainly an achievable goal, but not particularly easy given that both DirectShow and driver development have fairly steep learning curves. There are a variety of different driver models you could use for this, depending on exactly what your aims are. The easiest thing would be to create a Video for Windows (VfW) virtual camera driver. The huge benefit of this approach is that the driver will be entirely user mode code - much easier to debug and to write in general.
I don't have a lot of experience in this area, but I would start by looking at the MSDN docs for the DirectShow API.
A couple of .NET wrapper libraries exist as well:
Managed DirectShow
DirectShow.NET
Another DirectShow.NET

Categories