all groups > dotnet interop > march 2005 >
You're in the

dotnet interop

group:

how to consolidate a video from jpg's or bmp's with WMEncoder SDK 9


how to consolidate a video from jpg's or bmp's with WMEncoder SDK 9 Olivier Carrier via .NET 247
3/29/2005 11:24:59 PM
dotnet interop: Hello Ying-Shen,

I have been reading your postings for the past week in several=
websites and you seem to be the only person who might have the=
solution to my problem=2E I am trying to consolidate wmv videos=
from jpg's files (still images captured from an ip cam) using=
WMEncoder 9 SDK (or WMFormat SDK or DirectShow SDK or whichever=
else!!)=2E The WMEncoder SDK seemed to be the simplest approach=2E I=
succeeded in merging videos (inserted in different source=
groups) together but unfortunately as soon as I insert a jpg=
input in a source group it stops the encoding process=2E I=
believe the problem is the SetAutoRollover method=2E=2E=2E which seems=
to work only for videos=2E I can set the method so it switches=
between source groups after X seconds=2E
SrcGrp1=2ESetAutoRollover(1000, "SG2") // after one second
SrcGrp2=2ESetAutoRollover(-1, "SG3") // at the end
However when the source group has a jpg file as a video input it=
does not function=2E=2E=2E ??!! Would it be the good approach in order=
to consolidate a video ? Here is my code just in case you could=
find the problem : (I inserted a jpg file in the SrcGrp4)

' Global Encoder objects, variables and structures
Dim WithEvents glbEncoder As WMEncoder =3D New WMEncoder
Dim SrcGrpColl As IWMEncSourceGroupCollection =3D=
glbEncoder=2ESourceGroupCollection

' Add a source group named SG1 to the collection=2E
' Create a source object in the source group=2E
Dim SrcGrp1 As IWMEncSourceGroup2
Dim SrcVid1 As IWMEncVideoSource2
SrcGrp1 =3D SrcGrpColl=2EAdd("SG1")
SrcVid1 =3D=
SrcGrp1=2EAddSource(WMENC_SOURCE_TYPE=2EWMENC_VIDEO)

' Create a second source group named SG2
Dim SrcGrp2 As IWMEncSourceGroup2
Dim SrcVid2 As IWMEncVideoSource2
SrcGrp2 =3D SrcGrpColl=2EAdd("SG2")
SrcVid2 =3D=
SrcGrp2=2EAddSource(WMENC_SOURCE_TYPE=2EWMENC_VIDEO)

' Create a second source group named SG2
Dim SrcGrp3 As IWMEncSourceGroup2
Dim SrcVid3 As IWMEncVideoSource2
SrcGrp3 =3D SrcGrpColl=2EAdd("SG3")
SrcVid3 =3D=
SrcGrp3=2EAddSource(WMENC_SOURCE_TYPE=2EWMENC_VIDEO)

' Create a second source group named SG2
Dim SrcGrp4 As IWMEncSourceGroup2
Dim SrcVid4 As IWMEncVideoSource2
SrcGrp4 =3D SrcGrpColl=2EAdd("SG4")
SrcVid4 =3D=
SrcGrp4=2EAddSource(WMENC_SOURCE_TYPE=2EWMENC_VIDEO)

' Create a second source group named SG2
Dim SrcGrp5 As IWMEncSourceGroup2
Dim SrcVid5 As IWMEncVideoSource2
SrcGrp5 =3D SrcGrpColl=2EAdd("SG5")
SrcVid5 =3D=
SrcGrp5=2EAddSource(WMENC_SOURCE_TYPE=2EWMENC_VIDEO)

' Specify the input sources in source groups=2E
SrcVid1=2ESetInput("C:\Documents and Settings\USER1\Mis=
documentos\Visual Studio Projects\MBrecorder=
Solution\Frames\TestMBRvideo=2Ewmv")
SrcVid2=2ESetInput("C:\Documents and Settings\USER1\Mis=
documentos\Visual Studio Projects\MBrecorder=
Solution\Frames\video=2Eavi")
SrcVid3=2ESetInput("C:\Documents and Settings\USER1\Mis=
documentos\Visual Studio Projects\MBrecorder=
Solution\Frames\TestMBRvideo=2Ewmv")
SrcVid4=2ESetInput("C:\Documents and Settings\USER1\Mis=
documentos\Visual Studio Projects\MBrecorder=
Solution\Frames\Frame2=2Ejpg")
SrcVid5=2ESetInput("C:\Documents and Settings\USER1\Mis=
documentos\Visual Studio Projects\MBrecorder=
Solution\Frames\video=2Eavi")

' Choose a profile from the collection=2E
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer
Dim lLength As Long

ProColl =3D glbEncoder=2EProfileCollection
lLength =3D ProColl=2ECount

For i =3D 0 To lLength - 1
Pro =3D ProColl=2EItem(i)
If Pro=2EName =3D "Windows Media Video 8 for Local Area=
Network (384 Kbps)" Then
SrcGrp1=2EProfile =3D Pro
SrcGrp2=2EProfile =3D Pro
SrcGrp3=2EProfile =3D Pro
SrcGrp4=2EProfile =3D Pro
SrcGrp5=2EProfile =3D Pro
Exit For
End If
Next

' Specify a file object in which to save encoded=
content=2E
'The output file is an empty or an already existing =2Ewmv=
file
Dim File As IWMEncFile
File =3D glbEncoder=2EFile
File=2ELocalFileName =3D outputFilename

' Specify a file object in which to save encoded=
content=2E
'Dim File As IWMEncFile
'File =3D glbEncoder=2EFile
'File=2ELocalFileName =3D "C:\Documents and=
Settings\USER1\Mis documentos\Visual Studio Projects\MBrecorder=
Solution\Frames\testxxx=2Ewmv"

' Set source group X to roll over automatically to the=
next source group=2E
' -1 indicates that the rollover happens when source=
group X has been encoded=2E
SrcGrp1=2ESetAutoRollover(-1, "SG2")
SrcGrp2=2ESetAutoRollover(-1, "SG3")
SrcGrp3=2ESetAutoRollover(-1, "SG4")
SrcGrp4=2ESetAutoRollover(-1, "SG5")

' Start encoding=2E
glbEncoder=2EStart()

' For this example, use a message box to stop the=
application when you
' have finished encoding=2E
MsgBox("Click OK to stop encoding=2E")


So that's for the WMEncoder SDK solution=2E=2E=2E=2E

I have also read something about DirectShow GraphEdit utility=
using the :

"Generate Still Video" {7DF62B50-6843-11D2-9EEB-006008039E37}=
filter=2E=2E=2E would that be a better alternative ? although more=
complicated having to program it in C++ instead of VB=2ENET or=
C#=2E=2E=2E

I also consulted the DirectShow's PushSource sample which takes=
bmp's as input and builds AVI files=2E=2E=2E would it be possible to=
use a different output filter? like the WM ASF Writer or Reader=
for example ?? I am not too familiar about filters=2E=2E=2E

Anyway PLEASE PLEASE PLEASE help me solving my problem !!! as I=
have been spending hours and hours surfing the internet=
desesperatly for an answer !!!!

Thank you very very much in advance !

--------------------------------
From: Olivier Carrier

-----------------------
Posted by a user from =2ENET 247 (http://www=2Edotnet247=2Ecom/)

RE: how to consolidate a video from jpg's or bmp's with WMEncoder SDK david clark
5/25/2005 6:25:04 AM
Hi Olivier

I too have been trying to use the Encoder to make a video from images. I
think it is possible with a couple of hacks as metioned in this thread:
http://tinyurl.com/d3g6z

but to me they are too hacky - have to add net sink, have to manually, with
a timer or something, trigger the move to the next image / source.

What I am going to use (it works) is DirectShow. There is a nice Interop
assembly called DSHowNET that you can get from:
http://www.limegreensocks.com/DShow/

This is not the original location, but it is the latest. I have made a
couple of alterations to it so I can use SaveProfile and am trying to modify
it so you can get a IWMStreamConfig2 but it is not there yet (not so good
with interop).

AddThis Social Bookmark Button