Posts Tagged ‘mp3s’

simple is beautiful - command line id3 tagging

Sunday, March 16th, 2008

generally speaking, my set of mp3s is very well tagged. for my personal mp3s, i used to exclusively use easytag to tag them, and now i use a combination of easytag and amarok (which is totally awesome by the way!)

but sometimes, i have to mass edit id3tags for mp3s on the server, and i don't have the luxury of using such gui tools for the editing. as thus, i've been mainly using id3v2 within some perl scripts to tag mp3s. this turns out to work great, but i also wanted to be able to add album art to the mp3s from the command line.

i couldn't figure out how to do it using id3v2 (perhaps using the custom frames, there's a way, but nothing extremely simple and obvious from what i was looking at). then i found the solution in the form of a id3lib-ruby, a ruby wrapper for id3lib, the same library that id3v2 is based on.

with this, everything turns out to be extremely easy -

 
require 'id3lib'
 
tag = ID3Lib::Tag.new('myfile.mp3')
cover = {
   :id => :APIC,
   :mimetype => 'image/jpeg',
   :picturetype => 3,
   :data => File.read('cover.jpg')
}
 
tag << cover
tag.update!

and that's it. nice and simple. by the way, a picturetype of 3 denotes a front cover and is the default value (just learned that from a quick search). oh and the output mp3 image cover shows up fine in both linux and on itunes. beautiful!

quranicaudio.com redone!

Tuesday, September 4th, 2007

keeping the seo statements from the previous post in mind, audio.islamicnetwork.com has become http://quranicaudio.com/ -- it is now running on lighttpd (rather than apache - by the way, so far, i really like lighty masha'Allah) and al7amdulillah, so far, things look good.

quranicaudio.com is one of the web's largest (if not the largest) collection of cd quality downloadable quran mp3s (and some oggs). check it out!

come again?

Sunday, November 27th, 2005

a long time ago, when i still used to use xmms, there was this nice plugin called Repeat It! that let you say, "repeat this song between this and this times forever."

i found myself missing that feature today... unfortunately, i don't have xmms installed and don't want it installed because i now like the gtk2 based mp3 players, like beep for example.

but because beep is being rewritten as bmpx, i figure rather than porting the plugin, i can just write a much simpler command line version based on the existing plugin that works with beep.

note however that this is really bad... it does very little error checking, and the sleep solution isn't really the best solution... but its a pretty good solution for my limited uses :)

and in 25 lines, here it is:

 
#include <stdio.h>
#include <signal.h>
#include <bmp/beepctrl.h>
 
void got_signal(int x){
	printf("Exiting!\n"); exit(1);
}
 
int main(int argc, char** argv){
 
   int startpos, endpos;
   if (!xmms_remote_is_running(0))
      return (0*printf("\033[1mbmp is not running.\033[0m\n"))-1;
 
   if (argc != 3)
      return (0*printf("usage: %s start end\n", argv[0]));
 
   startpos = atoi(argv[1]);
 
   endpos = atoi(argv[2]);
 
   signal(SIGINT, got_signal);
 
   if (!xmms_remote_is_playing(0)){ xmms_remote_play(0); }
 
   while (1){
      xmms_remote_jump_to_time(0, startpos * 1000);
      sleep(endpos - startpos);
   }
}

to compile it, just do:

 
gcc `beep-config --cflags --libs` loopsegment.c -o loop

then just run beep, load up the file you want to play, and run the script passing in start and end seconds.