Saturday, July 24, 2010

FFROGG - FFmpeg Recursive Ogg Encoding Script

What happens when you have thousands of songs that you want encoded, but either you

a) Have a command line system where no gui app can encode them for you?

b) Want more efficient use of your processor therefore do not use a gui?

c) are not good at computing and just want to get'r done?

This is one itch I just had to scratch. Now I'm aware of great apps like handbreak and I know amarok 1.4.x used to have a script to encode songs in a playlist. However, not only am I a big fan off ffmpeg, I needed to test out my bash-fu.

The scenario is this:

Joe user has tons of music spread out all over his hard drive. Lets say he has 10 000, none of which are contained in any one folder as more OCD folks would do. (Or an organized heirarchy of folders even)

Joe decides that one day, he wants to move to a patent-free codec such as .OGG format, but not only does he not have the time to FIND all his mp3's, he's clueless about how to encode them and knows of no gui apps (except for above mentioned in this article).

Joe user visits this article and decides that he wants all his files encoded into one folder on an external hard drive (which could be his mp3 player).

All Joe has to do is ensure that ffmpeg and libvorbis/libtheora are installed correctly on his *nix system and he can go about watching TV or playing with his dog/kids/wife while the machine does all the work.

Here's How:

1) Download the script @ [ http://www.mediafire.com/?lc023alg2bsfx9x ] to your home folder

2) Make sure it's executable, use chmod +x ffrogg.sh to do so.

3) Use the command sh ffrogg.sh --input=/home/$USER/ --output=/media/externaldisk/encoded --export --recursive (as long as your --input is linked to the top folder where your music is located, it should be fine)

4) Navigate to your output folder, in Joe User's case, it's /media/externaldisk/encoded/. There should be a script called "ffrogg-encodethis-[numbers].sh".

5) At his/your convenience, run the script. Example: sh ffrogg-encodethis-1279967631.sh

Technical Aspect:

Here's the really cool technical details of the script.

THIS SCRIPT IS CURRENTLY IN ALPHA, IT DOES NOT WORK 100%!

This script at its greatest potential will dynamically produce a script using the ffmpeg and theora-vorbis backend that can be run which will encode ALL RECOGNIZED AUDIO FILES that were found when it was invoked. It can recursively find all audio files starting at the specified input directory. Since this is alpha software, below is a list of what DOES work in the current version (0.01.05 ALPHA):

sh ffrogg.sh [commands]

  • --input=[folder or file]
  • --output=[folder only]
  • --logging (this is for debugging purposes only, can specify a folder with --logging=[folder] if directory is read-only)
  • --recursive (this flag is required to go into directories to find audio files. Otherwise it just looks at contents of specified directories)
  • --export (Create the script and exit. Omitting this flag will cause the script to encode before exiting, although it gives a period to exit before starting)
  • --force (No use for it yet, as the recovery handling bit is not quite implemented. Will remove temp files if they get in your way)
  • --help (Gives a list of options, some of which will not work yet)
  • --version (displays version of program)

This script creates a few temporary files which is inefficient, but this is by no means a professional work. It's also licensed under the GPL version 2 (although I may have omitted that in the script itself).

If the --output and --logging= and --save-state= flags are given without parameters, the current folder is automatically used "." .

Running the script without parameters will cause it to exit.

I may not get around to improving it much, and I do have a graphical user interface planned which would require basically a re-write of the script into a QT application, so it may not get past Alpha. Feel free to take it on yourselves as long as you give credit in the comments at the very least, to PeonDevelopments 2010.

Thanks, and happy listening.

Since I don't usually look at comments, send them to my gmail.

peon.developments --at-- gmail --dot-- com.

=-=-=-=-=
Powered by Blogilo

No comments: