I recently spent some time messing with the Microsoft DirectX SDK with a view to making a simple video player. I wanted to show a video in the main window, with two smaller preview windows looking t+2 and t+5 seconds out respectively.

After evaluating the APIs for a couple of hours, the scope of my project had grown inordinately. I decided I wanted to write a DirectX Media Object (DMO) to do scene detection, embed it in the DMO Wrapper to drop it into my filter graph as a transform filter. I also realised that such a project was going to take weeks.

At this point I started looking at alternatives.

AviSynth is a scripted language for processing video. AviSynth scripts (.avs files) can be played in common media players (MS Windows Media Player, Media Player Classic, Mplayer). I'd used AviSynth for video processing before, but I realised the Internal library of filters can be used to perform a much wider array of tasks.

The following script loads the main video, creates two small time-delayed preview panes, then sticks them all together to produce a single clip.

Create main window


main = DirectShowSource("test.wmv")

Create two sub panes, half resolution and time delayed (by 250 and 500 frames respectively).


ahead10 = DirectShowSource("test.wmv").reduceBy2().Trim(250,0)
ahead20 = DirectShowSource("test.wmv").reduceBy2().Trim(500,0)

Glue the two sub panes together to form a single clip which is the same width as the main window


mosaic = stackhorizontal(ahead10, ahead20)

Glue the preview clip on to the same window


final = stackvertical(main, mosaic)
return(final)

AttachmentSize
test.avs330 bytes