#!/bin/bash # # DVB recordings are usually broken, so A/V sync will break during editing and/or # recoding. This script tries to fix all that. # # 1. Run ProjectX to split the mpeg transport stream into (fixed) elementary components. # 2. Run mplex to multiplex the elementary stream to MPEG PS (DVD-style mpeg) # 3. Remove all elementary streams to save space # 4. Run avidemux to create index for each fixed file # 5. When sure... remove original recording... # Get the basename (=no extension) of the edited file DVB_SUFFIX="vdr" M2V="m2v" MP2="mp2" MPG="mpg" BASENAME=$(basename $1 .$DVB_SUFFIX) DIRNAME=$(dirname $1) # After much hardship we finally have the full name of # the file, but without the extension FULLNAME=$DIRNAME"/"$BASENAME # You may possibly want to use some basic checks at some points to see if something # has gone wrong #if [ $? -ne 0 ]; then exit; fi # Split to (fixed) elementary streams java -jar /home/samuli/Desktop/ProjectX_Source_0.90.4/ProjectX.jar $FULLNAME.$DVB_SUFFIX if [ $? -ne 0 ]; then echo "Something went wrong with sanitizing the recording!" exit 1 fi # Multiplex the elementary streams back together mplex -f 8 -o $FULLNAME.$MPG $FULLNAME.$M2V $FULLNAME.$MP2 # If all seemed to go well, remove the original recording if [ $? -eq 0 ]; then echo "Removing original file $1" rm -f $1 else echo "Something went wrong with multiplexing, not removing original recording!" fi # Remove old elementary streams echo "Removing old elementary streams" rm -f $FULLNAME.$M2V $FULLNAME.$MP2