Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Tuesday, July 24, 2007 5:35:28 PM(UTC)
desrobe99

Groups: Registered
Posts: 2


Using the Multimedia SDK ver.14, I want to be able to take a DV avi (already saved to disk) and grab specific frames (like every Nth frame, or frames #12, 44, 199, 444, etc) and build up a new DV avi. My goal is to do this without intermediary files, ie. I don't want to have thousands of single image files saved to the hard drive before constructing the final ouput.

Does anyone know how I can do this?


Thanks
Dave
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Thursday, July 26, 2007 7:43:54 AM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 766


You should be able to use the ltmmPlayCtrl to seek to a specific frame, then call GetStillDIB which returns a pointer to a DIB in memory.  The toolkit should've come with a demo called Generate AVI which builds an AVI file from a bunch of bitmaps.  You should be able to implement the logic from that demo to accept the DIBs and then create an AVI file.
 
#3 Posted : Monday, September 10, 2007 5:45:11 PM(UTC)
desrobe99

Groups: Registered
Posts: 2


Ok, I'm completely lost. I have looked through the sample, and the documentation, but I don't know where to go from here.

The sample has the following:

Set smpsrc = New ltmmSampleSource


' create a new media type wrapper
Set mt = New ltmmMediaType

' set the type to 24-bit RGB video
mt.Type = "{73646976-0000-0010-8000-00AA00389B71}" ' MEDIATYPE_Video
mt.subtype = "{e436eb7d-524f-11ce-9f53-0020af0ba770}" ' MEDIASUBTYPE_RGB24

' setup the video info header
vih.bmiHeader.biCompression = 0 ' BI_RGB
vih.bmiHeader.biBitCount = 24
vih.bmiHeader.biSize = 40
vih.bmiHeader.biWidth = pictCounter.ScaleX(pictCounter.ScaleWidth, pictCounter.ScaleMode, vbPixels)
vih.bmiHeader.biHeight = pictCounter.ScaleY(pictCounter.ScaleHeight, pictCounter.ScaleMode, vbPixels)
vih.bmiHeader.biPlanes = 1
vih.bmiHeader.biSizeImage = (((vih.bmiHeader.biWidth * 3) + 3) And &HFFFFFFFC) * vih.bmiHeader.biHeight
vih.bmiHeader.biClrImportant = 0
vih.AvgTimePerFrame.lowpart = (10000000# / 15#)
vih.dwBitRate = vih.bmiHeader.biSizeImage * 8 * 15

' set the format
mt.formattype = "{05589f80-c356-11ce-bf01-00aa0055595a}" ' FORMAT_VideoInfo
LSet viha = vih
mt.SetFormatData 88, viha.buffer


' set fixed size samples matching the bitmap size
mt.SampleSize = vih.bmiHeader.biSizeImage
mt.FixedSizeSamples = True


' assign the source media type
smpsrc.SetMediaType mt


' select the LEAD compressor
ltmmConvert.VideoCompressors.Selection = ltmmConvert.VideoCompressors.Find("@device:sw:{33D9A760-90C8-11D0-BD43-00A0C911CE86}\LEAD MCMP/MJPEG Codec")
' assign the converter source
ltmmConvert.SourceObject = smpsrc
' set the output file name
ltmmConvert.TargetFile = txtFile.Text



' need a buffer to hold the bitmap bits
ReDim buf(vih.bmiHeader.biSizeImage)

On Error GoTo ConvertError
ltmmConvert.StartConvert
For i = 1 To frames
    DrawCenteredText CStr(i)
    pictCounter.Refresh
    GetDIBits pictCounter.hDC, pictCounter.Image, 0, vih.bmiHeader.biHeight, buf(0), vih.bmiHeader, 0
    Set ms = smpsrc.GetSampleBuffer(1000)
    ms.SyncPoint = True
    ms.SetData vih.bmiHeader.biSizeImage, buf
    ms.SetTime 0, frames - 1, 0, frames
    smpsrc.DeliverSample 1000, ms
    ' critical that we release the sample buffer so that we can get another
    Set ms = Nothing
Next
smpsrc.DeliverEndOfStream 1000
Exit Sub



What parts of this do I need to implement? I want to get the source from a single frame from an LTMMPlay control. I already am able to seek to the frame that I want, and I can call GetStillDIB, but it returns a pointer to something, but I'm not sure what. What do I do with that pointer??

Kind regards,
Dave




 
#4 Posted : Tuesday, September 11, 2007 7:12:09 AM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 766


While this function is complicated, the main thing you need to worry about is the use of the ltmmMediaSample (ms) and the ltmmSampleSource (smpsrc).  You are getting a new sample and setting it to ms with GetSampleBuffer, then setting the data with SetData, the finally delivering the sample.  Basically, you just need to get the bitmap data from the HDIB returned from GetStillDIB into a buffer and use that in the ms.SetData function.  LEADTOOLS provides the DIB and the functions possible for setting the data for a sample.  What you do with the DIB and what data you give to a sample is going to be general Windows programming and out of LEADTOOLS' court.

The difficulty with this particular project is VB.  GetStillDIB returns a handle to a DIB, but VB doesn't do pointers.  In C++ this probably wouldn't be too hard because you should be able to just use -> to access properties of the DIB and copy the data into a buffer.

It might be possible to write a simple C++ dll that takes a HDIB and returns a BITMAPINFOHEADER or just the data buffer.

Another workaround could be to use our Raster Imaging Pro toolkit's COM libraries.  You could create a LEADRaster object using the SetDIB function which creates a LEADRaster object from an HDIB.  Then you could use the LEADRaster.GetClientDC method to get a DC you can use with the GetDIBits function.  This wouldn't be as efficient as using Windows functions to get the data from the HDIB, but I'm pretty sure it would work if you have the Raster Pro sdk available.
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2020, Yet Another Forum.NET
This page was generated in 0.163 seconds.