Welcome to MSDN Blogs Sign in | Join | Help

What’s New in the Expression Encoder 3 SDK?

Just posted a little article talking about the Expression Encoder 3 SDK over on the Expression Encoder team blog.

Link

Posted by deanro | 0 Comments

Microsoft Expression Encoder 3 is now available for download

Check out the details on the Expression Encoder blog. Download it and tell us what you think.

Link

Posted by deanro | 0 Comments
Filed under:

Coming Soon: Expression Encoder 3

James has just updated the Expression Encoder blog with details of Expression Encoder 3. The product that has been keeping us busy for a while now. Once it’s out I’ll try to post a little bit more than I have in the past :-)

Link

Posted by deanro | 0 Comments
Filed under:

Editing files with Encoder

In Encoder V2 we added the ability to edit multiple sections out of a video/audio file and this can also be accomplished with the Expression Encoder SDK. MediaItem has a property called SourceClips which contains the list of clips for that media item. When you create a MediaItem it starts with one clip that encompasses the entire duration of the source. Each clip is represented by the SourceClip class and that contains two properties StartTime and EndTime. These properties indicate the times within the source file that the clip represents. For example, if I wanted to change it so that I only encoded the first 15 seconds of the file I could do something like the following.

MediaItem item = new MediaItem(@"C:\myvideo.wmv");
item.SourceClips[0].EndTime = new TimeSpan(0, 0, 15);

If I wanted to include the time from 0-15 seconds and from 30-45 seconds of the file I could add the following lines.

TimeSpan timeStart = new TimeSpan(0, 0, 30);
TimeSpan timeEnd = new TimeSpan(0, 0, 45);
item.SourceClips.Add(new SourceClip(timeStart, timeEnd));

You can keep added SourceClip’s for as many sections of the source that you wish to add before calling the Encode method.

Posted by deanro | 8 Comments
Filed under:

Metadata

When encoding files using the Expression Encoder SDK, you may find there are times when you want to examine the current metadata and/or change the metadata on the file you’re creating. Let’s say you want to go through all the metadata items on an item, you can do something like this.

MediaItem mediaItem = new MediaItem(@"C:\myvideo.wmv");
int metadataCount = 0;
foreach (KeyValuePair<string, string> pair in mediaItem.Metadata)
{
    Console.WriteLine(pair.Key + "-" + pair.Value);
}

More frequently you’ll probably want to specify certain metadata before encoding the file. You can do this by doing something like the following before calling the Job’s Encode method

mediaItem.Metadata[MetadataNames.Title] = "My Home Movies";
mediaItem.Metadata[MetadataNames.Author] = "Dean Rowe";

These are using the predefined metadata names that we’ve specified. If you want to specify your own custom metadata you can simply do something like

mediaItem.Metadata["Fred"] = "Foo";
Posted by deanro | 0 Comments
Filed under:

Expression Encoder 2 SDK Updated for Service Pack 1

I’ve just uploaded a post to the Expression Encoder team blog that talks about the new updates to the Expression Encoder 2 SDK that we’ve just released for Service Pack 1. Go ahead and try it out and let us know if you have any questions or comments.

Link

Posted by deanro | 1 Comments

Bingo

image The other day my wife had volunteered to help out with the Halloween festivities at my son’s school. As part of this, she wanted to organize a game of bingo for the kids. I promised to help and went online to search for some halloween bingo cards that could be generated or printed out. Unfortunately my searches weren’t fruitful. I found ones with numbers or words, but nothing that allowed me to uses images – which I thought would make it more fun for the young kids.

I thought about using Excel to generate the cards or maybe Word but that didn’t look to be as straightforward as I ‘d hope it might be. Then I thought “What about writing a quick WFP app?”. I hadn’t tried printing from WPF first, so I knocked up a quick app to try that out. Once that proved straightforward I just had to write some simple XAML to layout the card, get some halloween clipart from office online and write a little code to load and randomize the images.

So here’s what I ended up with. Each time you run it the app you get a “random” card and every time you click “Print” a new card is generated so you can just keep printing until you have enough cards.

The kids loved it. We gave a few prizes for the kids that got a line first and then we let the kids keeping playing until everybody had filled their card. Note that I deliberately chose to include every image on every card, so everybody filled out their card and shouted “house” at the same time. Of course it would be quite easy to change this behaviour.

If you ever want to do something like this yourself, just launch Visual Studio and create a new WPF application. Here’s what my window1.xaml looked like.

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="UntitledProject4.Window1"
    x:Name="Window"
    Title="Bingo"
    Width="850" Height="900">

    <StackPanel x:Name="LayoutRoot">
        <Border x:Name="BingoCard" Margin="50,50,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" BorderBrush="#FF000000" BorderThickness="5,5,5,5">
            <ItemsControl ItemsSource="{Binding ElementName=Window, Path=Images}" >
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Border Width="142" Height="142" BorderBrush="#FF000000" BorderThickness="5,5,5,5">
                            <Image Width="Auto" Height="Auto" Source="{Binding Path=FileName}" Margin="10,10,10,10"/>
                        </Border>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </Border>
        <Button HorizontalAlignment="Left" Margin="20,20,0,44" Width="97" Height="30" Content="Print" Click="OnPrint" IsDefault="True"/>
    </StackPanel>
</Window>

and here’s the corresponding C# file.

using System;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;

namespace UntitledProject4
{
    public class ImageData
    {
        public ImageData(string fileName)
        {
            this.FileName = fileName;
        }

        public string FileName { get; set; }    
    }

    public partial class Window1
    {
        /// <summary>
        /// The list of images that are databound to.
        /// </summary>
        private ObservableCollection<ImageData> m_images = new ObservableCollection<ImageData>();
        
        /// <summary>
        /// The print dialog. We store it as a member variable so any printer settings are preserved
        /// across multiple prints.
        /// </summary>
        private PrintDialog m_prtDlg = new PrintDialog();

        /// <summary>
        /// Initialize a instance of the Window1 class, that holds a bingo card.
        /// </summary>
        public Window1()
        {
            // Load the images - in this case I'm just loading them from c:\temp\halloween
            for (int i = 1; i <= 25; i++)
            {
                m_images.Add(new ImageData(@"C:\temp\halloween\" + i.ToString() + ".bmp"));
            }

            // Randomize them.
            this.RandomizeImages();

            this.InitializeComponent();
        }

        /// <summary>
        /// Gets the collection of images to use for the bingo card.
        /// </summary>
        public ObservableCollection<ImageData> Images
        {
            get
            {
                return m_images;
            }
        }

        /// <summary>
        /// Called to print the bingo card. The images are randomized after every print.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">The event arguments</param>
        private void OnPrint(object sender, RoutedEventArgs e)
        {
            if (m_prtDlg.ShowDialog() == true)
            {
                m_prtDlg.PrintVisual(this.BingoCard, "Bingo");
            }

            RandomizeImages();
        }

        /// <summary>
        /// Randomly shuffle the images
        /// </summary>
        private void RandomizeImages()
        {
            Random random = new Random();
            int imagesCount = m_images.Count;
            for (int i = 0; i < imagesCount; i++)
            {
                int randomIndex = random.Next(0, imagesCount);
                ImageData imageData = m_images[randomIndex];
                m_images[randomIndex] = m_images[i];
                m_images[i] = imageData;
            }
        }
    }
}

 

Hopefully the code should be self explanatory.

Posted by deanro | 1 Comments
Filed under:

Expression Encoder 2 SP1 SDK

As you may have heard Expression Encoder 2 SP1 is now available to download. We've been putting the final touches to the updated SDK which will included an updated help file, intellisense files and some samples in C# and now also in Visual Basic. The SDK should be released soon.

Posted by deanro | 1 Comments
Filed under:

Expression Encoder 2 SP1

If you’ve been wondering what we’ve been doing for last few months we’ve now announced Expression Encoder SP1 over on the Expression Encoder team blog. You’ll find quite a few new features and some nice bug fixes and this will be a free upgrade to to Expression Encoder 2.

Posted by deanro | 1 Comments
Filed under:

Expression Encoder and VB.NET

As James recently posted on the Expression Encoder team blog, we’ve just released an update to Expression Encoder 2 so that if you wish to use our object model from Visual Basic.NET you can now do that.

Download link

Posted by deanro | 1 Comments
Filed under:

Expression Encoder 2 SDK released

We released the Encoder SDK today. You can download it from the following location.

Microsoft® Expression® Encoder 2 SDK

Once installed, it will create a Start Menu shortcut under Microsoft Expression which opens an explorer window to the SDK directory.

The SDK installs a couple of XML files which enable intellisense comments within Visual Studio.

There is a Docs folder which contains the help file along with a PNG of the object hierarchy which can be printed if desired.

You'll also see a Samples directory which contain the actual samples. If you're running Vista and you want to build the samples directly from this location, remember that you'll probably need to run Visual Studio elevated.

The help file contains an introduction, details on the samples, the API reference and a few other bits and pieces.

image

We hope you find this useful, and please send us your feedback.

Posted by deanro | 3 Comments
Filed under:

Intellisense and Help file for Expression Encoder 2 Object Model

Just posted a link to the Intellisense and Help files for the object model to the Expression Encoder Team blog.

Head over, try them out and let us know what you think.

Thanks

Link

Posted by deanro | 2 Comments
Filed under:

Expression Encoder 2 is released

Expression Encoder 2 is now available. Click on the image to go to the Expression Encoder page where you will find a "Try Now" link to download the trial. We're planning to have more details of the new features up on the Expression Encoder Team blog soon. I'm also working on getting together a prelimary help file for the SDK object model and some XML files that will enable Intellisense comments within Visual Studio. Expect those soon...

image

Posted by deanro | 1 Comments
Filed under:

Changing the output profile

Once you've created a MediaItem, you're probably going to want to specify which video and/or audio profile you want to encode it with. There are a number of ways to obtain a video and audio profile. If you have your own PRX file that you wish to use, you can load it with code something like this

VideoProfile videoProfile;
AudioProfile audioProfile;
LocalProfiles.LoadProfileFromFile(@"C:\MyProfile.prx", out videoProfile, out audioProfile);

Once you have the profile loaded you can then set it on the MediaItem like so

mediaItem.VideoProfile = videoProfile;
mediaItem.AudioProfile = audioProfile;

If you want to use one of the built-in profiles you can obtain it with code something like this by just searching for the name of the profile.

VideoProfile videoProfile = VideoProfile.FindProfile("Hardware Device - zune");

This does have the disadvantage that the code isn't going to work on a non English version of Expression Encoder as the string will be localized into a different language. So in the RTM version of Expression Encoder we will include a static list of Video and Audio Profiles that match the built-in profiles we supply, so you'll be able to write the code a little easier like this

// Code from the future
mediaItem.VideoProfile = VideoProfiles.HardwareDeviceZune;

Once you've set the profile you may want to tweak it further by changing some of the individual parameters. You can do this with code like the following

// Funky code alert
mediaItem.VideoProfile = (VideoProfile)mediaItem.VideoProfile.Clone();

// Set the video bitrate and change the dimensions of the output video
mediaItem.VideoProfile.Bitrate = 64000;
mediaItem.VideoProfile.Height = 80;
mediaItem.VideoProfile.Width = 120;

You may have noticed the ever so slightly funky code at the beginning :-). At the moment, when you get an instance of a VideoProfile or AudioProfile class back we're internally creating what is essentially a read only version. So if you try to change one of the parameters you'll get an exception. To fix this at the moment, you need to make a copy of the class before you can change it and this is what the Clone line does. When the RTM version of Expression Encoder comes out, this hopefully should no longer be necessary and you'll be able to change things directly as you'd expect.

After you've done all this, you can go ahead and call Encode on the job and you should end up with a video file that matches the profiles that you've set.

Posted by deanro | 3 Comments
Filed under:

Overview of Expression Encoder 2

The session that our very own James and Charles did at Mix this morning is already online.  I haven't had a chance to watch it myself yet, but I'm sure James and Charles did an excellent job.

image

Posted by deanro | 1 Comments
Filed under:
More Posts Next page »
 
Page view tracker