How to programmatically control VLC seek in milliseconds? - c#

I'm writing an app in C# that's controlling two VLC instances via VLC's remote control interface. I need to be able to control the position in the stream of each instance as much as possible. The RC seek command only gives control in seconds so any fraction of a second is impossible.
Does anyone have a recommendation that will allow me to control seek to milliseconds in C#? I've looked at C# wrappers but none are maintained for the current version of VLC. I'd like to continue to use the RC interface for simplicity if possible.

Related

How to forward output of a directshow app(C++) to a C# app?

I am making a C# app to capture graphic from an avermedia pcie capture card.
But it seems that there are no out of box tools to do so.
So I made a C++ directshow app to do the capture, which is a console app and opens a capture window when running.
How can I redirect the output to a C# app? for example, to a CaptureElement?
So you want to have XAML CaptureElement connected to AverMedia PCIe capture card. This sounds like a well-understood challenge overall, however every other piece of technology you mentioned is eventually a bad choice: DirectShow, multiple apps with piping, redirection and fitting of cutsom code to XAML CaptureElement control.
Microsoft has intentionally been limited ways you can integrate different APIs and so there are not so many ways to get everything together.
Let us go over the supposed integration path. The capture card is supposed to be shipped with a compatible driver:
Video capture devices are supported through the UVC class driver and must be compatible with UVC 1.1
When this is the case, such devices are visible to Media Foundation API handling video capture among tasks. XAML CaptureElement would be able to see a video capture device through this API and this way everything is supposed to work without need to fit anything from your end.
If this is not happening, it suggests you are dealing with an unsupported device coming without suitable or compatible driver.
Previous media API in Windows was DirectShow but its days are gone. It remains perfectly working as a legacy framework, a lot of applications out there are still relying on it. Specifically it will not integrate with new technology like XAML and UWP. More to that, even Media Foundation itself, the current media API, in its public offering is lagging behind when it comes to fitting with most recent technology. Having said that it is a good idea to stay well clear of DirectShow here if this is at all possible.
I see no need for cross-process design with video travelling between process through piping. There is no good reason for such design and even though this can work efficiently (Windows itself proves it can work great in terms of performance by having so called Frame Server service in it), this is not to be built on piping. In your case it is unlikely to be have to be built on multiple processes either. Instead you can develop a native code DLL project that takes care of video acquisition and connects to managed code via suitable glue layer: C++/CLI, COM, C++/WinRT and such.
Then next thing is fitting to XAML CaptureElement. The control is designed to work with Windows.Media.Capture.MediaCapture class that talks to hardware and you don't have suitable hardware as you plan to implement your own acquisition layer. Long story short you are not supposed to forward external data to CaptureElement and you would have hard time doing this. Your best strategy is to upload externally obtained data to Windows.Graphics.Imaging.SoftwareBitmap or alike and take involved performance impact as acceptable. That is, you will be dealing with video frames as images.
An alternative way is to upload acquired video frames into Direct 3D 11 textures and it would open you a more performant way of integration with video related controls, such as Windows.UI.Xaml.Controls.SwapChainPanel however it would also require that you put much more development effort in there.

Which one to use: DirectX? Windows Media Player? GNU? Others?

I want to create a windows Forms program where I play an AVI file.
I want to be able to play it in full speed, to pause, to get the total number of frames, and to show a given frame (seek).
The AVI file has metadata for the file AND metadata per frame.
I want to do this in a windows Forms application in C#, or if it is really necessary using C++.
Internet search shows me a lot of possibilities to use: DirectX, DirectShow, Windows Media Player, Microsoft DirectX9, GNU code, and several other methods.
Alas I haven't seen one that supports all that I want, especially the metadata per frame is not used often.
It seems that several of these methods are obsolete, for instance to be able to use Microsoft DirectX I need to add "useLegacyV2RuntimeActivationPolicy".
So anyone who knows what method is the latest and greatest method to use in windows programming? Which method allows me to show metadate-per-frame?

Playing part of a sound (WMA) file in C#

I have a single WMA file which contains lots of different pieces of audio.
Is there any way I can play part of a sound stream?
Something like:
public static void Play(Stream soundStream, long start, long end);
You may be able to do this using NAudio, it is a audio library for .Net.
Using the example here I was able to throw a quick test application up to try it. Using the WaveSteam.Skip(int seconds) method you are able to start at a specific position in the file. I have not been able to work out how to get the end position though. Below is the modified sample that starts a wma file at the 30 second mark:
IWavePlayer waveOutDevice = new WaveOut();
WaveStream mainOutputStream;
WaveChannel32 volumeStream;
WaveStream wmaReader = new WMAFileReader(#"F:\My Music\The Prodigy\Music for the Jilted Generation\01 Intro.wma");
volumeStream = new WaveChannel32(wmaReader);
mainOutputStream = volumeStream;
mainOutputStream.Skip(30); //start 30 seconds into the file
waveOutDevice.Init(mainOutputStream);
waveOutDevice.Play();
The above sample omits the cleanup code to stop playback and dispose of the streams however. Hope that helps a bit.
Not in the way you want, no.
I assume this is within a WinForms or WPF context. The solution is to host the WMP ActiveX control in your project, then load the WMA file into it and set the Position/Seek property and then play it for a while and stop it when the Timer reaches a certain point. I don't believe the WMP ActiveX control has a timer event, so you'd need to watch it on another thread and stop the playback when it's reached.
It's a hack, but should work. You should be able to get something that "works" within a few hours if you're familiar with hosting ActiveX controls within .NET applications. Note that you'll want to make your application x86-only because of compatibility issues with the 64-bit WMP ActiveX control.
The, much harder, alternative is to work with DirectShow from within your application and create a Render Graph for WMA files and do the manipulation, seeking and playback yourself. DS has a very steep learning curve, expect this to take you at least a few days to even a few weeks if you've never worked with COM before.

Triggering windows explorer's "rotate clockwise" operation within a C# application

I need to rotate an image clockwise only just once after a certain operation. I felt so lazy to include rotating logic to my current image operations class then I come with this idea. What I need is already built within windows explorer, so is it possible to trigger windows explorer's rotate operations within a c# application for a valid file specified?
I have doubts that I can't access to that kind of functionality but I wanted to ask to make sure.
Thanks!
You're better off not relying on the feature since it is not part of the API and can disappear at any time. You should just do your own image rotation.
I don't think its possible to do it with Windows Explorer's integrated photo rotating, but you should check out the awesome image editing/processing library called ImageMagick. The original API is a native windows (dll) API, but there is a good .NET wrapper that is easy to use.
Here it is:
http://imagemagick.codeplex.com/
There are also wrappers for two dozen or so other languages, linked at ImageMagick's site:
http://www.imagemagick.org/

how to control media player using script or code

Is there a media player, where you can control its audio and video using script or code.for example lets say i want to pause the video after n secs, which player supports this? I am looking for free opensource solution which runs on desktop i.e windows 7.
I'm not the kind of giving the entire solution. But here's a good place to start. It shows how to embed Windows Media Player in a Windows Form.
http://msdn.microsoft.com/en-us/library/bb383953(v=vs.90).aspx
You'll have access to control like play, stop, etc.
VideoLan supports such use.
For instance, see here: http://www.videolan.org/doc/play-howto/en/ch04.html
From the link:
--extraintf allows you to select extra interface modules that will be launched in addition to the main one. This is mainly useful for special control interfaces, like HTTP, RC (Remote Control), ... (see below)
The RC interface is probably best from a pure code/script point-of-view.
The HTTP interface is oriented towards a human using a webpage, but could be controlled from code, too.

Categories

Resources