#!/bin/sh

# Copyright (c) 2009 Dominik Kopp
# This program is free software; see COPYING for details.


# call programm with movies as arguments
# it will create the sub folder good169 and put the converted movie there.

for X in "$@"
do

file=`basename "$X"`
path=`dirname "$X"`

mkdir "$path/good169"

sed -r 's/(\x00\x00\x01\xB3...)\x23/\1\x33/g' "$X" > "$path/good169/$file"
# example of a MPEG2 movie:
# 00 00 01 B3 2D 02 40 23
# for more information about the structure 
# see http://dvd.sourceforge.net/dvdinfo/mpeghdrs.html 
#
# how the sed command works:
# 's/search/replace/g'   g = global and not only one
# \x00 = hex code 00
# . = one character
# () = group pattern and \1 for reference

done