#!/bin/sh -e if test "$#" != "1"; then echo "Usage: $0 sound_file.ext"; exit 1; fi file="${1%.*}.pcm" ffmpeg -loglevel fatal -y -i "$1" -f u8 -c pcm_mulaw -ar 8000 -ac 1 "$file" size=`du -b "$file" | cut -f1` size=$(($size/240*240)) if test "$size" -gt "16080"; then size=16080; fi truncate -s "$size" "$file"