I'm building a C# application (Windows Forms and .NetFramework 4.8). I use the Accord.Net framework to record a video in .mp4 format on the computer. After recording, I am using the Windows Media Player control to play the video that was recorded.
string applicationFolder = Application.StartupPath;
if (File.Exists(applicationFolder + #"\temp\videoTemp.mp4"))
{
axWindowsMediaPlayer1.URL = applicationFolder + #"\temp\videoTemp.mp4";
}
I need to edit this video by adding a text at the bottom for a specific time. During recording I can add text using the command below before saving the frame in the .mp4 file:
using (Graphics g = Graphics.FromImage(currentFrame))
{
//g.DrawString("test"...);
}
I thought of doing the same with the video that is played by the Windows Media Player control. For that I looked for some event of the player where I can get a pointer to each new frame of the video playing, but no success.
When creating a Windows Media Player Graphics, the text is reproduced in the video, but only when the application is running, the saved video is not affected.
using (Graphics g = axWindowsMediaPlayer1.CreateGraphics())
{
//g.DrawString("test"...); //it's show only when application is running
}
The question: Does Windows Media Player have any feature where I can capture the current frame of the video being played? If not, is there any way to recover a video saved on the computer, edit it frame by frame and then save it by overwriting the old video using C#?
Sorry for my English. Thank you everyone.
Does Windows Media Player have any feature where I can capture the current frame of the video being played?
No, it's a player. And even if it did, it certainly can't write the result. Since it's a player and all.
If not, is there any way to recover a video saved on the computer, edit it frame by frame and then save it by overwriting the old video using C#?
I generally use ffmpeg for that, it's not terribly difficult and it has hardware acceleration both for decoding and recoding built-in.
Related
I am currently using VlcControl (2014.4.18.0) to play the video in old
VLC Media player using rtsp Url in c# code
VlcControl _videoControl;
String rtspUrl = networkUrl;
var media = new LocationMedia(rtspUrl);
media.AddOption("rtsp-tcp");
_videoControl.Play(media);
The issue here is, the video is not playing in default Video Track 1 but
it is playing in Video Track 2.
Is there any way to set the Video Track to 2?
Kindly let me know if any options available to set the video track and play.
There is a VideoTracksManagement object that allows you to change the Video track.
i am using vlc player in winforms. its working fine, but the problem is that its playing faster. i have videos recorded at 10fps. i think vlcControl is playing at 30fps, that's why video are playing faster. Referred this, but it didn't help. i couldn't find any function like set_play_back_speed function under vlcControl1.VideoI thought vlcControl would automatically figure out fps & play accordingly. if i open the same video from vlc media player installed on my windows pc, it plays at proper rate.
any clue how to fix this?
P.S: if i open any video recorded at 29.97fps, vlcControl in winforms is playing it at proper speed.
Well, there's no function to set FPS to video thru Vlc.DotNet and I am not sure are you using WinForms or WPF application, but best I can help is probably, if you would play with rate settings as in transpone video.
It's found at vlcControl1.rate (which is float value default is 1.00), if you have 30fps and only want 10fps well, you could try to set:
vlcControl1.rate = (int)(33 / 100);
Which then would decrease video and audio transpone to 10fps from 30fps (assuming 1.00 = 30fps).
I implemented a simple application to get video steam form a normal web camera , and show on a windows application using CAPTURE class.
The application works and i can see the video on the image box , but the frames in the video is flipped (my left side is shown in right side).
I tried with multiple cameras and the same problem remains.When i connect the same camera in other application such as skype, there is no flip problem.
Is it a normal behaviour in capture class?
How can solve this problem?
I followed this tutorial
Thanks in advance
You can use the Flip() method. Just ensure that the frame is not corrupted or null before calling it!
http://www.emgu.com/wiki/files/2.0.0.0/html/304d1f22-93fd-d920-1f4a-285c14594050.htm
is there a way to capture or to save the story board animation to media library in windows mobile? Currently i am working with an animation which changes the image for every second. How can i save this into a video format??
There is no mechanism to save any video content to Media Library.
Currently, using API, you can save pictures. Nothing else
Please see
http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.media.medialibrary_members.aspx
I want to build application which needs to be able to capture video from a web camera using C#. The captured video should be compressed using some codec (nothing special, anything available that saves space) and written to a file while capturing. A live preview of capture is not necessary.
The first question is: Which API is suitable for this and what would you recommend (I have seen DirectShow, Windows Media Foundation wrapper, etc. I am not sure which is would be best for managed environment and C#)?
I also need a video player in WPF which will play captured video. This player must be able to play captured video from an arbitrary position, pause and start/stop video.
Putting it all together, video is captured from a webcam in the background and at the same time the player plays that video being captured, but it can be paused, re-winded, stopped - something like a modern DVR.
The second question: Is it possible to create such a player using WPF MediaElement? (Confusion is about the file which is at the same time filled from the capture and played in the player)
A nice example of how to make all what you want: WebCam
I have used the AForge set of libraries to accept the videos frame by frame. I used the private void videoSourcePlayer1_NewFrame(object sender, ref Bitmap image) function to do this.
I've used VlcDotNet. It is very flexible and simple to use. It has a pretty active user base as well.
I've used it for displaying live video streams as well as recording to files.
You can try the DirectShow.net library.
I can recommend WPF's ffmediaelement. It's built on FFmpeg. So what can FFmpeg, can also ffmediaelement. It can capture video from both the webcam and the capture card. Unlike DirectShow, it's very simple.
Here's how to set up a video source:
Media.Source = new Uri("device://dshow/?video=Osprey-460e Video Device 1C");
... and parameters for it in MediaOpening event:
Media.OnMediaOpening(s, e) =>
{
e.Options.Input["framerate"] = "25";
e.Options.Input["video_size"] = "768x576";
e.Options.Input["pixel_format"] = "yuyv422";
};