Shrink Ogg files

Q Is it possible to reduce the bit rate of OGG files? I encoded at 458kbps, and they are taking up too much disk space.

A The Ogg Vorbis specification includes the ability to reduce the bit rate of a file without re-encoding, but the current software does not do this, so you need to uncompress and recompress each file. This does mean that there will be some loss of quality compared with encoding at the lower setting to start with, although it is likely to be minimal when coming down from such a high bit rate. Where you still have the original sources, re encoding from scratch is the best option. Otherwise, this will decode and re-encode a single file:

oggdec oldfile.ogg -o - | oggenc -q N -o newfile. ogg -

Use whatever N quality setting you want. Replace the -q with -b if you prefer to specify the average bit rate instead of quality level. You can convert all files in a directory with

mkdir -p smalleroggs
for f in *.ogg
for FILE in *.ogg
do
if oggdec "$FILE" -o - | oggenc -q N -o
"smalleroggs/$FILE" -
then
vorbiscomment -l "$FILE" | vorbiscomment -w
-c /dev/stdin "smalleroggs/$FILE"
fi
done

This re-encodes each file and copies the tags from the old file to the new one. If you want to recurse into a directory structure, you will need the find command to locate all *.ogg files. This version also deletes the original files, so use with care.

find -name '*.ogg' | while read FILE
NEWFILE=${FILE/.ogg/_new.ogg}
if oggdec "$FILE" -o - | oggenc -q N -o
"$NEWFILE" -
then
vorbiscomment -l "$FILE" | vorbiscomment -w
-c /dev/stdin "$NEWFILE"
mv -f "$NEWFILE" "$FILE"
fi
done

Follow us on Identi.ca or Twitter

Username:   Password:
Create Account | About TuxRadar