Encoding multiple bit rates using Expression Encoder SDK

Answered Encoding multiple bit rates using Expression Encoder SDK

  • Wednesday, February 04, 2009 12:05 AM
     
     

    We're looking to do multiple bit rates with Expression Encoder, and I was given an xml file to use as a template for encoding.  Once I create my job, how do I apply the template to it?  I see there is a template property, but I'm not sure what to pass it.  Do I give it the location of the file on the server, or include the file in the project?  Any help is appreciated.

All Replies

  • Monday, February 09, 2009 4:20 AM
     
     

    Hi Jhorra,

    We suggest that you'd better create a simple windows application.  It will get the target template create jobs to encode "multiple bite rates".For example,


            /// <summary>
            /// The function that is called to encode the current file.
            /// </summary>
            private void EncodeThread()
            {
                // Indicate in the UI that we're about to analyze the file and show the progress bar.
                this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)delegate()
                {
                    SetValue(StatusProperty, "Analyzing");

                    // Now we should show the progress bar
                    progressBar.Visibility = Visibility.Visible;
                });
               
                // Create the media item.
                MediaItem mediaItem;
                try
                {
                    mediaItem = new MediaItem(this.fileNameToEncode);
                }
                catch (InvalidMediaFileException exp)
                {
                    IndicateEncodingIsFinished(exp.Message);
                    return;
                }

                // Create the job, add the media item and encode.
                using (Job job = new Job())
                {
                    job.MediaItems.Add(mediaItem);
                    job.OutputDirectory = @"C:\output";

                    job.EncodeProgress += new EventHandler<EncodeProgressEventArgs>(OnProgress);

                    job.Encode();
                }

                IndicateEncodingIsFinished("Finished");
            }

            /// <summary>
            /// Called when the encode has finished.
            /// </summary>
            /// <param name="message">The message to display.</param>
            private void IndicateEncodingIsFinished(string message)
            {
                // Indicate in the UI that we're finished.
                this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)delegate()
                {
                    SetValue(StatusProperty, message);
                    SetValue(IsIdleProperty, true);

                    // Now we can hide the progress bar
                    progressBar.Visibility = Visibility.Hidden;
                });
            }
    We can get the sample on its SDK file.

    Best regards,

    Jonathan

  • Monday, February 09, 2009 9:47 AM
     
     

     Sorry if I wasn't clear.  I did create a windows application that does this.  My question is how do I pass it a file with presets to tell it how to encode.

  • Tuesday, February 10, 2009 1:34 AM
     
     Answered

    Hi Jhorra, 

    see there is a template property, but I'm not sure what to pass it.  Do I give it the location of the file on the server, or include the file in the project?

    We need to create a template here.  For example,

    MediaItem mediaItem = new MediaItem(@"C:\test\midnight.wmv");

                // Create a job and the media item for the video we wish
                // to encode.
                Job job = new Job();
                job.MediaItems.Add(mediaItem);

                // Set up the progress callback function
                job.EncodeProgress
                    += new EventHandler<EncodeProgressEventArgs>(OnProgress);

                // Set the output directory and encode.
                job.OutputDirectory = @"C:\test";
                job.DefaultMediaOutputFileName = "test.wmv";
                job.CreateSubfolder = false;
                job.Template = new Microsoft.Expression.Encoder.Templates.Template("Popup", @"C:\Program Files\Microsoft Expression\Encoder 2\Templates\en\FrostedGallery");    //this template will be found after Encoder 2 SP1 installed.
                job.Encode();

    For more clues, please take a look at this video.  Also, we can create a batch file(bat file) to achieve your goal.

    Best regards,

    Jonathan

  • Tuesday, February 10, 2009 2:03 AM
     
     

     I'm trying to find some documentation for this, is the first value, "name" supposed to be the name of the file and the second the directory it's located in?

  • Tuesday, February 10, 2009 2:54 AM
     
     

    Hi Jhorra,

    You'd better watch the video and use encoder.exe  /ListTemplates to show all the supported templates.   Currently, we can find something valueable from the Encode 2 SDK.

    Best regards,

    Jonathan

  • Tuesday, February 10, 2009 10:27 AM
     
     

     We've created a template with the bit rates, and encoding settings we wanted in Encoder, then exported the xml file.  That's the file I need to use, I don't want any templates created by default.  Also, this has to be done using the object model.

  • Tuesday, February 10, 2009 10:29 PM
     
     

    Hi Jhorra,

    Please take a look at the Microsoft.Expression.Encoder.Profiles.VideoProfile.  There you can set the properties freely. For example,

    MediaItem mediaItem = new MediaItem(@"C:\test\midnight.wmv");

                // Create a job and the media item for the video we wish
                // to encode.
                Job job = new Job();
                job.MediaItems.Add(mediaItem);

                Microsoft.Expression.Encoder.Profiles.VideoProfile vp = new Microsoft.Expression.Encoder.Profiles.VideoProfile();
                vp.Codec = Microsoft.Expression.Encoder.Profiles.VideoCodec.VC1;
                vp.CodecProfile = Microsoft.Expression.Encoder.Profiles.VideoCodecProfile.Advanced;
                vp.Bitrate = 458000;
                vp.MaxBitrate = 100000;

                .......
                mediaItem.VideoProfile = vp;

    For customize your VideoProfile, it is recommended to use Expression Encoder and save your template.  After that, we can find it on a location just like this by default.C:\Users\user account\Documents\Expression\Expression Encoder\Profiles.

    Also, this has to be done using the object model.

    I am not quite sure about what you mean by this.  Seems that object model is a way for coding.

    Best regards,

    Jonathan