Came across an old project where I had to solve this need, and thought I'd archive it on here for search engine purposes. This can be useful for scenarios like corporate training video directories, where you let the trainers upload videos and it automatically creates a thumbnail for clients to browse in a webapp, for example.
The first thing you'll need is an interop assembly to allow you to use the DirectShow COM objects from within .NET. You could either add a COM reference to your project, or better still use the command line tlbimp.exe framework utility to create the interop - the latter is preferred, as you'll want a strongly named interop assembly, which you can accomplish by specifying a keyfile with the tlbimp.exe /keyfile: parameter (specifying a key file that you created with the sn.exe framework utility). Add the newly created interop assembly as a reference in your project - barring specifying parameters otherwise, it'll be called Interop.DexterLib.dll, and once referenced will appear in the references as, of course, Interop.DexterLib.
There are a couple of structures that we need to define as we'll need them to communicate with DirectShow.
[StructLayout(LayoutKind.Sequential)]
struct element_RECT
{
public int left;
public int top;
public int right;
public int bottom;
}
[StructLayout(LayoutKind.Sequential)]
struct element_VideoHeaderInfo
{
public element_RECT rcSource;
public element_RECT rcTarget;
public UInt32 dwbitrate;
public UInt32 dwbiterrorrate;
}
The following code presumes that a couple of variables exist (for instance as parameters to a function)
In your extraction function, create a MediaDet instance, set the source video file path via the Filename property, and search for a video stream (there can be multiple streams. We search for a video stream by looking for one identified by the GUID 05589f80-c356-11ce-bf01-00aa0055595a). The following presumes that the unit has a using Interop.DexterLib; in it.
MediaDet mediaInt = new
Interop.DexterLib.MediaDet();
mediaInt.Filename = videoFilename;
bool videoStreamFound=false;
_AMMediaType oMediaType = mediaInt.StreamMediaType;
System.Guid videoHeader = new
System.Guid("05589f80-c356-11ce-bf01-00aa0055595a");
int streamCount = mediaInt.OutputStreams;
for (int counter=0;counter< mediaInt.streamCount;
counter++)
{
mediaInt.CurrentStream = counter;
oMediaType = mediaInt.StreamMediaType;
if (oMediaType.formattype == videoHeader)
{
videoStreamFound= true;
break;
}
}
Notice that we're setting the CurrentStream property on each iteration, so when a video stream is found, the MediaDet object will already have it selected as the active stream.
If we found a video stream in the file, retrieve the properties of the video frame so we can grab a full frame, and then direct it to save a frame at the specified time offset to our specified destination file.
if (videoStreamFound)
{
element_VideoHeaderInfo *header =
(element_VideoHeaderInfo
*)(oMediaType.pbFormat.ToPointer());
mediaInt.WriteBitmapBits(
videoOffset,
oHeader->rcSource.right-oHeader->rcSource.left,
oHeader->rcSource.bottom-oHeader->rcSource.top,
bitmapDestination);
Marshal.FreeCoTaskMem((System.IntPtr)oHeader);
}
Now ensure that the COM object is predictably freed now.
Marshal.FinalReleaseComObject(mediaInt);
Note that there are pointers (scary!) used above, so this code needs to be compiled with /unsafe. Don't worry - It's safe.
This technique works for pretty much any non-DRM multimedia file that contains a video stream, for which there is a DirectShow compatible codec installed on the system.
One note about this entry - I would use the PRE element and layout the code better, however Radio Userland exhibits a trait that drives me nuts with software: It is too clever, in a way that is often very detrimental. From removing attribute formatting, to completely reformatting PRE blocks, to auto-linking links that it shouldn't link, I seem to spend too much time trying to avoid it's "helpful" logic. This seems to be the case with too much software out there.
"It appears that you're writing a letter..."
Tagged: [.NET], [NET], [Software Development], [Programming], [Software-Development]
I was just doing a bit of work in the Opera web browser, typing some information into a web app's text box, when I accidentally de-selected the input box in the process of jumping between applications. On my next keystroke the interface suddenly went to an archaic layout. It looked like something rendered in Netscape 3.
I had no idea how I did this, it was completely unwanted, and the impact was extremely disruptive. Closing and restarting the application didn't remove this sticky setting, and randomly (and systematically) selecting what I thought would be the accidental shortcut keys yielded no solution.
Now I had to waste time finding, and then turning off, a feature that I didn't want in the first place.
This brings to mind a couple of user interface issues:
While there is a minority of users who override site stylesheets with their own, justifying the feature in Opera (though I'm not convinced that it should be an everyday keystroke like Shift-G by default), this brings me to another user interface observation.
Drawing from personal experience, I worked on a project quite a few years back where one developer insisted upon absolute flexibility in the user interface - Every toolbar had to be movable and dockable anywhere, every sidebar item drag and droppable, every menu item configurable, every UI skinnable. It was a nice cop out for us because we didn't really have to put too much thought into the interface, and could always justify it with the stock "the user can configure it how they want". Stick some more toolbars, statusbars, and panels in there because the user can clean it up according to their own needs, the logic went.
In the field, about 99.9% (more likely 100%) of the time that people discovered this functionality it was to their detriment. Like the taskbar-stuck-perilously-on-the-side-of-the-screen on your Aunt's Windows 95 computer, it was just something that happened by accident, and they didn't know how to get it back the way it was: No one (or very few) did it on purpose, but there it was terrorizing every computer user.
The first step of any support call for our app was to determine in what innovative ways the user managed to mess up their user interface. After getting a visualization of the sidebar on the bottom, the icons all on the background, the toolbar on the right, some critical toolbars hidden, with the menus all jumbled and the icons all removed, the cleanup began.
On the next release a menu item to reset the interface to the initial defaults was added, and on further releases most interface flexibility was removed (or alternately made much more difficult to do - you had to be dedicated and informed if you really wanted to change things. Someone is much more likely to unintentionally hit Shift-G with no input box focused than they are to accidentally go into the advanced preferences and set an option).
The moral of the story is that customizable interfaces are seldom beneficial, and instead function as a lazy, non-committal cop-out by the developers and designers of the application.
Even the most fundamental element of our user experience - windowing - merits some analysis: Apart from Winamp and Media Player, how often are apps in any configuration other than maximized or minimized? I run with dual-monitors, and 99% of the time one or both of them has a full screen application on them. My "windowing" is alt-tabbing through full-screen windows, and I copy data between apps using copy/paste, or, where dragging is necessary, via the taskbar.
Tagged: [Software Development], [Programming], [Software-Development], [Usability]
I've pursued various Microsoft certifications over the years, starting with the MCP, and then acquiring an MCSE and MCDBA.
My motivation in pursuing these certifications was that they served as a destination of sorts, motivating me to learn products and technologies to a breadth and depth that I wouldn't have otherwise.
The knowledge has proven very handy: Even when I serve in a development/design role (especially when I serve a development/design role) the information gained is critical in making appropriate decisions. When I serve leadership and advisory roles, again I'm glad that I spent the time going through every esoteric option and alternative, because the knowledge does help to head off misdirected initiatives and wasted effort.
For those who think "Oh, but I know all of it anyways. I am a Linux super-guru and thus I can achieve anything on the Windows platform with ease". I've heard this sort of boast before, and the results weren't pretty. Go to the Microsoft certification site and take some assessment exams - you might be shocked. The platform is absolutely huge, and it is remarkable how much of it doesn't gain our attention or focus, yet it can help us make better apps, and deploy better solutions.
"If you're a software developer and development manager, why did you get administrative type certifications?" some might ask. Very good question, and the answer is found in the paragraphs above - I dealt with the coding side all day every day, so I didn't see as much of an advantage focusing on an area that I know so well (basically it would have been hundreds of dollars for Microsoft to anoint what I'd proven amply in the field), while I (like most development focused people) didn't really pay enough heed to the platform side of things. Now that I am often called upon for platform consulting as well, it was a nice foundation to build upon.
Nonetheless, now that Microsoft has revamped their certifications, I've decided to upgrade to the MCTS: SQL Server 2005 along with the MCPD. I had hoped to get the MCTS out of the way, but it looks like the exam isn't available yet (despite a November 2005 timeline). Alas. Already it has encouraged me to focus on esoteria of SQL Server 2005 that would have gone ignored.
And for those who protest "But I don't have time! I'm a very busy person!": You could very well be running to stand still. It is an epic problem in this industry that tremendous effort is expended because people don't spend enough time on the skills side of things, focusing all of their attention on the application side.
If you're thinking of providing a demo or limited-use version of your software, pay for the bandwidth and host it yourself. It is an enormous waste of time for potential customers - not to mention that it's incredibly insulting - when you host at one of the big "make you follow 7 links, then sit in a queue, and then download a potentially tampered executable at a reduced speed" 3rd party file hosts that seem to be all the rage these days.
Bandwidth is relatively cheap nowadays, coming in at less than 8 cents a GB at many providers.
What does this have to do with social proof? Well if you host your demo or lite version at one of the aforementioned file hosts, my immediate presumption is that a very tiny percentage of users actually pay for the software: What else could justify such an abuse of clients?
Given this obvious conclusion, the power of social proof pushes me to lean against purchasing it either.
Enjoyable weekend, packed with Christmas parties and other holiday related events. What a wonderful time of year.
I don't normally do this, but since this is hidden in the personal category, what the heck: Surely everyone has seen this by now (I believe it's over 2 years old now). Amazing amount of planning and work (not to mention cost) went into that. They went big, and superbly kept some big-bang in reserve until the end. Amazing.
This is quite a humorous video.
On the more disturbing side are these and these. Apparently this has been going on for a while: An extremely talented motorcyclist ("GhostRider". Apparently the name is based on a comic) drives through congested urban streets and highways at absolutely insane speeds, darting between unpredictable traffic, capturing it all with several bike mounted cameras (along with coordinated "crew"). Most of these take place in Sweden, and apparently this is something of a trend there. [One individual insightfully commented that this was all inspired by an infamous scene from the French movie The Rendezvous, in which a hired, and apparently still mysterious, driver goes insanely quickly through the streets of Paris one morning, endangering pedestrians, other traffic, and himself as he disregards traffic lights and controls. See for yourself].
While I don't want to support that sort of activity (go crazy on the track, just don't put innocent people in harm's way for your fun - I'd love to have the real DVDs of these, but I'm not going to financially support it as a pursuit), I am in awe of the talent, and I am absolutely disturbed by the complete fearlessness: In a number of situations a driver making a last minute lane change would have resulted in certain death.
Actually that points out one of "GhostRider's" key talents, which is reading traffic (very, very rapidly). It is remarkable how many people have no ability to do this at even a much more liesurely pace. You know - those people who always seem to be speeding, yet they keep passing you over and over and over again (because they keep screwing themselves into dumb positions, particularly when they try passing on the right on 6 lane highways).
I think these fascinate me for the same reason that I enjoy F1 - extreme engineering (the devices featured are extraordinary pieces of engineering and perfection), risk, and extraordinary skill. These aren't a bunch of kids in Honda Civics with loud exhausts - they're obviously professional drivers and bikers to some degree, and the confidence and skill is extraordinary.
A lot of my work - both system consulting and software architecture/development - relies upon Microsoft technologies: Whether it's re-engineering a legacy system to take advantage of new SQL Server features for performance or functionality, overhauling a network infrastructure to leverage ActiveDirectory and the extensive platform security functionality, or developing a performant and scalable time-tracking application for an enterprise client, Microsoft is often a very important part of the equation.
Partly due to specialization (it's the tools we target), coupled with simply being the best choice in a lot of scenarios in our target market, we heavily rely on the Microsoft platform for ourselves and our customers. As a professional I can say with confidence that the platform is a secure, high performance, extremely scalable, robust one that compares very favourably against all competitors.
That wasn't always an accurate statement, though. Indeed, it is remarkable looking at the history of Microsoft and learning from their success: On paper it really is hard to believe that Microsoft maintained the market dominance that they did, and it's amazing that competitors couldn't capitalize on Microsoft's late entrance into a lot of markets, and their missteps in others.
Was Microsoft a master of timing, holding off on technologies and advances until the perfect time, or were they simply the beneficiary of a captive audience that was willing to wait however long Microsoft took, blind to the available alternatives?
I'll provide a couple of examples that I recall marvelling at as they occurred- these are hardly exhaustive, however I think it's a nice sampling.
I recall during my early courtship with the PC simply marvelling at how incredibly obsolete the platform seemed to be compared to competitors like the Amiga and the Mac introduced years earlier - from graphics capabilities to software to hardware: Everything about it seemed so backwards in comparison to the superior alternatives, yet customers stuck with it. This was the platform that Microsoft wed themselves to, so surely they would suffer as well, right?
Microsoft's insistence on legacy compatibility led to a platform that moved much slower than competitors - Competitors that had the liberty of just tossing it all out and starting from scratch with whatever whizz-bang feature the newest chips offered. Maybe they could run super-stable and super-fast, and offer the developers an elegant platform upon which to perform their magic...but could it run Commander Keen 1 through 3? Could it run that ancient text database app?
Of course it's easy to focus on the deficiencies and imagine that they wrote the whole story, but in reality the situation was much more complex. Windows, for instance, pioneered widely-used video card acceleration (I still remember that shiny new Diamond Speedstar 24x. 24-bit graphics, coupled with hardware acceleration of 3D primitives. It was good times running those benchmarks. Of course the Amiga fanatics will point out that it supported hardware acceleration, just as the STe featured a hardware blitter chip, but the interaction between acceleration and the GDI in Windows really set the bar), and Microsoft's push greatly accelerated the adoption of optical media. Windows For Workgroups brought inexpensive networking to a lot of shops (NetBEUI was imperfect, but it was an easy transition to TCP/IP), and Windows in general represented a "good enough" platform for a lot of users. Internet Explorer, for all of its ActiveX "holes" and CSS quirks introduced the rich web model that we rely upon today.
This all comes to mind as the x86-64 transition accelerates: More and more users are starting to switch to 64-bit capable systems, and the 2/4GB limits of our machines is actually becoming a rational limit among desktop users: Everyday users are shouldered against a limit that seemed almost theoretically large just a few short years ago.
Of course Microsoft has been releasing incomplete 64-bit options for years (for instance you could get a 64-bit version of SQL Server 2000 for the Itanium platform, barring a laundry list of exclusions and limitations, and way back with NT 3.1 Microsoft supported 64-bit processors, albeit in 32-bit mode). Now that 64-bit support is finally becoming a critical factor, Microsoft has a wide gauntlet of support ready, and is finally ready to deliver.
Once again when the market really cares, Microsoft is ready. For years some have been talking about the advantage of various operating systems, such as Linux, being availabile on cutting edge processors and 64-bit platforms. For years that has been paraded as an advantage to customers who continued to run their platform on a standard old x86-32 foundation. Yet now that those limits are being reached, and the platform needs to accommodate new levels of capability and performance, Microsoft is ready. Another deficiency overcome.
Looking at the platform now - the stability, security, and feature set of Windows 2003, a lot of it already existing in XP - it really does seem like a tremendous window of opportunity for the competition has passed: What used to be a crop full of delectable low hanging fruit is now a well protected enclave featuring armed guards.
If competitors couldn't make inroads before, how do they have a chance now? If Linux couldn't capture the desktop market against a monstrosity like Windows Me!, what chance does it really have against XP?
The most obvious answer is web applications - render the operating system irrelevant and you don't really have to compete.
Tagged: [Software Development], [Programming], [Software-Development]
How often did you use the scheduling functionality of your VCR to record your favourite television shows, decoupling yourself from the rigorous schedule imposed by the television networks?
The common answer, overwhelmingly, is never. Few bothered using the scheduling functionality, even when it would be beneficial to their quality of life.
This inspired endless jokes about the complexity of "programming the VCR". Even the few brave "wizards" who did bother scheduling recordings generally did so rarely: The hassle of managing tapes, manually setting schedule times, and then having the uncertain-quality result unavailable until completion simply wasn't worthwhile to most people. Many times it didn't work out, and they discovered that they actually recorded 8am instead of 8pm. Whoops!
Even the introduction of Guide+ - a system that allowed you to record a program by punching in a short code - changed the situation little: To many it still wasn't worth the marginal hassle.
The functionality to time shift was there, but few leveraged it.
This topic came up after becoming engaged in an interesting discussion about PVRs versus VCRs, and why the former is inspiring panic and behaviour changes among the television networks, while the latter was largely ignored. Consider that virtually every household in the West had one or more VCRs, yet only a very small percentage have a PVR today (though obviously it's a much greater percentage among the net savvy). Why the concern about functionality we've had for well over a decade?
The reason for the panic, of course, is that the seemingly minor usability and functional improvements of the PVR dramatically increased the usage and utility of the technology: Instead of rummaging for Guide+ numbers in the back of the newspaper, or worse - configuring start and end times manually - one simply pulls up an online listing, selects the programs they want, and selects to record them. The quality is superlative, it takes just a few moments, and they gain the added ability to quickly skip past commercials. Many choose to automatically record every new episode, saving even more time. To put the icing on the cake, there's no hassle dealing with the tapes.
simply reducing the complexity or number of steps marginally can lead to market dominance
There is a valuable lesson to be learned from this: Seemingly minor advances in usability can tremendously alter marketplace success (the VCR was, of course, a great success in marketplace saturation, but that was almost entirely on the merit of playback of pre-recorded content. Few used it to actually record content). Even when it seems like a marketplace need has been functionally satisfied, simply reducing the complexity or number of steps marginally - or reducing the barriers to entry - can lead to market dominance (or market creation). A PVR isn't just a VCR with a hard drive - It completely changed the equation.
Consider the software market: By all appearances it looks to be a saturated market - with a solution for every need - but the remarkable thing is that much of it remains completely unused and unadopted. There are countless domains where solutions sit collecting binary dust because the complexity or barrier to entry is too high.
Skype, in contrast, blazed a path of glory and achieved virtual overnight success, yet really it's just yet-another IP voice technology (like we've had since the mid-90s. Sure it added the distributed net, but that's a feature that is a marginal improvement at best). It offered a clear, usable interface, firewall avoidance, and a simple directory for finding the other person, and bam it is getting bought out for $2.6 billion - for doing what had been done by countless competitors in a seemingly commodity market for years before.
FogCreek software has had success simply taking some open source software and putting a pretty face on it, offering a small value-add (avoiding configuring your firewalls) - Making money charging money in a market that people thought was saturated with free alternatives. The web could really be considered a Gopher 2.0, but improved usability enough to be embraced by the everydayman. Bam, the webolution. HTML is absurdly trivial, yet the marginal usability advance of blogs are what made everyone a writer. CSS and JavaScript are both highly accessible technologies, and you can get started quickly by viewing the source of sites you like, again vastly accelerating the transition from initial exposure to actually doing something with it.
Even when targetting highly-trained professionals, immediate "usability" remains critical. Remarkably many of the successful back-end technologies are those that were easy to get started with.
Extraordinary to think that multi-year projects and massive web applications of tremendous scale were built on chosen technologies because they offered a painless, 10-minute getting started setup and tutorial - letting someone start pushing out code immediately - yet in talks with peers I've found that this is frequently the case. Indeed, I will admit to this irrational behaviour myself - several times I considered implementing a project in J2ME (targeting cell phones), but the hassle of setting up a J2ME development platform, and then the pertinent modules for the various phones, served as such a discouragement that I abandoned the project rather than wasting 4 hours dealing with that. In the longer term of a project it's completely irrational, yet it happens.
Of course much of the ASP development community evolved not because ASP was the best platform that was being chosen on merit, but rather because a lot of shops had a Windows NT box sitting there with IIS on it, and they started dropping ASP scripts on it (other languages, like PHP, required additional installations = more trouble). Soon enough these were ASP shops, even though it was almost accidental. Few of them really seriously evaluated the various alternatives.
Of course this was by design: Microsoft, who I spoke about earlier, understands this resistance to learning well. They have entered countless markets with seemingly inferior offerings (at least at first), but because it's there (Microsoft used to rely upon "everything on" by default) and it's easy to use, the marketplace adopts it. SQL Server is a fantastic database system (I personally believe it was one of the best, and is now the best with SQL Server 2005), but a lot of its growth came about largely because it was a trivial install with a simple, ultra-low barrier to entry GUI: Joe Developer installs it from the MSDN discs, prods it for a while, and soon enough he's building the enterprise data system on it. All because it was so accessible and easy to use [Of course many of those database don't use transactions (or they don't properly), and they host terrible schemas, but it got it used]. On the Windows platform a lot of admins did the "install everything" technique, and slowly they sorted it all out and utilized it. This was the way that Microsoft entrenched itself into corporate networks.
Contrast this with other areas where Microsoft hasn't followed this philosophy, and where the results have been much less positive - Even for critical back-end technologies like Biztalk and Sharepoint (both of which yafla provides solutions and consulting for), where you would think it would be soberly analyzed by experts over months of analysis before deployment (and thus requiring significant upfront configuration should be a non-issue), they often see little adoption simply because the install or initial configuration discourages fly-by investigation. Without the initial investigation there is no one to champion it, so it goes unused (despite being fantastic products).
There are countless examples of products whithering because the first install required 40 steps, and then doing the first "hello world" type of project was an enormous hassle. On the flip side a lot of questionable technologies and solutions have permeated largely because it was usable immediately, with little up-front investment.
If you make software products, ensure that Getting Started is as painless as possible, and advanced customization options are saved until the user has some experience with the product (literally it should install and configure everything, and start the user off with a Hello World template solution): Even if your customers will need to spend hundreds of man hours specializing it for their needs, they need to see something they can poke at and interact with almost immediately, giving them a sense of accomplishment to motivate them to continue on.
Once you've gotten the initial time investment, it's much, much easier to require a more involved understanding, and to demand that the user commit themselves to some educational time by the fireplace with the documentation.
We're a very impatient bunch these days, and this is critical if you want success.
If, on the other hand, you're looking at potential markets for software products, examine the usage patterns of PVRs versus VCRs - While the software world might seem full of existing solutions, really the field is wide open for usable solutions. Make an easier to use mousetrap and much of the world will beat a path to your door.
Tagged: [Software Development], [Programming], [Software-Development], [Usability]