sodnpoo.com

mencoder chop

Here's another mencoder script, this one breaks files up into MB sized chunks.

Usage: mencoderchop.sh <chunk size in MB> <filename>

It's a work around for a dvd player that can't deal with files bigger than 2GB.

#!/bin/bash

echo usage: $0 chunk_size filename

filesize=`ls -ls "$2" | cut -d " " -f 6`
chunksize=`echo "$1*1048576" | bc`
chunknum=`echo "($filesize/$chunksize)" | bc`

flags="-of mpeg -mpegopts format=dvd:tsaf -oac copy -ovc copy"

for ((i=0;i<=$chunknum;i++)) do
  part=`echo "$i+1" | bc`
  start=`echo "$i*$chunksize" | bc`

  mencoder "${2}" $flags -o "${2%.*}-part${part}.mpeg" -sb $start -endpos ${chunksize}b
done

You can get it to run in parallel adding an '&' to the end of the mencoder line. I didn't include it in the script because it becomes a bit unruly, but it can speed up things quite a lot.