[Vorbis] Re: Recursively vcutting

Andy Baxter andy at earthsong.free-online.co.uk
Sun Jan 2 06:29:53 PST 2005


On Sun, 02 Jan 2005 14:01:11 +0000, Kelsang Norpel wrote:

> Hi,
> 
> I've got alot of long 1-2hr files which I'd like to split up into 5-10 minute 
> chunks.  I think this should be possible using a small shell script and vcut, 
> but my scripting abilities are lacking.  Does anyone know of the existence of 
> a script which would do this, or know how I'd go about making one?
> 
> So say I had a 60 min file (60mins.ogg) I'd like to issue a command something 
> like
> 
>> split outfilename 60mins.ogg 600
> 
> which would do a series of vcuts
> 
> vcut outfile1.ogg tmpfile.ogg 60mins.ogg +600
> vcut outfile2.ogg tmpfile2.ogg tmpfile.ogg +600
> /bin/rm tmpfile.ogg 
> vcut outfile3.ogg tmpfile3.ogg tmpfile2.ogg +600
> /bin/rm tmpfile2.ogg
> 
> .......
> 
> 
> until it's reached the end of the file
> 

This does it:

-------------------

#!/bin/bash
split=$1;shift
file="$*"
name="${file%.ogg}" # strip extension.
cp "$file" /tmp/file-$$.ogg
stop=0
n=0
while [ $stop -eq 0 ] ; do
    echo "cutting to ${name}-$n.ogg"
    vcut /tmp/file-$$.ogg "${name}-$n.ogg" /tmp/remainder-$$.ogg "$split"
    stop=$?
    mv /tmp/remainder-$$.ogg /tmp/file-$$.ogg
    n=$(( $n + 1 ))
    done

rm /tmp/file-$$.ogg

--------------------

save it as vdice, then do vdice +600 filename.ogg

The key bit is the 'stop=$?' line, which tells the script to stop cutting
when vcut returns an error (because the split point has gone beyond the
end of the file.)



More information about the Vorbis mailing list