[mythtv-users] Repairing corrupt recordings with dd

Simon Hobson linux at thehobsons.co.uk
Tue Jun 23 15:30:14 UTC 2020


DaveD <mythtv at guiplot.com> wrote:
> 
> A while back (few weeks?) someone posted info about a technique to strip the first few megabytes from the beginning of a recording using dd.  It involved a discussion about the new video rendering system crashing the frontend (or casing decoder errors) on recordings where the format changes soon after the recording starts.  I swear I saved that message somewhere because I have a lot of those (thanks to Comcast and my firewire recordings) but I'll be dipped if I can find it.  I've searched the archives, too, with no luck.  I could probably figure it our from the dd man page, but thought I'd ask for a re-post of that info since it's a tried and tested method.

Can't help with specifics, but the general syntax for dd would be :

dd if=<input file name> of=<output file name> bs=<block size> skip=<blocks to skip on input> count=<blocks to copy>

Input & output file names are self explanatory. If omitted, defaults to stdin and stdout respectively.

Block size would be some convenient value such as 1M (or 1m, or 1024k - it seems different implementations differ in what they'll accept)

Skip is the key thing if you are wanting to trim the beginning of the file. You'd need to guesstimate how many blocks to skip, and possibly test it if it's a large file by only copying a small amount to see if you've reached the right point. As a rough starting guestimate, consider the length of your pre-roll time as a fraction of the entire recording, and skip a similar fraction of the recorded file size.

And count allows you to limit how much data you copy. Normally you'd want to the end of the file (just omit count altogether), but if finding the right cut point by trial and error, you might only want to copy a short bit of your video initially to save time waiting for disk I/O.


One word of warning ... dd is a powerful tool and comes with no safeties installed. It'll do what you ask it to do regardless of what you might have intended to type, and as long as system permissions allow then it'll happen - even if that means nuking an entire disk in double-short time. Very short is that interval between hitting enter and uttering "oh ****" as you realise that you'd got something wrong.

As an aside, if you ever have a failing disk, then ddrescue does a similar job to dd - but with added smarts specifically for dealing with error laced inputs.

Simon



More information about the mythtv-users mailing list