Showing posts from August, 2021

Playing or Ripping a scratched DVD under windows: "just" add linux

DVDs from the library are often very badly scratched. This posts describes a software method that makes them work, though it's a lot of work. No disk resurfacing required.

I'm not sure if I just happen to have a bad DVD drive, but I'm having a lot of trouble playing scratched DVDs. VLC is usually my go-to media player but here it does the stupidest thing possible: when it hits a bad scratch it just gives up and stops playback, forgetting your location and giving you no easy way to retry or skip ahead. I don't remember it giving up like that in the past and wonder if something has changed at the OS level. But a quick search of the VLC database shows people complaining about this as far back as 10 years ago (bug status: won't fix, interestingly. so much for open source!!).

I've had mildly more success with an ancient media player called MPC-HC. It doesn't give up as quickly, at least. I've not found any perfect solution, and it may not exist, because the problem of reading a scratched disk is genuinely hard, and finding the next good spot on the disk is definitely slower than real time.

If you can't play the disk back in real time, how about ripping it at your computer's leisure? Once it's ripped the bad sections can be skipped in an instant leaving just a tiny glitch in playback that you might not even notice. This I've found to be nearly impossible with Windows software. I've tried the usual suspects: handbreak, makemkv, and dvdfab, but each give up at roughly the same place VLC does, or don't even manage to open the disk at all due to CSS DRM. There's one that seemed to do a decent job called AnyDVD HD, but it's trial ware and has a large *yearly* price. No thanks.

I wondered if maybe the Linux crowd had solved this problem: after all things seem to be much worse in the windows 10 world; I had much better success back in the WinXP days. Maybe Microsoft has intentionally crippled DVD playback? So I tried Linux Mint. Unfortunately the same methods and techniques didn't work any better here; VLC failed at the same location, and an GUI app called DVDBACKUP (which seems to use the same underling libraries as VLC) failed in the exact same spot. 

So now it gets complicated: you can do some "magic" under Linux that will definitely recover the scratched disk, skipping over the areas that are unreadable. If I didn't lose you at "you need to use linux" then definitely read on as it's not that many steps, AND you don't even need "real" Linux; running it inside a VM (like VMWARE player) is fine!


0) you need some software which your Linux distro probably didn't install by default but can be installed easily from the command line (copy and paste one at a time):

 sudo apt install vlc

sudo apt install libdvd-pkg

sudo apt install gddrescue

1) you need to run vlc to "unlock" the drive first, or some of the "read errors" are actually DRM inserted by the drive itself and will completely prevent playback of the resulting DVD/ISO. All you need to do is start playing the disc and then hit pause.

vlc &

2) Now you need to rip the disk using ddrescue, which does not have a friendly front end like dvdbackup but doesn't have dvdbackup's problem that it just gives up after a few bad scratches are found.

ddrescue -n -b2048 -K1M /dev/cdrom diskname.iso

The interesting parts of this command:

-K1M makes ddrescue skip a 1MB chunk of disk each time there's an unrecoverable disk read error; given the data rate of a movie that's not so much, and anyway ddrescue will come back and try again from the opposite end of the gap if you let it run long enough. If you don't use a large skip size, the disk drive/driver will eventually lock up and stop responding at all. is a file that tells ddrescue where it skipped, this is critical for the next point:

If the disk read rate ever gets really slow, you can control+c and start again by re-entering the command line above; as long as you have a map file ddrescue will know how to continue. If restarting the program doesn't help, try rebooting /restarting your VM, sometimes the dvd driver or firmware get into a bad place and stop working or work very slow. 

The resulting ISO can be played by vlc with no extra steps. I've successfully used this linux-based  method on disks that no commercial app under windows could rip (even though it was really a VM running under windows). In one example, the disk wasn't hugely scratched but it was enough to flummox makemkv and dvdfab. This took about 1.5hrs and the resulting disk had 98% of the data successfully recovered. If I had let it run longer I might have gotten higher; it's your choice.  I've also seen it fail, but when it does, the disk can't even be started using VLC; if you can get to the menu and start playing from the first chapter, this method seems to work. 

Of course there's no real magic: if the disk is so badly scratched that 10% or more can't be read there's no point. But if it's just deeply damaged in a few spots this method can skip over those damaged regions intelligently. 

Now, if only this was all encapsulated in a single Windows app with a large green "start" button and no further complications. The fact that it can run under a VM definitely reduces the barrier to entry, but it's not so simple that I'd do it for every disc I get from the library either.  As for getting the file out of the VM, how about using a flash drive as the location to save the ISO? just cd/media/user_name/flashdrive_label first.

piLagTesterPRO now supports Excel / any plot program that can read CSV files

One of the main features of the piLagTesterPRO is the real time visualization of the TV's response,  plus the ability to export that data to disk for offline analysis and for making figures. Until now the offline analysis had to be performed in Matlab/Octave. But now you can use Excel or any program that can import CSV files (pretty much any plotting program known to man). No more need to install Octave! Design any analysis or figure you want using your favorite spreadsheet! 

Now, I'm not much for eXceL, and as you can see my copy is very old (2003!), so the quality of the figure I came up with it is not nearly as nice as what I can do in Octave. But if Octave is a non-starter for you this offers an alternative.

And of course you could use the same file with an online spreadsheet or plotting website too. Here's what I came up with in google sheets in about 30 seconds:

So the takeaway is this: now pretty much anybody can use the piLagTesterPRO to make figures. The data format is very simple: just two columns, one for time and one for brightness, and it is saved in a plain text file of "comma separated values" (aka CSV) that any program can open. To convert from the standard MATLAB friendly files to CSV use the datr2csv command on the pi, as in datr2csv *.datr

PS: the MATLAB/octave option is still fully supported for those who like the slick figures it makes. And the Matlab code I've written can be used without any programming, you just choose the file you want to plot using a GUI and it generates a reasonable figure from it automatically. Here's an old example from another dataset:

The difficulty arises if you want to edit that figure, which is pretty easy to do in the MATLAB GUI (costs$$$) but can't be done other than simple zooming and stretching in Octave (costs $0/your time).  

Pi0 and Pi0w GPIO layout map with landmarks

After counting pins many times to figure out where to wire up a Pi0 / pi0 Wireless it occurred to me that there might be some landmarks on the printed circuit board that would make it easier to find the desired GPIO pin without counting. The photos below are my attempt at this idea, and it does work, though it would be much better if the Pi folks had added a few silkscreened labels for this purpose.  Next rev, perhaps?

If you print these: these look good at 150 dpi in color, or as large as you can go in black and white.

As always, pin 1 is closest to the SD card slot.

postscript: I scavenged the board images and GPIO layout diagrams from the internet, so I cannot claim any ownership of the final composited image, just the idea. Instead of trying to stake a claim, however, I'd just enjoy if people could take this idea and make it better, perhaps improving the printability of the resulting image (the circuit board is awfully muddy on my printer). 

VIZIO XVT-473SV review: input lag, deinterlacing and upscaling using the piLagTesterPRO

This 1080p IPS Smart TV from 2011 looks great but, has variable and rather high input lag, although it's somewhat competitive for 480i and has excelent upscaling. It retailed for about $1300.

Image quality

Good upscaling is critical for retro gaming. Ideally, all pixels should appear equally sharp and bright (no aliasing), and angled lines should appear smooth, with no jagged, irregular steps. Also important is that the display shows most or all of the pixels it is sent. Often, this is not the case, with some number of pixels cropped from the bottom or top edges. Shockingly, these tests are relevant for modern gaming as well, because even at their native resolution many TVs have aliasing and cropping.

I had to adjust the set to minimize cropping and aliasing, but was very successful! There's almost no need for this table to summarize the results:

resolution aliasing cropping (side, top)
480p/i none none
720p very mild none
1080p none none

480i upscaling (left) vs ideal (right)

In particular 480i/p looked amazing after adjustment; sharp and zero scaling artifacts (see photo). This is a very impressive result matched by few TVs before or after. Only 720p had an issue, with a slight jaggedness that suggests some pixel-rearranging in order to avoid aliasing, but it's a mild effect.  On the whole the upscaling is A+!

It supports local diming with an addressable LED array. This allows very high contrast values for advertising purposes, but looks awful, with halos forming around any bright object on a black background. The first thing you want to do is turn that off!

This TV has "smart" features but at the time of testing (2021) most are no longer supported. But it still works as a dumb TV just fine thank goodness.

The display uses an IPS panel with great viewing angles but noticeable off-angle brightness changes, at least on a very dark background. Noticeable if you are looking for them, anyway. In game it's not distracting at all, in my opinion.

The display has 5 HDMI, VGA, and 1 yPbPr input. I tested HDMI and VGA, and found they performed identically.

Input Lag

I used a piLagTesterPRO to measure input lag. This device sends a frame of video over HDMI and measures how long it takes to display it. This display has a game mode, and with it off input lag was very high and varied between modes. Turning game mode on helped. I toggled all the other display quality settings as well, but did not see any further improvements, however the tests reported below with every "enhancement" set to off.

Complicating things significantly, this is yet another display that does not actually sync refresh to the input signal - instead it fills its own internal frame buffer from the video input and then draws that with a fixed additional delay that is randomly determined each time you turn on the set or switch inputs.  Take one example, input lag for 720p can vary from 61.6ms to 73.8ms. What you get seems to be entirely up to chance, but at least the lag is fixed and does not drift while you are playing.

I've elected to report the average lag values here, since that seems fairest, but there's no right answer; for more discussion of this issue see the above link. It's worth noting however, that this kind of changing lag is the hardest for your brain/hands to adapt to. I'd much rather have an extra 12ms of fixed lag added to the display than one like this where sometimes the extra lag is 0, and sometimes it's 12ms.

This TV supports 24hz input at 1080p; but it's a lie: it really draws at 60hz and has to repeat frames in an alternating pattern to approximate 24hz. Very disappointing!

It proudly proclaims "240hz" but this is also a lie, somehow relating to motion smoothing that as far as I can tell makes no difference. It does draw slightly faster than 60hz; it only takes about 12ms to refresh the screen, which would suggest that it's actually running at 80hz (which nicely divides into 240, which probably means they came up with that spec by using blank frame insertion, which does appear to be the case from looking at the brightness values over time). But it just sits idle for the extra 4ms left over in each frame, so it's only refreshing the screen 60 times a second. I hate this whole fake 120/240hz thing that happened in the 2010s.

The maximum input refresh rate for TV modes is 60hz; if you switch it to computer modes it can accept a 75hz signal at sub-native resolutions. This does not improve lag, however, as the TV continues to draw 60 times a second, and just drops all the extra frames.

Input Lag Test Results

I report two kinds of values. 1st response measures how long it takes for the TV to start responding (I use a 5% change in display brightness). This overly optimistic value doesn't tell how long it takes to see anything useful, but matches what other reviewers call input lag. full response is a more realistic measure of lag, and requires the display to reach 80% of full brightness. This combines both input lag and response time, and is closer to what you would actually experience in a game.

Resolution1st (average)full response1st responsefull response

I'm including the table to show all the modes I tested but in fact all the modes gave the same result: the first response at the screen top starts at 68ms, and takes 12ms to reach the bottom of the screen. That first response takes about 9ms to develop into the full response (that is, response time). This is true in both interlaced and non-interlaced modes. The deinterlacing method used is clever: when the image is static the full 480 vertical pixels are shown with no blur; but when a region is changing, it uses field doubling in that location only, resulting in a blocky 240 vertical resolution. But because things are moving the resulting resolution drop is well hidden. It's a good method for high speed deinterlacing in action games with great sharp visuals for RPGs as well. It's a shame it's paired with a display pipeline that's so slow otherwise. 

I tested both HDMI CEA and DMT modes and VGA input as well, all had the same average lag, and the same level of variability.

Results compared to other displays

To allow quick comparison between many displays I've summarized the results across all the displays I've personally tested with the piLagTester Pro. Min lag is the time to the first response, measured where the screen starts drawing (typically, the top); real lag is the time to the full response, measured where drawing finishes (usually the screen bottom), i.e. input lag + scan out + response time. Numbers in red denote average values that can vary by up to 8ms between power cycles (this TV varies by up to 6ms).

DisplayYear made (TV?)Native Resnative min lagnative real lag480i real lag480p real lag720p real lag1080p real lagnative response timenative scan out
Panasonic TH-58PE75U2008720p28.
Panasonic TH-42PX75U2008720p28.
Dell E2211H20141080p3.033.634.734.534.133.815.0015.57
Corprit D157 (hdmi)20211080p3.134.534.934.834.633.916.2515.13
AOC/Envision G19LWK2010900p3.131.239.538.738.437.815.5012.60
sony XBR 43X800D20174k24.544.346.546.044.644.75.0014.83
LG 42LC2D2006720p28.350.654.650.850.46.3015.95
TCL 40S32520211080p6.527.360.629.027.927.76.0014.83
Vizio E261VA2012720p19.359.061.160.459.258.925.0014.67
Samsung LN32B3602010720p37.660.062.161.860.560.18.0014.40
Dell U2410 (game)20101080p4.
Dell U2410 (sRGB)20101080p20.542.862.445.
ACER AT326520121080p19.543.862.745.343.843.88.0016.27
RCA L40FHD4120101080p20.346.665.
Sony 40VL130 (game)20081080p22.847.366.349.047.347.39.0815.43
Toshiba 40L2200U20141080p30.
Mitsubishi LT-4614420081080p51.
Polaroid FLM-373B2007720p28.
Samsung LN46B61020121080p53.
Vizio VO370M20101080p2.523.683.
Sharp LC-C3234U2009720p33.064.683.666.664.615.0016.60
Philips 42PFL3603D/F720091080p29.
Sony KDL-46EX40020101080p28.
Vizio xvt473sv20111080p67.688.688.889.288.688.69.0012.00
Toshiba 46L5200U20131080p55.
Sony 40S20L12007720p48.472.090.172.973.49.6014.00
Samsung LN46C63020121080p54.572.190.790.388.572.310.007.63
Vizio VO22L FHDTV10A2008720p28.
Samsung HP-T425420111080p69.775.794.
Vizio E261VA2007720p28.
GPX TDE3245W2016720p28.051.0102.
SANYO DP507492010720p67.075.0103.
Emprex HD 32022007720p27.050.5126.
Vizio E470VL (hdmi)20111080p69.086.0128.
LG 47LW6500-UA20121080p66.680.7149.7149.081.780.92.2711.83

Because this TV is pretty slow overall I'm sorting the list by it's best performing mode, 480i. Even with this leg up, the TV performs poorly, about 20ms slower than average. On the other hand it's great upscaling means it might be a good choice for non-action retro gaming.



This is too slow for anybody who cares about input lag. But for folks who just care about nice looking visuals, it's a great choice. And as a general purpose TV it looks great too.

Other models (to avoid)

I tested the XVT-473SV. The XVT553SV seems to have the same specs, so I assume it would perform the same. The XVT373SV and XVT323SV match the series in terms of model number but are advertised as "120hz" so they are likely going to perform differently (maybe even slightly better, since most 120hz TVs draw the screen at 8ms, not the 12 seen here).

Given how badly this one performed, Id' be worried about any Vizio from this era. So the XVT3D650SV, XVT3D424SV, XVT3D474SV, and XVT3D554SV, which are 3D TVs sold at the same time, should be viewed with some concern unless somebody else has published lag values for them.

Email me


Email *

Message *