CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2013

    converting block of jpg to wmv using window media encoder

    I try to convert jpg to wmv using window media encoder
    SetInput of screenshot works well: SrcVid.SetInput("ScreenCap://ScreenCapture1", "", "");
    When I change the SetInput to jpg
    I am 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.)

                    //get current folder
                    string curentFolder = Directory.GetCurrentDirectory();
                    // Create a WMEncoder object.
                    WMEncoder Encoder = new WMEncoder();
                    // Retrieve the source group collection.
                    IWMEncSourceGroupCollection SrcGrpColl = Encoder.SourceGroupCollection;
                    // Add a source group to the collection.
                    IWMEncSourceGroup SrcGrp = SrcGrpColl.Add("SG_1");
                    IWMEncVideoSource2 SrcVid = (IWMEncVideoSource2)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
                    //SrcVid.SetInput("ScreenCap://ScreenCapture1", "", "");
                    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.
                    IWMEncFile File = Encoder.File;
                    File.LocalFileName = curentFolder + @"\OutputFile.wmv";
                    // Choose a profile from the collection.
                    IWMEncProfileCollection ProColl = Encoder.ProfileCollection;
                    IWMEncProfile Pro;
                    for (int i = 0; i < ProColl.Count; i++)
                        Pro = ProColl.Item(i);
                        if (Pro.Name == "Windows Media Video 8 for Broadband (PAL, 700 Kbps)")  //"Screen Video/Audio High (CBR)"
                    // Fill in the description object members.
                    IWMEncDisplayInfo Descr = 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";
                    // Start the encoding process.
                    // Wait until the encoding process stops before exiting the application.
                    Console.WriteLine("Press Enter when the file has been encoded.");
                    Console.ReadLine(); // Press Enter after the file has been encoded.
                catch (Exception e)

  2. #2
    Join Date
    Jun 2013

    Re: converting block of jpg to wmv using window media encoder

    Sorry that I do not have the link in front of me... I remember seeing a program on CodeProject DOT COM that did something close to what you want to do. Believe it was for BMP images to AVI or something like that.

    There are a lot of options out there... some are very good and some are very bad.

    Your best quick option would be to use Windows Movie Maker then drag all the pictures in the order that you want them in then create the movie.

    Windows Media Encoder was not meant to load picture after picture to make a movie.

    Windows Media Encoder can however translate say an AVI Video to WMV (Windows Media Video) Format.

    Hope that helps you get moving in the right direction.

    Bill G.

  3. #3
    Join Date
    Jun 2013

    Re: converting block of jpg to wmv using window media encoder

    Another option would be to write a quick program to load your images into a fixed size picture box, then use Screen Capture using Windows Media Encoder program by simply making a WME Template then record a section of the screen.

    For Example on Windows 8 PC, if you installed the Windows Media Encoder 9 SDK, then look for this program:
    "C:\Program Files (x86)\Windows Media Components\Encoder\wmenc.exe"

    Hope that will give you some ideas on how to get your task done.

    Bill G.
    Senior Software Engineer for over 35 years
    Age 56

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.