Fading a video clip to black - c#

I have a requirement to play a video file in C# (with audio) then to be able to fade out the video to a black screen then fade in another video.
I've looked at DirectShow & DirectShowNet however I'm none the wiser. I've got a simple app to play a video with a time counter etc, however I'm flummoxed with filters & graphs.
What direction do I need to go in?

Create a WPF Apllication and use the MediaElement Control to play the videos. Use the events of the MediaElement (for example MediaEnded) to detect when to start fadeout / switch streaming source / fadein. The easiest way for the fadeout is to change opacity of the Mediaelement.
The MediaElement should be able to play all videos which have a directshow filter installed on your system.

Are you using WPF?
With WPF you could do this in a variety of ways. eg you could simply animate the video control's (MediaElement) opacity.
NOTE: you can use WPF controls inside of a Winforms app. See this video for how to do this.

One solution, although I would consider it a hack, would be to draw a black overlay ontop of the viewable area of the video. You can adjust the transparency of the overlay based on the frame/time of the video. Essentially, you would fire off a timed event that would slowly remove or add transparency to the overlay based on where in the video you want to starting fading.

Related

Image with transparency over video

Im using C# in VS2017 and have a Vlc Control to play a video.
I want to overlap some part of the video with a PNG image with transparency. In VS2017, elements are transparent to their parent. So, to make the image be transparent to the video I have to set it as child of the video.
But if I do that, the image doesn't display at all. Video is always refreshing and overlapping the image (even if I do a constant BringToFront in the image).
So, I change the Parent of the image to the form. Now the image displays, but through it's transparency I see the form's background, not the video.
Target platform is Windows. Is there any solution for this?
I had this same problem with windows forms. I believe there is no simple solution where you can use another control (e.g a picturebox) and make it transparent such that you can see the video behind it.
One thing you can do is to create another form, set it as topMost, set it's MDiParent to the form containing the VLC control and set its FormBorderStyle to None. Then set it's background to be the image you want to overlay and set it's opacity property to say 50%. This should give you the effect you want but it is a bit of a work around.
If you can you should move to WPF as your UI technology which should solve this and allow you to overlay a picture box with a transparency that doesn't just show the background of the main form behind it and actually shows the video.
It's not very clear how you're using libvlc.
Do you have to blend the image with the control itself? Shouldn't you blend any given image with the video frames?
If so, try using --alphamask-mask filter:
--alphamask-mask=<string>
Transparency mask
Alpha blending transparency mask. Uses a png alpha channel.
If you're using libvlc.net you can do this by adding an option:
vlcContext.StartupOptions.AddOption(<options>);

How can I extract the duration of a GIF animation from a file in UWP

I found this article http://web.archive.org/web/20130820015012/http://madskristensen.net/post/Examine-animated-Gife28099s-in-C.aspx (very helpful).
Unfortunately, our favorite hobbled race horse, UWP, does not include the required APIs.
I am working on a slide show app and would like to allow the user to advance an image with a set timing, except if it is an animated GIF, then I want to show the full animation once...
So, where can I extract the duration of the complete GIF animation, using the UWP on board tools?

C# SharpDX Play Video with Alpha (Transparency)

I'm writing a program to show different pictures and videos on a form. I started with displaying images with transparency using GDI. Due to the fact that GDI doesn't support transparency, the loading and displaying was very very slow, so I moved over to SharpDX.
In the meantime I managed (with one of the samples from SharpDX) to display different images on my form with opacity, positioning and sizing the images.
The images are drawn with DrawBitmap of the RenderTarget class in the render loop.
Now I want to do the same with videos. My goal is to play videos (more than one at the same time) in my form and set the position, size and transparency of the different videos.
I'm new to SharpDX and information about graphic programming and the documentation and the samples of SharpDX are very rare. I found many samples for playing videos with SharpDX, but all for XAML and WIN8 or Store-Apps, but no samples of how to play video in normal C# programs. What I found is one video player with SharpDX, but I don't know how to change this sample to add transpareny, sizing and positioning of the video playing.
Can anyone give me some examples how to play videos with SharpDX in a form or picturebox/panel? It would be great if this would show the things from above.

Display a Control over video playing via Microsoft.DirectX.AudioVideoPlayback

I have a C# Windows Form application that plays local videos. I would like to overlay a small form with controls over the video while it is playing. The video is owned by a panel and I have tried to create another panel that contains controls like a button and textbox and tried to brind the whole panel forward and send the video back, but the video stays on top.
Any ideas?
You typically cannot place controls on top of video without having flickers and unwanted artifacts. This comes from the fact that video playback allocates specific video hardware resources to stream video and streaming takes place separately from the rest of UI. Applications such as players "mix" overlay images (including those which mimic controls) into video or otherwise display them through specialized APIs, those are not regular controls.
The easiest solution for you is to place controls side by side to the video, without putting one on top of the other.

How to add transparent control above video control like wpf label over mediaelement

I want to add a transparent label or textbox over video control when playing it flickers but in wpf i used label above mediaelement and it was perfect.
How can get the same behavior in c# winforms or native c++ or whatever you know?? i'm using vlc media player control
how the wpf do it? the way?
You will have to either:
A. Disable the hardware acceleration for video playback.
B. Use a library for directX and intercept the frames redrawing your content on top of the frame.
This library may help but it's been a couple of years since I played with video technology.
http://directshownet.sourceforge.net/

Categories