[mythtv-users] Recovering recordings from corrupted partition

Torsten Crass torsten.crass at eBiology.de
Tue Nov 25 18:23:45 UTC 2008


Hi there,

recently the ext3 partition on which I used to store all my MythTV DVB-T 
recordings got severely corrupted (please, don't ask me what stupid 
thing I did... ;-). I tried to use file recovery / carving tools like 
"PhotoRec" and "foremost" to scan for putative remnants of those files 
and found many things (including the png images created by MythTV as 
live previews), but not a single mpg. So I started wondering whether the 
mpg files created by MythTV from (German) DVB-T streams might exhibit 
different characteristics from what e.g. foremost expects to see at the 
start and/or end of a typical mpg file. However, since I obviously don't 
have any MythTV recordings left, I don't have any files I could examine 
in order to tell foremost which file signatures to look for.

To this end -- unless you have some better idea --, I'd like to ask you 
folks out there who happen to also rely on DVB-T in Germany to run the 
shell script below on your recordings directory and to post its output 
back into the forum. With the information thus gathered I might be able 
to define suitable DVB-T mpg header and footer patterns for foremost.

I tried out the script on a bunch of "normal" mpg files I had laying 
around, and it seemed to me that they are padded with quite a number of 
00 and ff values toward their ends. Hence I'd like you to call the 
script with a rather high value for the number of footer bytes, like

headerfooter.sh -h 16 -f 4096 /path/to/your/recordings/*.mpg > out.txt

Thank you very, very much in advance -- and dont't think twice, but 
thrice before you hit ENTER when issuing a dd command... ;-)

	Torsten

--------8<--------

#!/bin/sh

# ---------------------------------
# -------- headerfooter.sh --------
# ---------------------------------


n_footer=16
n_header=16
show_filenames=

function printUsage() {
   echo "headerfooter -- print first and last n bytes of some files"
   echo "----------------------------------------------------------"
   echo "Usage: headerfooter [options] <file> [<file>...]"
   echo "with possible options:"
   echo "-?     : Display this message and exit."
   echo "-f <n> : Show the files' last <n> bytes. [$n_footer]"
   echo "-h <n> : Show the files' first <n> bytes. [$n_header]"
   echo "-s     : Show the individual files' names."
}

while getopts ": f: h: s" option; do
   case $option in
     f ) n_footer=$OPTARG;;
     h ) n_header=$OPTARG;;
     s ) show_filenames=1;;
     \?) printUsage
         exit 0;;
     * ) printUsage
         exit 1;;
   esac
done
shift $((OPTIND-1))

if [ ! "$1" ]; then
   printUsage
   exit 1
fi

if [ $n_header -gt 0 ]; then
   echo --- HEADERS ---
   for path in "$@"; do
     if [ $show_filenames ]; then
       echo $path:
     else
       echo --------
     fi
     hexdump -Cv -n $n_header "$path" | \
       head -n $(( ($n_header - 1) / 16 + 1))
   done
fi

if [ $n_footer -gt 0 ]; then
   echo --- FOOTERS ---
   for path in "$@"; do
     if [ $show_filenames ]; then
       echo $path:
     else
       echo --------
     fi
     size=$(stat -c '%s' "$path")
     hexdump -Cv -n $n_footer -s $(($size - $n_footer )) "$path"  | \
       head -n $(( ($n_footer - 1) / 16 + 1))
   done
fi


More information about the mythtv-users mailing list