Thursday, March 25, 2010

Get the System Uptime for a Windows Machine

From a command prompt type:
net stats srv
Look for the line that says "Statistics since"

More info:
http://support.microsoft.com/kb/555737

Friday, March 5, 2010

FFMPEG Settings for H264 on IPhone

Took me a coupe hours today to get this to work. First I tried to compile FFMPEG from source. This appeared to work but after a couple hours of it not liking the settings I was using I finally downloaded a Win32 binaries from here:
http://tripp.arrozcru.org/

Here's the command line I used to convert a 704x544 AVI. You'll probaby need to adjust some of the size settings for you're own application.

ffmpeg -i "Rick Astley - Never gonna give you up RICKROLL.avi" -vcodec libx264 -b 1500k -s 480x368 -acodec libfaac -ab 128k -ar 48000 -f mp4 -deinterlace -y rick-out.mp4


UPDATED 7/24/2011: updated 128kb to 128k per Daniel's feedback in the comments.

Here's the FFMPEG command line reference:
http://ffmpeg.org/ffmpeg-doc.html

Note for the IPhone the following limits:
H.264 video, up to 1.5 Mbps, 640 by 480 pixels, 30 frames per second, Low-Complexity version of the H.264 Baseline Profile with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats;

If you're getting this error "error while opening encoder for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height", you probably didn't compile FFMPEG correctly. Try downloading it from the website above.

H264 is currently my video format of choice since it works on the following:
  • IPhone
  • Silverlight
  • Flash
  • HTML5 in Safari (4+) and Chrome
  • Quicktime
Note to FFMPEG. Figure out a way to make it easier to get Win32 binaries with all the bells and whistles. Using your product is frustrating enough without having to compile it with a million third party libraries.

Sunday, February 28, 2010

.NET LINQ Bug - Specified cast is not valid.

I ran into this nasty little bug last week. It didn't show up on my local work station running Windows 7 but it showed up once published to our development server running Windows 2003 Server. It would happen when inserting a record to the database after calling "db.SubmitChanges()"

The root cause was having a "non-integer" key which I rarely use, but this instance was special. I was able to fix it immediately by deleting the association in the LINQ designer. I was lucky because so far I don't need this relationship defined in LINQ.

After the immediate fix I noticed our development server was missing some patches, so I put in a request to have those installed. I haven't yet tested if that fixes the problem but I suspect it will. Also there is this hotfix that may work:
https://connect.microsoft.com/VisualStudio/feedback/details/351358/invalidcastexception-on-linq-db-submit-with-non-integer-key

Hope this saves someone else some time!