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
    Posts
    1

    converting block of jpg to wmv using window media encoder

    Hi
    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.)
    Thanks,



    Code:
    try
                {
                    //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);
                        //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.
                    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.
                    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();
                }

  2. #2
    Join Date
    Jun 2013
    Posts
    2

    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
    Posts
    2

    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
  •  





Click Here to Expand Forum to Full Width

Featured