Quantcast
Channel: Media Foundation Development for Windows Desktop forum
Viewing all articles
Browse latest Browse all 1079

converting block of jpg to wmv using window media encoder

$
0
0
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.)
thanks,
  1. try
  2.            {
  3.                //get current folder
  4.                string curentFolder =Directory.GetCurrentDirectory();
  5.                // Create a WMEncoder object.
  6.                WMEncoderEncoder=newWMEncoder();
  7.                // Retrieve the source group collection.
  8.                IWMEncSourceGroupCollectionSrcGrpColl=Encoder.SourceGroupCollection;
  9.                // Add a source group to the collection.
  10.                IWMEncSourceGroupSrcGrp=SrcGrpColl.Add("SG_1");
  11.                IWMEncVideoSource2SrcVid=(IWMEncVideoSource2)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
  12.                SrcVid.SetInput(@"C:\Users\jacoba\Videos\Untitled.jpg","","");//Bitmap file (.bmp, .gif or .jpg file)
  13.                // Crop 2 pixels from each edge of the video image.
  14.                SrcVid.CroppingBottomMargin=2;
  15.                SrcVid.CroppingTopMargin=2;
  16.                SrcVid.CroppingLeftMargin=2;
  17.                SrcVid.CroppingRightMargin=2;
  18.                // Specify a file object in which to save encoded content.
  19.                IWMEncFileFile=Encoder.File;
  20.                File.LocalFileName= curentFolder+@"\OutputFile.wmv";
  21.                // Choose a profile from the collection.
  22.                IWMEncProfileCollectionProColl=Encoder.ProfileCollection;
  23.                IWMEncProfilePro;
  24.                for(int i =0; i <ProColl.Count; i++)
  25.                {
  26.                    Pro=ProColl.Item(i);
  27.                    //Console.WriteLine(Pro.Name.ToString());
  28.                    if(Pro.Name=="Windows Media Video 8 for Broadband (PAL, 700 Kbps)") //"Screen Video/Audio High (CBR)"
  29.                    {
  30.                        SrcGrp.set_Profile(Pro);
  31.                        break;
  32.                    }
  33.                }
  34.                // Fill in the description object members.
  35.                IWMEncDisplayInfoDescr=Encoder.DisplayInfo;
  36.                Descr.Author="Author name";
  37.                Descr.Copyright="Copyright information";
  38.                Descr.Description="Text description of encoded content";
  39.                Descr.Rating="Rating information";
  40.                Descr.Title="Title of encoded content";
  41.               Encoder.PrepareToEncode(true);
  42.                Encoder.Start();
  43.                Console.WriteLine("Press Enter when the file has been encoded.");
  44.                Console.ReadLine();// Press Enter after the file has been encoded.
  45.            }
  46.            catch(Exception e)
  47.            {
  48.                Console.WriteLine(e.ToString());
  49.                Console.ReadLine();
  50.            } 

Viewing all articles
Browse latest Browse all 1079

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>