¶VirtualDub 1.6.12 released
VirtualDub 1.6.12 has been posted to SourceForge. It took a long time primarily because I spent a lot of time reworking the timing logic in the capture module and going back and forth with some users who were willing to test internal builds with varying balances of breakage and functionality. Special props go to the users with handles Moitah and i4004 on the forums, who graciously spent a lot of time telling me that my resynchronizer sucked and that giving me hard data as to what was going on. Because the resynchronizer was quite heavily reworked, and because I sneaked in several features, both capture and non-capture, this build is marked as experimental.
One notable feature that I snuck into this build is that you can now capture from a DV capture device that uses the MSDV driver through DirectShow. Previously this didn't work because DV data comes in as type MEDIATYPE_Interleaved rather than separate MEDIATYPE_Video and MEDIATYPE_Audio streams; I don't own a DV camcorder, and the scenery around me is far too boring to warrant me getting one, so I didn't have a way to look at the filter graph and fix this. Well, as luck would have it, when I visited my older brother John over the holidays I was able to scam^H^H^Hborrow some time with his DV camcorder to develop against and add the code to insert the DV splitter into the graph. It isn't terribly tested (implementation and testing time approx. one hour), you can't shuttle the tape or control via timecode, and it only records type-2 DVs, but it's a little better than before, at least.
Capture rework details
I was about to release this a few days ago, but I decided to do some long-duration capture testing instead. Which was a good thing, because I managed to watch a full season's worth of Alias DVDs, and in capturing them off my PS2's output — testing files deleted immediately afterward, of course — I found two huge bugs in the capture module at the last minute. One was that I forgot to restore the SEH chain properly in the audio resampler when I borrowed the stack pointer for an eighth register (hey, if I'm going to write assembly language, I might as well go full bore), and the other is that the crash trap I had in the capture callback was trapping C++ exceptions too. This meant that errors during the capture like disk full errors sometimes got reported as internal errors or simply crashes/hangs.
Agent Bristow saves the day again.
It turned out that there was a nasty bug in the audio resampler that caused it not to account for a non-zero start time at the beginning of the video stream. Also, the algorithm I was using to determine the relative start offset between the audio and video streams could become progressively unstable over time with regard to noise sensitivity. The current build now has a semi-haphazard set of PID controllers and filters to control audio and video timing that would probably make an EE professor cringe, but seems to work better than the old code. In addition, the default is now to only determine the relative latency from the starting several seconds of the stream, and if that still doesn't work, the relative latency can be manually set.
Now, one thing to be aware of with regard to the audio resampling in the capture module is that it does not guarantee zero dropped/inserted frames. Some are of the opinion that such a resampler should mean no frame aberrations, but the problem is that any timing glitches in the video stream that are not handled by frame drops or inserts must be fixed by correspondingly wonking the audio stream in speed and pitch, which can be equally noticeable. Although the video timing correction option will now try to globally change the speed of video to account for a lower or faster than expected frame rate, it will still emit drop/insert commands when it detects holes in the input. (There was a really badly fragmented portion of my hard drive during my tests, so this scenario was well-tested.) However, I did rework the code so that disabling drops or inserts no longer causes a sync error — the timing controllers can now see a video timing error of more than one-half frame. I wouldn't recommend turning off frame inserts, but turning off frame drops is now reasonable if your video input is stable.
As usual, contact me by email or the forum if you have problems and suspect an issue with the resampler.
I've seen some white papers from Microsoft recommending that you should eschew use of RDTSC for high-precision timing and use QueryPerformanceCounter() instead, for better stability on multicore systems. Ha. Hahaha. Avoiding RDTSC is fine, as many mobile CPUs, and even some desktop CPUs, will run their time stamp counter (TSC) at varying rates depending on load and there is no really good way to compensate for this if you want time (vs. clock cycles). Don't be so quick to switch to QPC, however. For one thing, on Windows XP x64 Edition, some AMD64 systems have a bug in their ACPI implementation that causes the time base returned by QPC() to run at half speed. Even worse, though, the time source used by QPC is frequently buggy, and when I was doing tests with VirtualDub's video capture module I saw several instances where the QPC time base would suddenly jump forward several seconds ahead when the audio and video clocks were stable. Thus, 1.6.12 no longer uses either RDTSC or QPC for capture timing estimation and now uses timeGetTime() with the system clock raised to 1KHz. The change in the system clock frequency also increases precision of video timestamps from some capture drivers under NT/2000/XP, a feature that was accidentally lost from the 1.5 capture module.
I snuck in a few miscellaneous goodies, such as the performance settings saving (only six years late) and a scaling crop dialog. There are also now script commands and command-line switches that allow you to use VirtualDub to glean information from a video file, although rather inefficiently:vdub "e:animeAMG-OP.MPG" /cmd "VirtualDub.Exit(VirtualDub.video.width)"
I also added optional vsync support to the display panes, but now I'm itching for deinterlacing too.
Build 24259 (1.6.12, experimental): [January 4, 2006] [features added] * Performance settings are now auto-saved. * Cropping dialogs now auto-scale video that is too large to display and use a dashed crop border for better visibility. * Added /cmd flag to quickly invoke a script command from the command- line. * There is now an option to avoid tearing in the video display panes. * Script: Added VirtualDub.Exit(int) command to end the program with a specific error code. * Script: Added VirtualDub.subset.length property for current length of subset in frames (timeline). * Script: Added VirtualDub.video.length property for current length of source video in frames. * Capture: The list of statistics displayed in the info panel has been expanded and can be filtered from the Preferences dialog. * Capture: Modified option to adjust video timing based on drift from ideal stream timing rather than real-time. * Capture: Reworked video timing interpolation to be less sensitive to discontinuities in the system timer. * Capture: "Autoincrement filename" option now automatically skips over existing files as well. * Capture: Added timing graph to visualize behavior of resync engine. * Capture: Timing logs, if enabled, are automatically saved at the end of capture. * Capture: Increased precision of frame period selection from 1us to 100ns to reduce frame dropping at device level when using DirectShow drivers. * Capture: Capture from DV sources to type-2 DV AVI using the DirectShow DV driver is now supported. * Capture: Backspace now works when entering channel numbers. [bugs fixed] * Increased precision of processing fps estimate. * "Space" is no longer listed as an accelerator for "abort dub" since it doesn't work as such when rendering to disk. It still works for preview. * Fixed job control re-enabling itself if a menu command is chosen while a job is running, leading to possible reentrancy crashes. * Clearing the current job list or loading a new one while a job was in progress led to a crash. * Invalid MPEG-1 layer II frame headers display a slightly less confusing error than "internal error." * Renamed "use internal MJPEG decoder" in AVI extended open options to "use internal decoders," since it happened to force the internal DV decoder too. Added a sticky option in Preferences for this. * Filters were receiving inconsistent output frame numbers when using input preview or saving with a starting offset. * Fixed crash when crop rectangle reduced filter input to smaller than 1x1. * Fixed crash when using deinterlace filter in "duplicate field 2" mode. * Fixed broken cropping in some modes of deinterlace filter. * Manually stopping a save operation will now also stop a running script, and cause a command-line task to return with an error code. * CLI tool didn't work properly when path to vdub.exe/vdub64.exe contained spaces. * Removed some hard-coded limits on frame rates in the Frame Rate dialog box. * Fixed minor memory leak when plugins fail to load. * Fixed a case where an I/O error on the output AVI file could cause a hang instead of an error to be displayed. * MPEG-1: Fixed yet another rare frame decoding error when seeking randomly in the timeline. * MPEG-1: Fixed crash when opening file with all CPU optimizations forced on. * D3DFX: vd_tvpcorrect, vd_t2vpcorrect, vd_tvpcorrect2, and vd_t2vpcorrect2 constants were computed with U and V sizes swapped. * Capture: VFW devices sometimes didn't display overlay properly with full- height frame sizes and consumed additional CPU due to the preview hook being left enabled. * Capture: The Video File (emulation) test capture driver is no longer a candidate for being saved as the driver to auto-start the next time capture mode is entered. * Capture: Unicode filenames are now displayed properly in the title bar. * Capture: Fixed 0.03% sync error when using NTSC frame rates. * Capture: Fixed random crash when modifying filter parameters with a WDM capture driver active in accelerated preview mode. * Capture: Fixed keyboard focus on startup so that entering channel numbers works again. * Capture: Fixed instability on reporting errors when audio resampler is enabled. * (AMD64 only) Fixed crash when opening a Motion JPEG file with no MJPEG codec installed. Note that the internal MJPEG codec still isn't implemented for this platform. [regressions fixed] * Capture: Fixed normal errors sometimes being reported as internal errors.