Expression Encoder bug

I've been working on getting the excellent video sharing site Video.Show up and running on my home server for easy sharing of home videos with friends and family. Video.Show was developed by Vertigo software as a sort of blueprint for implementing silverlight applications, but I think it's pretty cool as-is.You can grab it from codeplex and see for yourself.

In order to get my videos ready for the site and uploaded to my silverlight streaming account, I have a simple command line application that scans my home video directory, adds the video to the database, and then kicks off the processing of it. The Video.Show implementation has most of the mechanics worked out including launching the Expression Encoder command line.

Things were working just dandy, videos getting processed and uploaded and then appearing on my site. Except some were causing the expression encoder to throw an unhandled exception. Some were for valid reasons - for example, I didn't have the required codec installed for some videos. (Why an unhandled exception is necessary for that is beyond me. It seems like a pretty common scenario). Anyways, I still had a set of videos that were causing the encoder to still throw an exception, and these were videos of the same type as others successfully getting processed.

Digging deeper I found that for the videos in question the command line encoder was throwing the following exception:

Unhandled Exception: System.ArgumentOutOfRangeException: The value must be great er than or equal to zero and less than the console's buffer size in that dimension. Parameter name: left Actual value was -4. at System.Console.SetCursorPosition(Int32 left, Int32 top) at Microsoft.Expression.Encoder.ConsoleEncoder.OnEncodePropChange(Object send er, PropertyChangedEventArgs e) at Microsoft.Expression.Encoder.PropertyChangedImplTarget.FirePropertyChanged Event(String strName) at Microsoft.Expression.Encoder.PropertyChangedImpl.Dispose() at Microsoft.Expression.Encoder.EncoderBase.b__3() at Microsoft.Expression.Encoder.MessageManager.SendToUIThread(MethodInvoker i nvoker) at Microsoft.Expression.Encoder.EncoderBase.FinishItem() at Microsoft.Expression.Encoder.Encoder.EncodeItem(ItemData item, PublishItem Info& publishedItem) at Microsoft.Expression.Encoder.ConsoleEncoder.Encode() at Microsoft.Expression.Encoder.ConsoleEncoder.Encode(ConsoleJob job) at Microsoft.Expression.Encoder.XmlCommand.Execute() at Microsoft.Expression.Encoder.Program.Run(String[] args) at Microsoft.Expression.Encoder.ProgramStarter.Run3[T](String[] args, RunAppH andler`1 runApp) at Microsoft.Expression.Encoder.ProgramStarter.Run[T](String[] args, RunAppHa ndler`1 runApp) at Microsoft.Expression.Encoder.Program.Main(String[] args)

I was still sort of baffled. I noticed that the expression encoder console application outputs to the console the percentage complete of the task, which seems perfectly logical to me. With this video though, it wasn't fitting on one line in the console window, because the file name for source and destination were big, so it looked like this:

Encoding: Playing-before-swim-lessons.wmv -> Playing-before-swim-lessons.wmv 0.1
%

Note the way the percent wrapped to the next line. I changed the properties of my command window to change the width from 80 to 100, making it so that the status would appear on one line, and what do you think happened?

it worked!

So there is a bug somewhere in the calculation of how to output the status line when dealing with wrapping.

Hopefully this helps someone else out.

No Comments