Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[vdr] Archiving VDR-recordings on CD-Rs
Hello @ll,
as promised yesterday: Here's my way of archiving a vdr-recording without
modifying them
The first script (make_vdr-cd.sh) creates a directory structure, that can be
burned to CD-R afterwards.
It takes two arguments: The source directory of the movie (e.g.
/video/%Detroit_Rock_City) and the target directory (that's the directory
structure as it should be on CD-R).
The top level directory is called vdr and contains three subdirectories:
MPEG: this is where the recordings are stored (CAUTION: these are
sym-links only)
index: this is where the other files from the .rec directory are stored
plus additional index.vdr* files
info: these are files that store information on date, time, name of the
recording and the current version of vdr
It'll look something like the following (ttt was the target directory).
ttt:
total 1
drwxr-xr-x 5 vdr vdr 1024 Mar 15 14:44 vdr
ttt/vdr:
total 3
drwxr-xr-x 2 vdr vdr 1024 Mar 15 14:44 MPEG
drwxr-xr-x 2 vdr vdr 1024 Mar 15 14:44 index
drwxr-xr-x 2 vdr vdr 1024 Mar 15 14:44 info
ttt/vdr/MPEG:
total 0
lrwxrwxrwx 1 vdr vdr 64 Mar 18 22:13 001.vdr ->
/video/%Detroit_Rock_City/2002-03-15.14.44.99.99.rec/001.vdr
lrwxrwxrwx 1 vdr vdr 64 Mar 18 22:13 002.vdr ->
/video/%Detroit_Rock_City/2002-03-15.14.44.99.99.rec/002.vdr
lrwxrwxrwx 1 vdr vdr 64 Mar 18 22:13 003.vdr ->
/video/%Detroit_Rock_City/2002-03-15.14.44.99.99.rec/003.vdr
lrwxrwxrwx 1 vdr vdr 64 Mar 18 22:13 004.vdr ->
/video/%Detroit_Rock_City/2002-03-15.14.44.99.99.rec/004.vdr
ttt/vdr/index:
total 2148
-rw-r--r-- 1 vdr vdr 1089456 Mar 15 14:44 index.vdr
-rw-r--r-- 1 vdr vdr 313296 Mar 15 14:44 index.vdr_001
-rw-r--r-- 1 vdr vdr 309024 Mar 15 14:44 index.vdr_002
-rw-r--r-- 1 vdr vdr 293544 Mar 15 14:44 index.vdr_003
-rw-r--r-- 1 vdr vdr 173592 Mar 15 14:44 index.vdr_004
-rw-r--r-- 1 vdr vdr 22 Mar 15 14:44 marks.vdr
-rw-r--r-- 1 vdr vdr 4 Mar 15 14:44 resume.vdr
-rw-r--r-- 1 vdr vdr 436 Mar 15 14:44 summary.vdr
ttt/vdr/info:
total 5
-rw-r--r-- 1 vdr vdr 11 Mar 15 14:44 date.vdr
-rw-r--r-- 1 vdr vdr 18 Mar 15 14:44 name.vdr
-rw-r--r-- 1 vdr vdr 6 Mar 15 14:44 time.vdr
-rw-r--r-- 1 vdr vdr 39 Mar 15 14:44 version.vdr
-rw-r--r-- 1 vdr vdr 2 Mar 15 14:44 volumes.vdr
If you replace the symbolic links in the MPEG-dir with the real 00x.vdr
files you can just burn the target directory to CD-R. As expected they won't
fit onto a single disk. Therefore, I store one 00x.vdr file per disk leaving
the rest identical for each disk of the set (I found MaxVideoFileSize=695
O.K. for 700MB CD-Rs)
Two variables have to be set:
VDR_DIR=(path to your vdr source directory)
On my machine this is something like /home/vdr/vdr/VDR ->
/home/vdr/1.00/vdr-1.00-pre4
Actually the result of /bin/pwd will be placed into the info/version.vdr
file (vdr-1.00-pre4 in my case)
SPLITINDEX=(path to splitindex binary)
Path of the splitindex binary (source code is at the end of this mail)
Now, if you want to watch a movie that is stored on CD-R you invoke
mount_vdr-cd.sh
This script does not take any arguments.
It mounts the CD and recreates the original directory structure in the video
dir (except for any number of '%' preceeding the original name of the
recording).
The following variables must be set to match your needs:
CDROM=(mount point of your cdrom drive)
e.g. /media/cdrom on SuSE 7.2
VIDEO_DIR=(path to video dir)
VFAT=1
'1' if you use VFAT '0' if not
PRIORITY=00
LIFETIME=01
priority and lifetime parameters of the .rec directory (e.g.
2002-03-15.14.44.00.01.rec)that will be created. This allows you to leave
vdr the task of deleting the stuff automatically.
COPY='ln -s'
well this is the most important variable: Anything between the single quote
characters will be done to the 00x.vdr file in the vdr/MPEG dir of the CD-R.
'ln -s' creates a symbolic link. Now you can watch the movie from CD.
'cp' actually copies the file. Now you can unmount the CD and watch from
HDD.
I added this script to my commands.conf.
Finnally go to the recordings menu there you'll find the restored movie with
it's original name.
If this collection helps enjoy using it. If not feel free to improve it.
CREDITS to the creator(s) of the original genindex.c program, as I took the
code to write the splitindex.c program and of course to Klaus for creating
such a marvelous piece software like VDR is today.
CU,
Christian.
------ make_vdr-cd.sh ------------
#!/bin/bash
#
# local variables
#
VDR_DIR=~vdr/vdr/VDR
SPLITINDEX=~vdr/prog/splitindex
############################################################################
#
if [ -z $1 ] || [ -z $2 ]; then
echo USAGE $0 "<sourcedir> <targetdir>"
exit 1
else
SRC_DIR=$1
TARGET_DIR=$2
fi
if [ -d $TARGET_DIR ]; then
echo $TARGET_DIR already exists
exit 2
fi
BASE_DIR=$TARGET_DIR/vdr
MPEG_DIR=$BASE_DIR/MPEG
INDEX_DIR=$BASE_DIR/index
INFO_DIR=$BASE_DIR/info
mkdir $TARGET_DIR
mkdir $BASE_DIR
mkdir $MPEG_DIR
mkdir $INDEX_DIR
mkdir $INFO_DIR
INFO=`ls $SRC_DIR`
DATE=`echo $INFO | cut -c1-10`
NAME=`basename $SRC_DIR | sed 's/^%*//' | sed 's/_/ /g'`
TIME=`echo $INFO | cut -c12-16 | sed 's/\./:/'`
FILES=`ls $SRC_DIR/$INFO/[0-9][0-9][0-9].vdr`
VOLUMES=`ls $SRC_DIR/$INFO/[0-9][0-9][0-9].vdr | wc -l | sed 's/^ *//'`
VERSION=`(cd $VDR_DIR && /bin/pwd)`
TIMESTAMP=`echo $DATE$TIME | sed 's/-//g' |sed 's/://'`
ln -s $FILES $MPEG_DIR
cp $SRC_DIR/$INFO/index.vdr $INDEX_DIR
$SPLITINDEX $INDEX_DIR/index.vdr
cp $SRC_DIR/$INFO/marks.vdr $INDEX_DIR
cp $SRC_DIR/$INFO/summary.vdr $INDEX_DIR
echo -ne """\0\0\0\0""" > $INDEX_DIR/resume.vdr
echo $DATE > $INFO_DIR/date.vdr
echo $NAME > $INFO_DIR/name.vdr
echo $TIME > $INFO_DIR/time.vdr
echo $VOLUMES > $INFO_DIR/volumes.vdr
basename $VERSION > $INFO_DIR/version.vdr
touch -t $TIMESTAMP $TARGET_DIR
touch -t $TIMESTAMP $BASE_DIR
touch -t $TIMESTAMP $MPEG_DIR
touch -t $TIMESTAMP $INDEX_DIR
touch -t $TIMESTAMP $INFO_DIR
#touch -t $TIMESTAMP $MPEG_DIR/*
touch -t $TIMESTAMP $INDEX_DIR/*
touch -t $TIMESTAMP $INFO_DIR/*
-----------------------------------
------ mount_vdr-cd.sh ------------
#! /bin/bash
#set -x
#
# local variables
#
CDROM=/media/cdrom
VIDEO_DIR=/video
VFAT=1
PRIORITY=00
LIFETIME=01
COPY='ln -s'
############################################################################
#
#
# The index files
#
INDEX_DIR=$CDROM/vdr/index
INDEX=$INDEX_DIR/index.vdr
SUMMARY=$INDEX_DIR/summary.vdr
RESUME=$INDEX_DIR/resume.vdr
MARKS=$INDEX_DIR/marks.vdr
#
# The other information files
#
INFO_DIR=$CDROM/vdr/info
DATE=$INFO_DIR/date.vdr
TIME=$INFO_DIR/time.vdr
NAME=$INFO_DIR/name.vdr
VERSION=$INFO_DIR/version.vdr
VOLUMES=$INFO_DIR/volumes.vdr
#
# The video files
#
MPEG_DIR=$CDROM/vdr/MPEG
MPEG=$MPEG_DIR/???.vdr
#
# mount CD if necessary
#
cd_in=`mount -l -t iso9660 | grep $CDROM | wc -l`
if [ $cd_in -eq 0 ]; then
mount $CDROM
fi
#
# create directory structure
#
BASE_DIR=`cat $NAME | sed 's/\ /_/g'`
if [ $VFAT -eq 0 ]; then
REC_DIR=`cat $DATE`.`cat $TIME`.$PRIORITY.$LIFETIME.rec
else
REC_DIR=`cat $DATE`.`cat $TIME | sed
's/:/\./'`.$PRIORITY.$LIFETIME.rec
fi
mkdir -p $VIDEO_DIR/$BASE_DIR/$REC_DIR
#
# now copy the files
#
cp $SUMMARY $VIDEO_DIR/$BASE_DIR/$REC_DIR
cp $RESUME $VIDEO_DIR/$BASE_DIR/$REC_DIR
cp $MARKS $VIDEO_DIR/$BASE_DIR/$REC_DIR
cp ${INDEX}_`basename $MPEG| cut -c1-3`
$VIDEO_DIR/$BASE_DIR/$REC_DIR/`basename $INDEX`
for file in $MPEG; do
$COPY $file $VIDEO_DIR/$BASE_DIR/$REC_DIR
done
exit 0
-----------------------------------
------- splitindex.c --------------
#include <stdio.h>
#include <limits.h>
#define I_FRAME 1
#define P_FRAME 2
#define B_FRAME 3
#define B2 256
#define B3 256*256
#define B4 256*256*256
int main(int argc, char** argv)
{
int c;
FILE* fp_in;
FILE* fp_out = NULL;
int idx = 0;
unsigned char ie[8];
char* inFile;
char outFile[PATH_MAX];
if (argc > 1) {
inFile = argv[1];
} else {
inFile = "index.vdr";
}
fp_in = fopen(inFile, "r");
if (fp_in == NULL) {
printf ("Failed to open input file \"%s\".\n", inFile);
return 1;
}
while (fread (ie, 1, 8, fp_in) == 8) {
if (ie[5] != idx) {
if (fp_out != NULL) {
fclose (fp_out);
}
idx = ie[5];
sprintf (outFile, "%s_%03d", inFile, idx);
fp_out = fopen(outFile, "w");
if (fp_out == NULL) {
printf ("Failed to open output file \"%s\".\n",
outFile);
return 2;
}
}
if (fwrite (ie, 1, 8, fp_out) != 8) {
printf ("Failed to write to output file \"%s\".\n",
outFile);
return 3;
}
}
if (fp_out != NULL) {
fclose (fp_out);
}
if (fp_out != NULL) {
fclose (fp_in);
}
return 0;
}
-----------------------------------
Home |
Main Index |
Thread Index