| Comments

In an email dialog today I saw someone asking how he could use an existing Encoder 2 template for existing media or streaming URIs when you don’t have something to encode.  After a few explanations, he replied that someone should blog this – and I agree :-).

So what did he mean?  Well, when you use Expression Encoder, you are typically going to be encoding media to a format to consume.  Encoder also gives you an additional option in the output settings to generate a media player for that encoded content.  These are all based on templates that I’ve previously written about that are available in the product as well is the source code for you to extend.

But what if you have a media file that doesn’t need encoding or you have a streaming URI and you don’t need to encode anything, but want the player?  To some it might not be so obvious so let me try to walk you through the steps.

You need the player

First you need the player.  The XAP that is, of the template you want to use.  There are essentially two ways of going about getting this:

    1. Getting the MediaPlayerTemplate.xap file from an existing output you already did (that used the same template you want)
    2. Building the XAP using the source of the templates and building it from scratch (requires .NET compiler or Visual Studio)

Obviously if you have the XAP of your desired template, you are ready to proceed.  If you don’t, then you’ll need to proceed to step 2.  Here’s what you’ll do:

Building the Player

First, find the template you want.  These are located in C:\Program Files\Microsoft Expression\Encoder 2\Templates\en (note: if you are on 64-bit or a different language, this path may differ slightly).  Within here you’ll see a list of templates by name.  Find the one you want and within that folder there is a Source directory.  That’s what you want.  I highly recommend actually moving the source files to a different place rather than edit directly in the templates directory.  There is a Visual Studio 2008 solution/project file in there and you can open it up and compile. 

As long as you are in there…

If you don’t need all the features of the template (i.e., Adaptive Streaming, etc) consider reading James Clarke’s post on removing some of those references and still creating the same template, but with reduced functionality.

Once compiled (remember to choose the right configuration - i.e., Release, Debug - for your needs), you’ll have in the Bin directory of that project the MediaPlayerTemplate.xap file you need. 

Passing parameters

So how can you compile the player template without media?  The Encoder 2 Silvelright 2 templates are completely parameter driven.  If you notice in any existing encoded project output (look at the default.html file generated) you’ll see the object tag used to host the player.  It may look something like this:

   1: <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
   2:     <param name="source" value="MediaPlayerTemplate.xap"/>
   3:     <param name="onerror" value="onSilverlightError" />
   4:     <param name="initparams" value='autoplay=True,autoload=True,enablecaptions=True,muted=False,stretchmode=0,displaytimecode=False,playlist=&lt;playList><playListItems><playListItem title="Moonlight%201.0%20Install%20on%20OpenSuse" description="Screencast%20of%20Moonlight%20install%20on%20OpenSuse.%20%20Virtual%20image%20provided%20by%20http://susestudio.com." mediaSource="MoonlightInstall.wmv" adaptiveStreaming="False" thumbSource="" frameRate="14.9669006991039" width="800" height="600" ><chapters><chapter  position="9.674" thumbnailSource="MoonlightInstall_9.674.jpg" title="Silverlight%201.0%20Chess%20playback%20from%20Vertigo" /><chapter  position="13.967" thumbnailSource="MoonlightInstall_13.967.jpg" title="Standard%20Silverlight%20installer%20integrates%20with%20Moonlight%20install%20links." /><chapter  position="18.058" thumbnailSource="MoonlightInstall_18.058.jpg" title="Firefox%20first%20nag%20message%20to%20protect%20user%20from%20web%20installs." /><chapter  position="20.784" thumbnailSource="MoonlightInstall_20.784.jpg" title="Second%20Firefox%20nag%20message%20(plugin%20message%20from%20trusted%20sources)" /><chapter  position="24.543" thumbnailSource="MoonlightInstall_24.543.jpg" title="Plugin%20installation%20complete%252C%20Firefox%20restart" /><chapter  position="32.055" thumbnailSource="MoonlightInstall_32.055.jpg" title="Silverlight%201.0%20Chess%20now%20working%20with%20Linux/Moonlight" /><chapter  position="43.801" thumbnailSource="MoonlightInstall_43.801.jpg" title="Video.Show%20from%20Vertigo" /><chapter  position="46.675" thumbnailSource="MoonlightInstall_46.675.jpg" title="Launching%20a%20media%20player%20in%20Moonlight%20for%20first%20time" /><chapter  position="48.334" thumbnailSource="MoonlightInstall_48.334.jpg" title="Microsoft%20Media%20Pack%20(codecs)%20prompt%20for%20install" /><chapter  position="51.249" thumbnailSource="MoonlightInstall_51.249.jpg" title="Media%20Pack%20EULA" /><chapter  position="60.051" thumbnailSource="MoonlightInstall_60.051.jpg" title="Re-launch%20media%20player%20with%20Media%20Pack%20installed" /><chapter  position="71.010" thumbnailSource="MoonlightInstall_71.010.jpg" title="HD%20media%20playback%20via%20Moonlight%20on%20Linux" /><chapter  position="72.490" thumbnailSource="MoonlightInstall_72.490.jpg" title="Fullscreen%20mode" /><chapter  position="76.138" thumbnailSource="MoonlightInstall_76.138.jpg" title="Bubblemark%20application%20on%20Moonlight" /></chapters></playListItem></playListItems></playList>' />            
   5:     
   6:     <a href="http://go2.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;">
   7:          <img src="http://go2.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/>
   8:     </a>
   9: </object>
  10: <iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe>

Notice the initParams option?  If you aren’t familiar, you can send Silverlight 2 applications parameters using this method.  There’s a video walk-through on using initParams you can view on the Silverlight community site.  The key area here (among the other options) for media URIs is the playlist parameter.  Singling that one out you’ll see the structure looks like this:

   1: <?xml version="1.0" encoding="utf-8" ?>
   2: <playList>
   3:   <playListItems>
   4:     <playListItem title="Moonlight%201.0%20Install%20on%20OpenSuse" description="Screencast%20of%20Moonlight%20install%20on%20OpenSuse.%20%20Virtual%20image%20provided%20by%20http://susestudio.com." mediaSource="MoonlightInstall.wmv" adaptiveStreaming="False" thumbSource="" frameRate="14.9669006991039" width="800" height="600" >
   5:       <chapters>
   6:         <chapter  position="9.674" thumbnailSource="MoonlightInstall_9.674.jpg" title="Silverlight%201.0%20Chess%20playback%20from%20Vertigo" />
   7:         <chapter  position="13.967" thumbnailSource="MoonlightInstall_13.967.jpg" title="Standard%20Silverlight%20installer%20integrates%20with%20Moonlight%20install%20links." />
   8:         <chapter  position="18.058" thumbnailSource="MoonlightInstall_18.058.jpg" title="Firefox%20first%20nag%20message%20to%20protect%20user%20from%20web%20installs." />
   9:         <chapter  position="20.784" thumbnailSource="MoonlightInstall_20.784.jpg" title="Second%20Firefox%20nag%20message%20(plugin%20message%20from%20trusted%20sources)" />
  10:         <chapter  position="24.543" thumbnailSource="MoonlightInstall_24.543.jpg" title="Plugin%20installation%20complete%252C%20Firefox%20restart" />
  11:         <chapter  position="32.055" thumbnailSource="MoonlightInstall_32.055.jpg" title="Silverlight%201.0%20Chess%20now%20working%20with%20Linux/Moonlight" />
  12:         <chapter  position="43.801" thumbnailSource="MoonlightInstall_43.801.jpg" title="Video.Show%20from%20Vertigo" />
  13:         <chapter  position="46.675" thumbnailSource="MoonlightInstall_46.675.jpg" title="Launching%20a%20media%20player%20in%20Moonlight%20for%20first%20time" />
  14:         <chapter  position="48.334" thumbnailSource="MoonlightInstall_48.334.jpg" title="Microsoft%20Media%20Pack%20(codecs)%20prompt%20for%20install" />
  15:         <chapter  position="51.249" thumbnailSource="MoonlightInstall_51.249.jpg" title="Media%20Pack%20EULA" />
  16:         <chapter  position="60.051" thumbnailSource="MoonlightInstall_60.051.jpg" title="Re-launch%20media%20player%20with%20Media%20Pack%20installed" />
  17:         <chapter  position="71.010" thumbnailSource="MoonlightInstall_71.010.jpg" title="HD%20media%20playback%20via%20Moonlight%20on%20Linux" />
  18:         <chapter  position="72.490" thumbnailSource="MoonlightInstall_72.490.jpg" title="Fullscreen%20mode" />
  19:         <chapter  position="76.138" thumbnailSource="MoonlightInstall_76.138.jpg" title="Bubblemark%20application%20on%20Moonlight" />
  20:       </chapters>
  21:     </playListItem>
  22:   </playListItems>
  23: </playList>

This sample above represents a single media file with chapter markers.  The bare minimum for a single media URI would be:

   1: <playList>
   2:   <playListItems>
   3:     <playListItem mediaSource="MoonlightInstall.wmv"></playListItem>
   4:   </playListItems>
   5: </playList>

So if you have a streaming URI (i.e., mms://mysite.com/live-baseball-game.asx) you would use this playlist structure:

   1: <playList>
   2:   <playListItems>
   3:     <playListItem mediaSource="mms://mysite.com/live-baseball-game.asx"></playListItem>
   4:   </playListItems>
   5: </playList>

and then in your HTML page you could have something like this for the full implementation (noting to use the appropriate width/height for your needs):

   1: <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
   2:     <param name="source" value="MediaPlayerTemplate.xap"/>
   3:     <param name="onerror" value="onSilverlightError" />
   4:     <param name="initparams" value='autoplay=True,autoload=True,enablecaptions=True,muted=False,stretchmode=0,displaytimecode=False,playlist=&lt;playList><playListItems><playListItem mediaSource="mms://mysite.com/live-baseball-game.asx"></playListItem></playListItems></playList>' />            
   5:     
   6:     <a href="http://go2.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;">
   7:          <img src="http://go2.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/>
   8:     </a>
   9: </object>
  10: <iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe>

It is important to note that if you know the other parameters like framerate, etc. you should provide as much information you can for the playListItem node, but I’m just noting the bare minimum above.

Can I do this in code?

Yes, if you were using the media player in code you can still use this method in either XAML as noted in a previous post of mine or in code using something like this:

   1: public Page()
   2:         {
   3:             InitializeComponent();
   4:             Loaded += new RoutedEventHandler(Page_Loaded);
   5:         }
   6:  
   7:         void Page_Loaded(object sender, RoutedEventArgs e)
   8:         {
   9:             ExpressionMediaPlayer.MediaPlayer mp = new ExpressionMediaPlayer.MediaPlayer();
  10:             mp.Width = 800;
  11:             mp.Height = 600;
  12:             ExpressionMediaPlayer.PlaylistItem playListItem = new ExpressionMediaPlayer.PlaylistItem();
  13:             playListItem.MediaUrl = new Uri("mms://mysite.com/live-baseball-game.asx");
  14:             mp.Playlist.Add(playListItem);
  15:             LayoutRoot.Children.Add(mp);
  16:         }

I suspect people would not be using the code concept as much but I just wanted to point it out here.

Summary

So having the MediaPlayerTemplate.xap file is really all you need.  Anything else can be sent as parameters either via the object tag, the XAML control or in code.  This enables being able to really re-use the template you desire without having to run an encoder job just to get the template and change the code.

Hope this helps!

| Comments

In an email dialog today I saw someone asking how he could use an existing Encoder 2 template for existing media or streaming URIs when you don’t have something to encode.  After a few explanations, he replied that someone should blog this – and I agree :-).

So what did he mean?  Well, when you use Expression Encoder, you are typically going to be encoding media to a format to consume.  Encoder also gives you an additional option in the output settings to generate a media player for that encoded content.  These are all based on templates that I’ve previously written about that are available in the product as well is the source code for you to extend.

But what if you have a media file that doesn’t need encoding or you have a streaming URI and you don’t need to encode anything, but want the player?  To some it might not be so obvious so let me try to walk you through the steps.

You need the player

First you need the player.  The XAP that is, of the template you want to use.  There are essentially two ways of going about getting this:

    1. Getting the MediaPlayerTemplate.xap file from an existing output you already did (that used the same template you want)
    2. Building the XAP using the source of the templates and building it from scratch (requires .NET compiler or Visual Studio)

Obviously if you have the XAP of your desired template, you are ready to proceed.  If you don’t, then you’ll need to proceed to step 2.  Here’s what you’ll do:

Building the Player

First, find the template you want.  These are located in C:\Program Files\Microsoft Expression\Encoder 2\Templates\en (note: if you are on 64-bit or a different language, this path may differ slightly).  Within here you’ll see a list of templates by name.  Find the one you want and within that folder there is a Source directory.  That’s what you want.  I highly recommend actually moving the source files to a different place rather than edit directly in the templates directory.  There is a Visual Studio 2008 solution/project file in there and you can open it up and compile. 

As long as you are in there…

If you don’t need all the features of the template (i.e., Adaptive Streaming, etc) consider reading James Clarke’s post on removing some of those references and still creating the same template, but with reduced functionality.

Once compiled (remember to choose the right configuration - i.e., Release, Debug - for your needs), you’ll have in the Bin directory of that project the MediaPlayerTemplate.xap file you need. 

Passing parameters

So how can you compile the player template without media?  The Encoder 2 Silvelright 2 templates are completely parameter driven.  If you notice in any existing encoded project output (look at the default.html file generated) you’ll see the object tag used to host the player.  It may look something like this:

   1: <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
   2:     <param name="source" value="MediaPlayerTemplate.xap"/>
   3:     <param name="onerror" value="onSilverlightError" />
   4:     <param name="initparams" value='autoplay=True,autoload=True,enablecaptions=True,muted=False,stretchmode=0,displaytimecode=False,playlist=&lt;playList><playListItems><playListItem title="Moonlight%201.0%20Install%20on%20OpenSuse" description="Screencast%20of%20Moonlight%20install%20on%20OpenSuse.%20%20Virtual%20image%20provided%20by%20http://susestudio.com." mediaSource="MoonlightInstall.wmv" adaptiveStreaming="False" thumbSource="" frameRate="14.9669006991039" width="800" height="600" ><chapters><chapter  position="9.674" thumbnailSource="MoonlightInstall_9.674.jpg" title="Silverlight%201.0%20Chess%20playback%20from%20Vertigo" /><chapter  position="13.967" thumbnailSource="MoonlightInstall_13.967.jpg" title="Standard%20Silverlight%20installer%20integrates%20with%20Moonlight%20install%20links." /><chapter  position="18.058" thumbnailSource="MoonlightInstall_18.058.jpg" title="Firefox%20first%20nag%20message%20to%20protect%20user%20from%20web%20installs." /><chapter  position="20.784" thumbnailSource="MoonlightInstall_20.784.jpg" title="Second%20Firefox%20nag%20message%20(plugin%20message%20from%20trusted%20sources)" /><chapter  position="24.543" thumbnailSource="MoonlightInstall_24.543.jpg" title="Plugin%20installation%20complete%252C%20Firefox%20restart" /><chapter  position="32.055" thumbnailSource="MoonlightInstall_32.055.jpg" title="Silverlight%201.0%20Chess%20now%20working%20with%20Linux/Moonlight" /><chapter  position="43.801" thumbnailSource="MoonlightInstall_43.801.jpg" title="Video.Show%20from%20Vertigo" /><chapter  position="46.675" thumbnailSource="MoonlightInstall_46.675.jpg" title="Launching%20a%20media%20player%20in%20Moonlight%20for%20first%20time" /><chapter  position="48.334" thumbnailSource="MoonlightInstall_48.334.jpg" title="Microsoft%20Media%20Pack%20(codecs)%20prompt%20for%20install" /><chapter  position="51.249" thumbnailSource="MoonlightInstall_51.249.jpg" title="Media%20Pack%20EULA" /><chapter  position="60.051" thumbnailSource="MoonlightInstall_60.051.jpg" title="Re-launch%20media%20player%20with%20Media%20Pack%20installed" /><chapter  position="71.010" thumbnailSource="MoonlightInstall_71.010.jpg" title="HD%20media%20playback%20via%20Moonlight%20on%20Linux" /><chapter  position="72.490" thumbnailSource="MoonlightInstall_72.490.jpg" title="Fullscreen%20mode" /><chapter  position="76.138" thumbnailSource="MoonlightInstall_76.138.jpg" title="Bubblemark%20application%20on%20Moonlight" /></chapters></playListItem></playListItems></playList>' />            
   5:     
   6:     <a href="http://go2.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;">
   7:          <img src="http://go2.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/>
   8:     </a>
   9: </object>
  10: <iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe>

Notice the initParams option?  If you aren’t familiar, you can send Silverlight 2 applications parameters using this method.  There’s a video walk-through on using initParams you can view on the Silverlight community site.  The key area here (among the other options) for media URIs is the playlist parameter.  Singling that one out you’ll see the structure looks like this:

   1: <?xml version="1.0" encoding="utf-8" ?>
   2: <playList>
   3:   <playListItems>
   4:     <playListItem title="Moonlight%201.0%20Install%20on%20OpenSuse" description="Screencast%20of%20Moonlight%20install%20on%20OpenSuse.%20%20Virtual%20image%20provided%20by%20http://susestudio.com." mediaSource="MoonlightInstall.wmv" adaptiveStreaming="False" thumbSource="" frameRate="14.9669006991039" width="800" height="600" >
   5:       <chapters>
   6:         <chapter  position="9.674" thumbnailSource="MoonlightInstall_9.674.jpg" title="Silverlight%201.0%20Chess%20playback%20from%20Vertigo" />
   7:         <chapter  position="13.967" thumbnailSource="MoonlightInstall_13.967.jpg" title="Standard%20Silverlight%20installer%20integrates%20with%20Moonlight%20install%20links." />
   8:         <chapter  position="18.058" thumbnailSource="MoonlightInstall_18.058.jpg" title="Firefox%20first%20nag%20message%20to%20protect%20user%20from%20web%20installs." />
   9:         <chapter  position="20.784" thumbnailSource="MoonlightInstall_20.784.jpg" title="Second%20Firefox%20nag%20message%20(plugin%20message%20from%20trusted%20sources)" />
  10:         <chapter  position="24.543" thumbnailSource="MoonlightInstall_24.543.jpg" title="Plugin%20installation%20complete%252C%20Firefox%20restart" />
  11:         <chapter  position="32.055" thumbnailSource="MoonlightInstall_32.055.jpg" title="Silverlight%201.0%20Chess%20now%20working%20with%20Linux/Moonlight" />
  12:         <chapter  position="43.801" thumbnailSource="MoonlightInstall_43.801.jpg" title="Video.Show%20from%20Vertigo" />
  13:         <chapter  position="46.675" thumbnailSource="MoonlightInstall_46.675.jpg" title="Launching%20a%20media%20player%20in%20Moonlight%20for%20first%20time" />
  14:         <chapter  position="48.334" thumbnailSource="MoonlightInstall_48.334.jpg" title="Microsoft%20Media%20Pack%20(codecs)%20prompt%20for%20install" />
  15:         <chapter  position="51.249" thumbnailSource="MoonlightInstall_51.249.jpg" title="Media%20Pack%20EULA" />
  16:         <chapter  position="60.051" thumbnailSource="MoonlightInstall_60.051.jpg" title="Re-launch%20media%20player%20with%20Media%20Pack%20installed" />
  17:         <chapter  position="71.010" thumbnailSource="MoonlightInstall_71.010.jpg" title="HD%20media%20playback%20via%20Moonlight%20on%20Linux" />
  18:         <chapter  position="72.490" thumbnailSource="MoonlightInstall_72.490.jpg" title="Fullscreen%20mode" />
  19:         <chapter  position="76.138" thumbnailSource="MoonlightInstall_76.138.jpg" title="Bubblemark%20application%20on%20Moonlight" />
  20:       </chapters>
  21:     </playListItem>
  22:   </playListItems>
  23: </playList>

This sample above represents a single media file with chapter markers.  The bare minimum for a single media URI would be:

   1: <playList>
   2:   <playListItems>
   3:     <playListItem mediaSource="MoonlightInstall.wmv"></playListItem>
   4:   </playListItems>
   5: </playList>

So if you have a streaming URI (i.e., mms://mysite.com/live-baseball-game.asx) you would use this playlist structure:

   1: <playList>
   2:   <playListItems>
   3:     <playListItem mediaSource="mms://mysite.com/live-baseball-game.asx"></playListItem>
   4:   </playListItems>
   5: </playList>

and then in your HTML page you could have something like this for the full implementation (noting to use the appropriate width/height for your needs):

   1: <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
   2:     <param name="source" value="MediaPlayerTemplate.xap"/>
   3:     <param name="onerror" value="onSilverlightError" />
   4:     <param name="initparams" value='autoplay=True,autoload=True,enablecaptions=True,muted=False,stretchmode=0,displaytimecode=False,playlist=&lt;playList><playListItems><playListItem mediaSource="mms://mysite.com/live-baseball-game.asx"></playListItem></playListItems></playList>' />            
   5:     
   6:     <a href="http://go2.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;">
   7:          <img src="http://go2.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/>
   8:     </a>
   9: </object>
  10: <iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe>

It is important to note that if you know the other parameters like framerate, etc. you should provide as much information you can for the playListItem node, but I’m just noting the bare minimum above.

Can I do this in code?

Yes, if you were using the media player in code you can still use this method in either XAML as noted in a previous post of mine or in code using something like this:

   1: public Page()
   2:         {
   3:             InitializeComponent();
   4:             Loaded += new RoutedEventHandler(Page_Loaded);
   5:         }
   6:  
   7:         void Page_Loaded(object sender, RoutedEventArgs e)
   8:         {
   9:             ExpressionMediaPlayer.MediaPlayer mp = new ExpressionMediaPlayer.MediaPlayer();
  10:             mp.Width = 800;
  11:             mp.Height = 600;
  12:             ExpressionMediaPlayer.PlaylistItem playListItem = new ExpressionMediaPlayer.PlaylistItem();
  13:             playListItem.MediaUrl = new Uri("mms://mysite.com/live-baseball-game.asx");
  14:             mp.Playlist.Add(playListItem);
  15:             LayoutRoot.Children.Add(mp);
  16:         }

I suspect people would not be using the code concept as much but I just wanted to point it out here.

Summary

So having the MediaPlayerTemplate.xap file is really all you need.  Anything else can be sent as parameters either via the object tag, the XAML control or in code.  This enables being able to really re-use the template you desire without having to run an encoder job just to get the template and change the code.

Hope this helps!

| Comments

I’ve seen this issue a few times with people using the Manage Videos portion of Silverlight Streaming to directly upload a video file to be hosted.  Now with direct endpoints to the WMV files I’m seeing it a bit more.  Let me see if I can shed some light on this situation.

First, there is a distinction between uploading an application to Silverlight Streaming versus just a video.  What I’m going to discuss here is working with video only uploads.  If you didn’t know, you can directly upload just a video and Silverlight Streaming will host that file and create a Silverlight player experience for you as well (if you want it).

Okay, now on to the issue.  It is important to note that there are specific size limitations of videos with Silverlight Streaming services.  If you are trying to go beyond those size limitations your issue could be that right away.  The video file size must be smaller than 105MB.  Moving on…

Some of you may have attempted to upload a video and then directed to the page that shows the video processing and seen a “Video cannot be processed” message. 

Your issue could be related to what I’ll explain here.  It’s a bug.  We released the Silverlight Streaming transcoding (upload video turnkey only) service when Expression Encoder 2 was not yet released.  When Encoder 2 shipped, we realized that it wasn’t playing nice (the outputs rather) with the transcoding service.  We have to fix this and are working on it.  If you are taking a video source, running it through Expression Encoder 2 and then trying to upload that resulting video, you may be hitting this issue.

One thing to note, is that the “upload video” is a transcoding service.  So if you already have a VC-1 (or Silverlight capable) media format WMV, there really is no need to use the upload video portion.  You already have a high-quality encoded format and don’t need to transcode that again.  So how do you get it up there if this issue exists?  A few ways.

Option 1 – Upload an Application with a manifest

You can package the video file up with an application and use the Manage Applications functionality to upload that content.  You can use one of the Encoder templates if you’d like as well.  Even though you may not need the extra files, that is okay, because you can still have an endpoint to your WMV if that is what you want.  Since we don’t have the Silverlght Streaming Publish plug-in for Expression Encoder 2 complete yet (it is coming), here is a workaround on how to create those packages.

Option 2 – Upload the file direct with the API

While maybe not flexible for some, you can upload the file as an application directly using the API which doesn’t require a ZIP format for this purpose.  More information on the methods and API you would need can be found here.  The API is a WebDAV-based API for managing applications.

Option 3 – Name your WMV file to ‘video.wmv’ and upload as an application

Before you do any operation rename your file to ‘video.wmv’ and then go to the Manage Applications area of Silverlight Streaming.  Create a new application and give it a name, then in the next screen upload the ‘video.wmv’ file you just renamed.  After completion you can go to the Manage Videos section of the administration site and see your video.

We understand this may be a problem for some of you and are doing our best to address it as soon as possible.  Please note this is only an issue for Expression Encoder 2 file outputs that are attempting to be uploaded via the Silverlight Streaming transcoding service (aka Manage Videos) section.

Hope this helps!

| Comments

while preparing for the code trip, we have several 'on-board' needs.  one of which is a quick method to get our content encoded for consumption by devices and frameworks (i.e., silverlight).  we want a smooth method so that we aren't boggled down with multiple tools opening and changing settings, cutting and pasting, etc.

so, inspired by my colleagues post about using workflow to automate, i set about the task.  we're going to be making several assumptions along our production, one of which is we know we'll have multiple video/audio sources and that there *will* be some post-edit being done.  but once we have that post edit completed, we'll want all videos to feel similar (size, quality, etc.) and encoded for multiple uses.  i've pretty much decided that there really are 3 formats that would suffice the world: WMV, MP4, MP3.  if we get all of these, we can accommodate most.  here's how i justify that:

    • WMV: we'll have standard (4:3) and widescreen (16:9) format for viewing offline as well as online via silverlight (we'll be using the widescreen online most likely).  we'll also have a Zune formatted version for quick updating.
    • MP4: itunes, ipod, mac viewing in both standard and widescreen formats
    • MP3: audio format beloved by all

so the first step is to tackle the how.  if you don't know, expression encoder has a command-line interface.  this is especially helpful for a few things, namely our batch processing (you can also save job files and send in a job to the command-line interface quickly).  so the first thing i did was wrap the input parameters into a windows workflow foundation activity.  luckily michael did a lot of this for me in his webcast :-).  it basically abstracts all the possible input parameters and enables you to optionally send them into the activity:

for the mp4 encoding i'm using a piece of software that also has an command-line interface.  this one isn't as flexible so given my two known encoding types i'm pretty much hard-wiring in some of the settings and only enabling the size parameters for alteration.

mp3 version -- let's get to that later.

now that i have my activities (one for WMV, one for MP4) in an activity library, i'm ready for a client tool.  for our purposes, we don't need a fancy GUI tool, so i settled for a command-line interface.  in my client i added a sequential workflow and then added my activities.  i re-used the WMV activity 3 times to alter the different settings and then use the output of them to feed into my MP4 activity (used twice).  the resulting visual workflow looks like this:

the input to the command line looks for a source WMV file, title, description, author, album.  these input parameters are sent as named parameters to the workflow activity:

var namedArguments = new Dictionary<string, object>();

namedArguments.Add("SourceFilename", args[0]);
namedArguments.Add("Title", args[1]);
namedArguments.Add("Description", args[2]);
namedArguments.Add("Author", args[3]);
namedArguments.Add("Album", args[4]);

which are then mapped to properties of the activities:

the activity libraries also expose a few other properties that i'm passing in to my commands.  for example, i want each video to have a bumper intro and then an icon overlay in the right location.  i'm able to pass in these parameters which then map to expression encoder properties.  i'm also able to tell it to make sure to letterbox content that isn't native 16:9 aspect ratio for the standard format encodings.  the result of these activities is that i have three WMV files appropriate for my use.  expression encoder also generates thumbnail images of a frame in each video.  i've not much use for them, so i added the last workflow code to simply clean up the jpeg images generate (delete them) from the output directory.

one problem i had was that expression encoder exposes a lot of properties but not for metadata individually.  i wanted to embed the appropriate metadata for the WMV files for the title, description, etc.  luckily there is one input parameter for encoder that i can append to my other custom ones, and that is "/Preset" which enables me to provide certain presets that will be passed in and here is where it allows me to make metadata a part of that preset.  the input parameter looks for a literal xml file so i have to create one.  i added the template as a resource in my project:

<?xml version="1.0" encoding="utf-8"?>
<Preset>
  <MediaFiles>
    <Metadata>
          <Item
            Name="Title"
            Value="{0}" />
          <Item
            Name="Author"
            Value="{1}" />
          <Item
            Name="Copyright"
            Value="2008, Microsoft" />
          <Item
            Name="WM/MediaCredits"
            Value="{2}" />
          <Item
            Name="Description"
            Value="{3}" />
          <Item
            Name="WM/AlbumArtist"
            Value="{4}" />
          <Item
            Name="WM/AlbumTitle"
            Value="{4}" />
          <Item
            Name="WM/Genre"
            Value="Podcast" />
          <Item
            Name="WM/Year"
            Value="{5}" />
        </Metadata>
  </MediaFiles>
</Preset>

and then when the user executes the command-line interface, i take their input, merge it with the xml here and output a temporary xml file that is then passed into the named parameter dictionary for the workflow activity.  when no longer needed it is cleaned up (on the workflow completed event handler).  now my WMV file is complete with formats and metadata.

for the MP4 format i chose to use the resulting output of the WMV file and do a single pass there.  the settings for the tool weren't ideal for adding overlays, etc. so using the resulting WMV file and same bitrates i'm just passing in the resulting WMV and creating two MP4 formats.  boom.  done.  the metadata actually *was* parameters i could send into this tool, so it was easy to ensure that metadata was in there.

now, on to the MP3 format.  sigh.  what i need is a tool that will enable me an WMV or MP4 input and extract the audio-only track into an MP3 file.  i found all sorts of tools that will do this, but none that can be automated from a command-line.  this is my last resulting automation problem for now.  if anyone has tips on how to do this, i'll send you a prize :-).

now on to decisions.  while we'll have several formats to offer viewers, we also want to have feeds with enclosures for readers.  that brings us to a decision.  podcast formats for enclosures only enable one enclosure.  so, dear reader, what do we choose?  i figure we offer a WMV, MP4 and MP3 feed uniquely...but then which format do we supply?  is this a lame question?  the widescreen will be the best quality, but will it render okay on all devices/readers?  what do you choose?

anyhow, a fun little project i finished (except for the MP3 -- prize awaiting) and thought i'd share how it is accomplished.  one little command "encodepipe.exe <file> <title> <desc> <author> <album>" and a few short minutes later i have all the formats i need.  the next step is to automate upload to a content delivery network so i don't have to pick and choose uploading!

we just posted the schedule for our trip, so if you want to subscribe to the feed to be notified when we'll start putting out some content, that would be cool.  real-time updates via twitter as well.  see you on the road!

| Comments

i just put up another podcast video of how to "cheat" at creating a media player for silverlight.  have you been looking at some of these media experiences with all their fancy buttons and dvd player-type overlays, etc. but didn't want to take the time to code your own?  well, you don't have to :-) (man that sounds like an infomercial)

in this podcast i demonstrate using expression media encoder as a tool that will essentially generate stub code for you.  now keep in mind that expression media encoder itself generates some pretty kick arse templates that may perfectly suit you.  but perhaps you want a player that has more branding or a mix of certain elements, etc.  well, still use expression media encoder for this.  let it output the template and then just change the xaml! 

after you watch the podcast (subscribe links on the left panel of my web site if you are reading this in a reader), you'll hear me reference certain named elements for key function points of the player code that is generated.  i said i'd call them out here and that is what i'm doing :-).  these refer to the named elements in the xaml.  they could be canvas elements/groups or objects themselves like a rectangle.  as long as they are named specifically the code should work.  here's a list of the most popular that i've used and the heirarchy of any children objects they should have.  the names themselves are in bold, everything else is just description:

    • VideoWindow - this is the key element to display the media and must be a MediaElement node.  you can add clipping masks, etc. (as i show in the video), but you must have at least one MediaElement with this name
    • PlayPauseButton - the grouped canvas of your play and pause buttons. named this way, the logic is already there to handle certain functions if you don't provide additional animations/timelines (like hide/show).
      • PlaySymbol - the symbol for the actual play button
      • PauseSymbol - the symbol for the actual pause button
      • PlayPauseButton_MouseEnter/MouseLeave/MouseDown - i'm only going to put this here once, but it applies to most of the other elements like StopButton and MuteButton, etc.  if you have a timeline named these, it will fire, if you don't some default actions will occur.
    • StopButton - the symbol for the actual stop button
    • Timeline - for displaying the playing progress of the media
      • TimeSliderDecoration - the element that shows the full progress
      • TimeSlider - the progress growing metere
      • TimeThumb - the arrow/object, etc. that shows the point in the progress and the user would drag to adjust the position
    • VolumeSlider - the elements making up the volume function
    • VolumeThumb - the arrow/object that shows the position of the current volume and the user would drag to adjust
    • VolumeUpButton/VolumeDownButton - if you were to use buttons for volume instead of a slider
    • MuteButton - self explanatory
    • CurrentTimeText - displays the time progress of the media element
    • ChapterArea - the area that would display the markers in the media file (dvd-style playback)
    • FullScreenArea - the full screen experience root node

there are, of course, more elements to mess with and i'd encourage you to look at one of the more advanced template outputs and start sniffing around to see what you find.  the cool thing is that you don't have to have all of them.  you'll notice in the podcast that i only put 3 elements on there and there are no errors.  the output code handles if an element is there or not for you.

i hope this helps get you started on creating great media experiences with silverlight and expression sooner!  if you want the sample player xaml that i used in the podcast, you can download that here.