For kweetet we use several mp3's in our exercises: all our assignments are both in text and audio, some of the questions are audio files and all the feedback on the answers is again with text and audio. We noticed that downloading the exercises on mobile devices could take a while, partly because of the audio. When I took a closer look, we noticed that files where too large: 320kbps for voice while 96kbps would suffice. These mp3's were everywhere in a complex folder structure, so I had to write a script on our server hosting the authoring tool to convert all these mp3s to a lower bit rate at export.
So, to be able to convert mp3s to a lower bit rate I needed to install ffmpeg on the centos machine. No magic there, centos' yum is all you need: just follow the steps of this post
And then the command to do the conversion recursively over all folders, it turned out I could do this in one go! The trick was: a/ discover that you can recurse over folders with find, b/ you can execute a command on every result, c/ you can execute multiple commands for every result, by just having multiple -exec parameters. Resulting in:
find ./export/ -name "*.mp3" -exec ffmpeg -i {} -codec:a libmp3lame -b:a 96k out.mp3 \; -exec mv out.mp3 {} \;
No comments:
Post a Comment