video.takeSnapshot 0.9.0 ActiveX, how to specify file name?

All you've ever wanted to know about the ActiveX, Mozilla plugins, the web interface and various PHP extensions
corvusvideo
Blank Cone
Blank Cone
Posts: 29
Joined: 03 Mar 2008 16:14

video.takeSnapshot 0.9.0 ActiveX, how to specify file name?

Postby corvusvideo » 28 Apr 2008 16:05

I am playing with the ActiveX wrapper (0.9.0, but it seems the same under 0.8.6) and I can't get the video.takeSnapshot method to work. For one I can't figure out how to set the output filename (the method takes no arguments as exposed). So thinkig it would use the params set under the player, I called it anyway and, predictably, it crashed the machine entirely.

Anybody have an example of how to snap the current frame to a PNG or JPG using the ActiveX control?

Thanks....

thannoy
Big Cone-huna
Big Cone-huna
Posts: 601
Joined: 20 Mar 2008 09:44
VLC version: 0.9.8a & 1.0-git
Operating System: GNU/Linux Fedora10
Location: France
Contact:

Re: video.takeSnapshot 0.9.0 ActiveX, how to specify file name?

Postby thannoy » 28 Apr 2008 16:21

I have no example sorry, but just looking to ActiveX API I think video.takeSnapshot() returns the picture. But I don't know how to use it, nor how to avoid your crash.

Bellow is the extract of the API description related to this method, if it can help you or others to help you:

Code: Select all

[helpstring("take video snapshot and save it into picture object.")] HRESULT takeSnapshot([out, retval] IPictureDisp** picture);
Also, I am not sure this method is very official. API for mozilla plugin and ActiveX should be unified and described in the following link. takeSnapshot is not listed there: http://wiki.videolan.org/Documentation: ... deo_object

regards

corvusvideo
Blank Cone
Blank Cone
Posts: 29
Joined: 03 Mar 2008 16:14

Re: video.takeSnapshot 0.9.0 ActiveX, how to specify file name?

Postby corvusvideo » 28 Apr 2008 17:11

Thanks. I see now what it is supposed to do. It populates an OLE IPictureDisp which I can then put into a bitmap and save.

Unfortunately still crashes so I guess this is just a stub of a method that will be removed in the unified API.

That being said, anybody have any ideas on saving a still image from a video? Either through ActiveX or through the libvlc?

Thanks...

corvusvideo
Blank Cone
Blank Cone
Posts: 29
Joined: 03 Mar 2008 16:14

How to take snapshot of playing video in C#

Postby corvusvideo » 30 Apr 2008 16:53

Thought I would post what I came up with to get this to work in case someone else was looking to do the same thing.

On my form the VLC AtciveX control is named "axVLCPlugin21"

*** IMPORTANT *** must play videos with the ":no-overlay" option for this to work.....

Code: Select all

axVLCPlugin21.playlist.add(filePath," ",":no-overlay"); axVLCPlugin21.playlist.play();
Here is the code to take a snapshot.....

Code: Select all

axVLCPlugin21.playlist.togglePause(); System.Threading.Thread.Sleep(100); String tempPath = Path.GetTempPath(); string imgPath = tempPath + @"Captured.jpg"; Bitmap bmpScreenshot = new Bitmap(axVLCPlugin21.ClientRectangle.Width, axVLCPlugin21.ClientRectangle.Height); Graphics gfxScreenshot = Graphics.FromImage(bmpScreenshot); System.Drawing.Size imgSize = new System.Drawing.Size( axVLCPlugin21.ClientRectangle.Width, axVLCPlugin21.ClientRectangle.Height); Point ps = PointToScreen(new Point(axVLCPlugin21.Bounds.X, axVLCPlugin21.Bounds.Y)); gfxScreenshot.CopyFromScreen(ps.X, ps.Y, 0, 0, imgSize, CopyPixelOperation.SourceCopy); bmpScreenshot.Save(imgPath, System.Drawing.Imaging.ImageFormat.Jpeg); MessageBox.Show("Image saved : " + imgPath); axVLCPlugin21.playlist.togglePause();

pepaloji
New Cone
New Cone
Posts: 1
Joined: 23 Jul 2020 22:44

Re: video.takeSnapshot 0.9.0 ActiveX, how to specify file name?

Postby pepaloji » 23 Jul 2020 22:49

Thank you corvusvideo.

in VB works too.

Imports System.IO
...


AxVLCPlugin21.playlist.togglePause()
System.Threading.Thread.Sleep(100)
Dim tempPath As String = Path.GetTempPath()
Dim imgPath As String = tempPath + "Captured.jpg"
Dim bmpScreenshot As Bitmap = New Bitmap(AxVLCPlugin21.ClientRectangle.Width,
AxVLCPlugin21.ClientRectangle.Height)
Dim gfxScreenshot As Graphics = Graphics.FromImage(bmpScreenshot)
Dim imgSize As System.Drawing.Size = New System.Drawing.Size(
AxVLCPlugin21.ClientRectangle.Width,
AxVLCPlugin21.ClientRectangle.Height)
Dim ps As Point = PointToScreen(New Point(AxVLCPlugin21.Bounds.X, AxVLCPlugin21.Bounds.Y))

gfxScreenshot.CopyFromScreen(ps.X, ps.Y, 0, 0, imgSize, CopyPixelOperation.SourceCopy)
bmpScreenshot.Save(imgPath, System.Drawing.Imaging.ImageFormat.Jpeg)
MessageBox.Show("Image saved : " + imgPath)
AxVLCPlugin21.playlist.togglePause()

rexxitall
New Cone
New Cone
Posts: 1
Joined: 05 Jan 2023 13:55

Re: video.takeSnapshot 0.9.0 ActiveX, how to specify file name?

Postby rexxitall » 05 Jan 2023 14:22

Ive tryed also to specify a filename within VB6. The only thing that i could achive is that the sceenshot files will be stored in the folder where the running application points to. So if you want to specify at least the path for the snaphot bitmaps you can use the vb6 chdrive and chdir commands to point to the screenshot path. The files created will be BMP files with a "strange" name. so the only solution might be to set this up to a EMPTY temporary directory, make a screenshot, read that directory, rename the file and move it to its final destination. Somehow after dealing with the vlc COM object it looks like a "unwanted" child. It shows up a lot of propertys which are either poor documentated or simply does not wor. For example it has a backcolor property. I would love to set the media area initially to black but - no chance. On runtime you get xyz is not supported.

Anyhow it will look something like that:

Code: Select all

Function snapshot() As String Dim resp As Variant Dim PIC Dim STATE As Boolean On Error Resume Next Dim FOLDER As String Dim DRIVE As String Dim Filename As String Dim CDIR As String Dim CDRIVE As String CDIR = CurDir DRIVE = "d:" FOLDERNAME = "\snapshot" ChDrive DRIVE MkDir DRIVE & FOLDER ChDir DRIVE & FOLDER Kill DRIVE & FOLDER & "\*.*" 'empty the temp folder 'note: to get a image the playlist needs at least a few ms playing after loading the file... (150ms in my case) With Play.CUTTER 'the vlc object on the form STATE = .playlist.isPlaying .playlist.PAUSE Set PIC = Play.CUTTER.video.takeSnapshot() If STATE Then .playlist.Play DoEvents End With Filename = Dir(FOLDER) 'get the name of the bmp 'Do While filename > "" ' Debug.Print sFilename ' filename = Dir() 'Loop snapshot = Filename ChDir CurDir End Function


Return to “Web and scripting”

Who is online

Users browsing this forum: No registered users and 6 guests

cron