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 600which 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 I'm not sure how to tell the script how long the file is, I'm sure it's possible with an awk on the output from ogginfo. anyway, any help with this would be much appreciated, many thanks, norpel -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://lists.xiph.org/pipermail/vorbis/attachments/20050102/70ea4c70/attachment.pgp
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.)
Thanks Andy, you just saved me alot of work trying to do all of this manually On Sunday 02 Jan 2005 14:29, Andy Baxter wrote:> #!/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-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://lists.xiph.org/pipermail/vorbis/attachments/20050102/edf3aac3/attachment.pgp
On Sun, 2 Jan 2005 14:01:11 +0000, Kelsang Norpel <norpel@meditateinscotland.org> 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?I see you've had some answers on the shell-scripting side of this. I'd add that I strongly recommend not using vcut for any purpose. It works unreliably and will tend to produce incorrect output files. (I wrote it, and _I_ won't use it!) Mike