c# Text over video - c#

I've spent days googling and coding tryin to acheive the basic level of effect all media players have when showing fancy subtitles - that being text (optionally with outline/dropshadow/glow) written above a video (video being a videofile but would nice to also have option of being a videofeed eg webcam).
So far the only way I've managed to get anything over a video is either to write to a transparent picturebox above a video component which is aliased so has dodgy outline, or using the directshow.net library and the capture method from the dxtext example I have managed to actually write over a picturebox that is being spat frames of the video. The problem here is that as soona s I add the writing commands in (video plays to picturebox fine without it) then I get slight fps hit coming accross as marginal stuttering on the video.
Does noone have a way to just write/draw over a video without taking this kind of performance hit? Or am I going to have to resort to directx or something or just give up on this luxury? :/ I can paste any code needed for help but I think anyone with assistance will probably be the one wanting to post code!
TIA for any input, it's doing my head in D:

Related

Taking pictures and recording multimedia files from WPF-application

we are in need of a way to record videos with sound and taking pictures inside a WPF-application. It should be able to save locally to disk. Preferably it should be able to show the content once it is saved as well, but if no such component exists, we will use another component for the playback.
I've looked around and found no real good options to do this. Some options lack the sound recording in videos, and some are just too old to get working properly (WPF has had a long run so far...)
Does anyone here has any experience in this specific area?
Got Taking Pictures and Videos working with this little documentation https://www.codeproject.com/Articles/330177/Yet-another-Web-Camera-control
If you dont tell us what problems exactly you got, or which code you already got, we can't really help.

Extract Frames of Video at Runtime

I can find plenty of methods for extracting all frames of a video when it is not playing. However what I want to achieve is extracting frames at runtime while the video plays. I want to be able to scan the video for qrcodes at runtime, but my blocker is extracting the frames while the video plays.
My platform for building this in is Windows and C#.
Looking for any library or strategy to achieve this. The best idea I have so far is have the video playing and extract and scan frames for each N second that the player progress hits. But there must be something better than that.
Maybe this tutorial made by Microsoft can help you a little bit.
https://msdn.microsoft.com/en-us/windows/uwp/audio-video-camera/get-a-preview-frame
Hope that my answer was helpful for you! :)

Why AxShockwaveFlash take so much memory or process while transitions?

I have developed an application with 2 AxShockwaveFlash and textBlock.In AxShockwaveFlash there is 2 different flash files with their own animation and in the bottom of the form a textblock scroll some text(Ticker).While loading of flash my ticker get stuck and when the flash has some transition then also my ticker get stuck.
I am not getting any clue why my application responds slow while playing or transitioning a flash file.How can I track exactly the problem is?
The simple answer to : Why AxShockwaveFlash take so much memory or process while transitions? is simply because that Someone out there doesn't know how to code a transition without killing the CPU.
To be fair your question didnt give enough helpful info (which led to the rambling answer below). Many people will call something "a Flash animation" when that something is anything from simple text fading in/out.. to a full blown 3D engine game demo to.. some intensive realtime video pixel effects. Just happens to be done in Flash so it's a Flash animation, right?.
A) If you can improve the C# code... Look into improving your WPF/Textblock code
Because if your Textblock is getting slowed down by the additional loading of some multimedia elements (photo, sound, Flash etc) then you simply have to improve that Textblock code.
Is this slow WPF TextBlock performance expected?
http://social.msdn.microsoft.com/Forums/vstudio/en-US/378a1945-8f72-4641-a0b8-e8ba5a31eced/is-the-wpf-textbox-really-that-slow?forum=wpf
http://www.codeguru.com/csharp/.net/net_wpf/article.php/c18025/10-Ways-to-Improve-the-Performance-of-Your-WPF-Application.htm
B) If you can improve the AS3 code... Look for any CPU intense pixel activity. Use bitmapData.lock and .unlock if the transitions code uses bitmapData.
If the Flash is externally created by someone else then perhaps there is some ineffecient coding? Check CPU usage by loading just the SWF's (no Textblock). Also consider the nature of your Flash animations for example I've never known SWF's of advert banners & pop-up ads to NOT add CPU usage. I dont know what those people do with their "simple" adverts. Essentially if someone else made it, find an alternative. Else if you have the source code, improve upon the transitions function first amongst others.

Reading specific frames from video file with .NET (not necessarily in sequential order)

I have a .NET Winform application and i need to show specific frames of a video file. Frames aren't necessarily in sequential order and are loaded when the user moves a slider, or when the application fires some events. I tried the following things:
Using EmguCV (OpenCV Wrapper): The problem here is that when i use SetCaptureProperty (With CAP_PROP.CV_CAP_PROP_POS_FRAMES, AVI_RATIO or MSEC ) to sets capture's position, the position isn't seted correctly (I checked it using GetCaptureProperty next to the SetCaptureProperty instruction). So, the frame returned by QueryFrame isn't the needed frame.
Using WPF MediaElement with Clock driven behavior: I can set the position of the video at the place that i need. The problem is that i don't know how get only one frame of the video sequence. By default, i have the Clock controller paused. When I set the position, If I call Clock.Controller.Resume(), then the video start playing from here. If I don't call Clock.Controller.Resume(), or if i call Clock.Controller.Resume() and then Clock.Controller.Pause() nothing is happening.
Im looking for another video library that can be used for accomplish this work, but i am not sure about what could be used. Any idea?
Thanks a lot for all comunity members, not only for help with this answer, but for the very big help that you give me with my problems every day. Iam new, but i would try to return these helping others with your problems.
Sorry for my terrible english! (Im spanish speaker and english speaking is not my best quality :S)

DirectShow EVR resizing window problem

So I've been looking into the world of media playback for windows and I've started making a C# Media Player using DirectShow. I started off using the VRM-7 windowed video renderer and it was brilliant except it had a couple of small problems (multi monitors, fullscreen). But after some research I found that it's deprecated and I should be using VRM9.
So I changed it to use VRM9 windowless then found out that was an old post rofl >_< so finally I'm using Vista/Win7 (or XP .net 3) Enhanced Video Renderer (EVR) which is apparently the most up to date Microsoft video renderer and has all the flashy performance/quality things added to it. (tbh I haven't noticed any difference but maybe I need a blue-ray or HQ video to notice it).
With using EVR everything is working fine except resizing the video. Its really laggy/choppy/teary and probably something to do with its frame queueing mechanism.
To demonstrate my problem
open up windows media player classic.
View -> Options -> Playback -> output
Chose the "EVR" DirectShow Video renderer
Now restart wmp class and play a video, while it's playing click and drag a corner to resize it. You'll notice its horribly laggy. This is the exact same problem i am having.
But if you chose "EVR Custom Pres. **" or EVR Sync **" resizing works beautifully! So i tried googling around for anything about EVR resizing issues and how to fix it but i couldn't believe how little i could find. I'm guessing "Custom Pres." stands for "Custom Presenter" which sounds like they made their own.
Also you'll notice on the right hand size when you swap between EVR and the other EVR's the Resizer drop down on the right greys out.
So basically I wan't to know how I can fix this retarded resizing problem and is there any decent documentation out there? There is a fair bit for VMR7/9 but not much for EVR. I downloaded the DirectX SDK which apparently has samples but it was a waste of 500mb of bandwidth as it had nothing relevant.
Perhaps there is some way to force it not queueing up frames if that is the problem?
If you want code say the word and I'll paste some in. But it's really quite simple and nothing much happens, i'm convinced it's a problem with the EVR renderer.
EDIT: Oh and one other thing, what does VLC use? If you go into vlc options and change the renderer to anything but default, they all suck. So is it using VMR7? Or its own?
I need to write my own Custom Presenter, which from the looks of http://msdn.microsoft.com/en-us/library/bb530107(VS.85).aspx is a relatively big task.
Guess i'll look at the sample and try to go from there

Categories