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).
Related
I'm seeing a memory leak (10M each time) when I play->stop->play->stop a local mp4 file using both libvlcsharp and the officially released VLC media player(3.0.16) when video filter is applied.
Since I'm having multiple(around 10) VideoView displayed simultaneously in my program, OOM error occurs in like 20 play&stop operations.
I'm using c# and I've tried GC.Collect() in my program, it didn't work.
Anything I can do about this?
FYI: The video filter I've tried: ripple, sharpen, wave. And both libvlcsharp and VLC media player works fine without video filter.
Edit 1:
The vout is dx3d11 and the I'm using VLC media player on windows10.
I'm making a Windows Form application that is supposed to play an animated gif while playing music.
I used SoundPlayer, and everything worked flawlessly. Then I found out I can't play multiple audio files with SoundPlayer, which was a problem (Background music AND effects needed).
So I looked a little bit into DirectSound, but my application froze everytime I did anything DirectSound related (Device, Buffer...).
So now I'm trying out WMP, I was happy at first, but when I enabled a GIF (Transparent, in case it matters), the music stopped in less than a second while you could see the GIF to stop for a frame or so, like it's loading something heavy. And this happens every time that audio and GIF are playing at the same time, no matter if one of them started in advance. When I used SoundPlayer, I could play 20 animated GIFs at once with no effect on audio.
To sum it up:
SoundPlayer = Only one audio file, unacceptable
DirectSound = Freezes for some reason (Maybe worth trying again? I'd like to put focus of this question on WMP though, I lost the code anyway)
WMP = Won't play along nicely with animated GIFs, which are required.
I tried playing both .wav and .mp3 file, no difference.
I added the wmp.dll reference before.
using System;
using System.Windows.Forms;
using System.Media;
private void button2_Click(object sender, EventArgs e)
{
var player = new WMPLib.WindowsMediaPlayer();
player.URL = "song.wav";
pictureBox1.Visible = true;
}
Is there something I should know about WMP? Can you recommend some other method? It does seem that the audio stops when the pocess reaches certain memory usage. It's steady on about 45 MB, but once I play the audio file it starts increasing, and plays until it reaches about 48 MB when it stops and returns to 45 MB.
Thanks for taking your time and helping me in any way.
EDIT: I was using a GIF picture with resolution of 500x500 which I used SizeMode=StretchImage on to actually make it appear smaller (200x200). In this case, the music played for about 0.2 seconds. I resized the resource picture to 100x100, using StretchImage to make it appear as 200x200 again, and the music played for about 8 seconds, about 4 seconds if I loaded two GIFs at once. Changing the .mp3 bitrate to make it just 170KB didn't help at all. I mean my Google Chrome takes 3GB of my memory and still plays multiple videos just fine, while my Form is taking not even 50MB and struggles. Surely there must be a way to play GIF and a song. Is there some kind of MemoryAssignLimit property? Or does WMP simply fail when it comes to bigger resources? Is it a limitation set by WinForms?
Followed this solution, and it worked like charm, GIFs everywhere and 30 overlapping songs, and nothing stops unless I want it to. Great.
I'm building a Windows Forms application in VS 2010 that smoothly increases or decreases the speed of a video playing back based on the speed of the user input.
I've tried several avenues..
1.) Using the AudioVideoPlayback DirectX class - I set the speed of the video, by setting the current position of the video, based on a timer.. and increased or decreased that value based on user input. While this worked on my PC, it lags a lot on our lower end target PC's. Can anyone think of a more efficient way to increase/decrease the speed of playback using this class?
2.) I've tried the Windows Media Player ActiveX control, and tried setting the rate/position dynamically, but this is extremely jumpy and laggy even on my development PC
3.) I've tried the Apple QuickTime Control 2.0 COM Component that comes with VS 2010, and it's also very laggy.
4.) I'm trying to figure out how to set the speed on the Shockwave Flash Object control, but haven't found that out yet
Can anyone suggest other avenues to explore? I just need to be able to increase/decrease the speed of video playback smoothly based on user input without lag. I don't care what format the video needs to be in, all videos can be converted to the required format.
Any help/ideas will be appreciated.
Thanks
The ultimate way is to decode the Bitmaps from videos, and handle the frames yourself.
Try the CaptureNET example from DirectShow.NET. It allows you to capture bitmaps from each frame. After that, write your own playback control to handle the refresh rate.
After trying many different formats/libraries and components I found the VLC Media Player ActiveX control to be the most efficient method to slow down/speed up video without any noticeable lag.
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";
};
I currently have a windows media player embedded into my winform on c# and i am now trying to make a button to control the speed of the video play. I currently can use controls to play, pasue and stop, found in ctlcontrols but can't find a way to change the speed of video play through using a button on my form?
An example of my code for pausing the video in it is:
axWindowsMediaPlayer1.Ctlcontrols.pause();
But i need some code to change the play speed so any help would be much appreciated.
Thanks
Settings.Rate is what you are looking for: speed is a double, 1.0 being normal speed.
axWindowsMediaPlayer1.settings.rate = speed;
For rewinding:
if (axWindowsMediaPlayer1.controls.isAvailable('FastReverse'))
axWindowsMediaPlayer1.controls.fastReverse();
For a full scripting reference check the documentation.