Hi
I try to convert jpg to wmv using window media encoder
I running this code (contain single jpg for Trial) I get error
"System.Runtime.InteropServices.COMException (0xC00D0BB8): The input media format is invalid."
at line: SrcVid.SetInput(@"C:\Users\jacoba\Videos\Untitled.jpg", "", "");
any idea how to SetInput for jpg (or any others image - BMP, PNG etc.)
I try to convert jpg to wmv using window media encoder
I running this code (contain single jpg for Trial) I get error
"System.Runtime.InteropServices.COMException (0xC00D0BB8): The input media format is invalid."
at line: SrcVid.SetInput(@"C:\Users\jacoba\Videos\Untitled.jpg", "", "");
any idea how to SetInput for jpg (or any others image - BMP, PNG etc.)
thanks,
try
{
//get current folder
string curentFolder =Directory.GetCurrentDirectory();
// Create a WMEncoder object.
WMEncoderEncoder=newWMEncoder();
// Retrieve the source group collection.
IWMEncSourceGroupCollectionSrcGrpColl=Encoder.SourceGroupCollection;
// Add a source group to the collection.
IWMEncSourceGroupSrcGrp=SrcGrpColl.Add("SG_1");
IWMEncVideoSource2SrcVid=(IWMEncVideoSource2)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
SrcVid.SetInput(@"C:\Users\jacoba\Videos\Untitled.jpg","","");//Bitmap file (.bmp, .gif or .jpg file)
// Crop 2 pixels from each edge of the video image.
SrcVid.CroppingBottomMargin=2;
SrcVid.CroppingTopMargin=2;
SrcVid.CroppingLeftMargin=2;
SrcVid.CroppingRightMargin=2;
// Specify a file object in which to save encoded content.
IWMEncFileFile=Encoder.File;
File.LocalFileName= curentFolder+@"\OutputFile.wmv";
// Choose a profile from the collection.
IWMEncProfileCollectionProColl=Encoder.ProfileCollection;
IWMEncProfilePro;
for(int i =0; i <ProColl.Count; i++)
{
Pro=ProColl.Item(i);
//Console.WriteLine(Pro.Name.ToString());
if(Pro.Name=="Windows Media Video 8 for Broadband (PAL, 700 Kbps)") //"Screen Video/Audio High (CBR)"
{
SrcGrp.set_Profile(Pro);
break;
}
}
// Fill in the description object members.
IWMEncDisplayInfoDescr=Encoder.DisplayInfo;
Descr.Author="Author name";
Descr.Copyright="Copyright information";
Descr.Description="Text description of encoded content";
Descr.Rating="Rating information";
Descr.Title="Title of encoded content";
Encoder.PrepareToEncode(true);
Encoder.Start();
Console.WriteLine("Press Enter when the file has been encoded.");
Console.ReadLine();// Press Enter after the file has been encoded.
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
Console.ReadLine();
}