View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 10 posts ] 
Print view Previous topic   Next topic  
Author Message
Search for:
 Post subject: Creating Audio CD's
PostPosted: Sat Nov 12, 2005 10:02 pm 
Offline
Joined: Fri May 20, 2005 3:48 pm
Posts: 9
Location: Virginia U.S.A.
Here are the steps I took to burn audio cd's from my mythmusic library. This is a pretty cheesy hack if you will but it works for me. As you will notice, all the tools to make an audio cd from mythmusic already existed. All I did was tie them together. "I'm just a shoe lace"

First install these packages
--> sox
--> mpg321
--> normalize-audio
All of these packages installed properly under KnoppMyth R5A16. I'm not sure about other versions.
--> mp3cd - This at one time was in the Debian repositories but is no longer that I can tell. So cd into your home directory and

$wget http://outflux.net/software/pkgs/mp3cd/ ... 024.tar.gz

then extract the file

$tar xvfz mp3cd-1.024.tar.gz

follow the install instructions within the mp3cd-1.024 directory. (or you can cheat as I did and copy the mp3cd file to /usr/bin)
$su
password
#cp mp3cd-1.024/scripts/mp3cd /usr/bin/mp3cd

Once the packages are installed create a symlink from /usr/bin/normalize-audio to /usr/bin/normalize
So as root do

#ln -s /usr/bin/normalize-audio /usr/bin/normalize

now download the next needed file

$wget http://www.foofus.net/jmk/mythtv/m3u2myth.pl

copy this file to /usr/bin

$su
password
cp m3u2myth.pl /usr/bin/m3u2myth.pl

Now using your favorite editor create a file called burncdaudio.sh

----------------------------------------------------------------------------------------------
#! /bin/bash
# (c) 2005 Jeff Bushnoe
# Version 0.1
#
# ----------------------------------------------------------------------------
# Script to create Audio Cd's from MythMusic Library
# ----------------------------------------------------------------------------
#
# Programs and Scripts used.
# Sox --> apt installable
# mpg321 --> apt installable
# normalize --> apt installable (In Debian a link from /usr/bin/normalize-audio to /usr/bin/normalize needs to be created)
# cdrdao --> apt installable
# m3u2myth --> by Joseph N. Mondloch
# mp3cd --> by Kees Cook ( no longer in the apt repositories. you can get it here http://outflux.net/software/pkgs/mp3cd/ ... 024.tar.gz

PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/local/sbin:/usr/local/bin:/usr/games"
export PATH

# Create Temporary Directory
echo Making Temporary Work Directory,
mkdir /myth/cdaudio/tmp

# Change into Directory where MythMusic Library resides.
echo Changing into MythMusic Library Directory,
cd /music

# This Script converts the default playlist in MythMusic to a playlist file.
echo Converting MythMusic default playlist,
perl m3u2myth.pl --toM3U --file /myth/cdaudio/tmp/cdaudio.pls --id 1

# This Script reads the newly created playlist, converts the mp3's to wavs, checks the wav's for proper formatting, level's the volume for each wav, and then writes the disc.
echo Creating wavs and burning disc.
perl mp3cd -s clean -t /myth/cdaudio/tmp -d /dev/dvd /myth/cdaudio/tmp/cdaudio.pls

# Remove Temporary directory and files.
echo Removing Temporary directory and files.
rm -fr /myth/cdaudio/tmp

echo #############################
echo Finished
echo #############################
----------------------------------------------------------------------------------------------
Some editing needs to be done to match your system.

I created a folder called cdaudio under the myth directory, but it can be whatever you desire. Remember that the mythtv user has to have write privlages. This will be the working directory for the script.

$mkdir /myth/cdaudio

You'll need to change this line so it'll change into where you have your music stored. I have mine in /music.

# Change into Directory where MythMusic Library resides.
echo Changing into MythMusic Library Directory,
cd /music

copy this newly created/edited file to /usr/bin

#cp burncdaudio.sh /usr/bin/burncdaudio.sh

Make this file executable

#chmod +x /usr/bin/burncdaudio.sh

Now edit the file library.xml in /usr/share/mythtv and add these lines. (Remember to make a backup of this before you edit it just in case things go astray, as with any edited file). This could also be put in the optical_menu.xml file, but again put it where you feel fit.

<button>
<type>Audio CD Creation</type>
<text>Burn Audio CD</text>
<action>EXEC sh /usr/bin/burncdaudio.sh</action>
</button>


Now you'll want to check that the script runs without errors, so as the mythtv user in a console window run the frontend.

$mythfrontend

Go to media library --> listen to music, press '3' key to edit playlist, select 2 or 3 songs and then exit out. Now you should have the songs you selected in your default playlist. This is where the script will get the songs from. (A quick note: While in the 'Edit Playlist' window if you highlight the 'Active Play Queue' selection and press 'm' you'll be able to see how much time your using.) Exit out of the frontend. As the mythtv user do this

$sh /usr/bin/burncdaudio.sh

If the script finishes without error then your good to go select more songs and run the script form the button you created earlier. You won't be able to do anything else until the disc is done. (kinda like the backup and restore scripts from the knoppmyth menu)

If you get errors with the burning process (as I did). Then to solve this you'll need to create a file called cdrdao.conf. Now using your favorite editor create this file and add this line.

write_driver: "generic-mmc-raw"

as root copy this new file to /etc

$su
password
#cp cdrdao.conf /etc/cdrdao.conf

Now run the script again to make sure it'll create your disc.


If you want you can add these two lines into the burncdaudio script so that sounds are played to indicate the start and finish of the script just like the knoppmyth backup and restore scripts do.

under this line "PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/local/sbin:/usr/local/bin:/usr/games"
export PATH"
add

# So we know the script has started we will play a sound.
(play /usr/share/sounds/beg.wav >& /dev/null)&

under this line "rm -fr /myth/cdaudio/tmp" add
# So we know the script has ended we will play a sound.
(play /usr/share/sounds/end.wav >& /dev/null)&

You should be good to go
Good Luck


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 12, 2005 10:12 pm 
Offline
Joined: Fri May 20, 2005 3:48 pm
Posts: 9
Location: Virginia U.S.A.
After posting I realized I had forgot to add that you need to edit the m3u2myth.pl file for it to function properly.

Comment out these three lines

use MP3::Info;
my $mp3Tag = get_mp3tag($row->[0],2,1);
my $mp3Info = get_mp3info($row->[0],2,1);


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 12:47 pm 
Offline
Joined: Tue Oct 25, 2005 1:22 pm
Posts: 108
Location: USA, New Hampshire
Code:
Making Temporary Work Directory,
Changing into MythMusic Library Directory,
Converting MythMusic default playlist,

---------------------------------------
m3u <==> MythMusic DB Conversion Script
---------------------------------------

Retrieving playlist: 1...
Writing playlist (default_playlist_storage) to m3u file...
Creating wavs and burning disc.
Cleaning up...
01: [...]/Kayne West - Late Registration - 02 - Heard.mp3
02: [...]/LL Cool J feat. Ralph Tresvant & Ricky Bell - Candy Girl.mp3
03: [...]/Mike Jones- Im looking for a dime.mp3
04: [...]/Nas feat. Lauryn Hill - If I Ruled the World.mp3
05: [...]/This_Is_The_Way_I_Pray.mp3
Use of uninitialized value in scalar chomp at /usr/bin/mp3cd line 537.
Use of uninitialized value in pattern match (m//) at /usr/bin/mp3cd line 538.
Use of uninitialized value in split at /usr/bin/mp3cd line 539.
Use of uninitialized value in split at /usr/bin/mp3cd line 543.
Use of uninitialized value in concatenation (.) or string at /usr/bin/mp3cd line 548.
Error: '': unknown extension ''!
Stopping due to errors...
Removing Temporary directory and files.

Finished


This is the error I get and followed your post to a tee.
Any info would be great.
Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 7:21 pm 
Offline
Joined: Fri May 20, 2005 3:48 pm
Posts: 9
Location: Virginia U.S.A.
Hi

Couple of questions

1. Was "This_Is_The_Way_I_Pray.mp3" the last song?
2. What version of KnoppMyth are you using?
3. Is all the songs in your library mp3?

I tried for many hours to recreate your error but couldn't.
e-mail me if you like
jeedbu73@juno.com


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 02, 2005 3:44 am 
Offline
Joined: Mon Jun 21, 2004 5:28 am
Posts: 700
Location: Germany
This is great! I'm going to have to set it up when I get a chance!

As for the problem listed, I took a quick look at the script. The problem happens after track 5. A couple of things to check:
    The filename of track 6 might contain characters that are not parsed properly in mp3cd. The easiest thing to do in this case is rename the file or directory above it with the unusual character
    The ID3 information might contain characters that are confusing m3u2myth.pl. In this case, try changing the ID3 information (this can be done in myth)
I would recommend looking at the contents of /myth/cdaudio/tmp/cdaudio.pls. You will have to modify burncdaudio.sh to not delete it. There will probably be something suspicious at track 6.

I had problems once writing perl code that handles every possiblity of file name or ID3 character (I was writing a flac->mp3 bulk conversion tool). If anyone knows of a trick to do this, let me know...

Allen

_________________
ASUS AT3N7A-I (Atom 330)
TBS 8922 PCI (DVB-S2)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 27, 2006 8:53 pm 
Offline
Joined: Sat Feb 04, 2006 1:36 pm
Posts: 3
Have you guys managed to get this script to work with myth 0.20? It worked just fine for me on myth 0.19 but when i upgraded to .20 the script only finds the old playlist from when i was running .19.
Has anyone got a fix for this? If so please let me know, i really miss this script!

Thanks

/Peter


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 28, 2006 2:52 am 
Offline
Joined: Mon Jun 21, 2004 5:28 am
Posts: 700
Location: Germany
Yup. The DB field names have changed. I was too lazy to look for a new version, so I made global replaces in the m3u2myth.pl file to get it to work. I see now there is no new version (yet). I don't have internet near my mythbox, but I'll post my version here tomorrow.

If you are in a real hurry, you can find the fixes by:

1. Create a play list with a song with an unusal name.

2. Run mythbackup.

3. Look in the sql backup file created and search for the the unusual name to find the play list.

4. From there it is easy to figure out the new field names and change them in the m3u2myth.pl file.

_________________
ASUS AT3N7A-I (Atom 330)
TBS 8922 PCI (DVB-S2)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 28, 2006 4:16 pm 
Offline
Joined: Sat Feb 04, 2006 1:36 pm
Posts: 3
I couldn't find anything specific pointing to the audio track i had added to my playlist. All i could find was the contents of the music database.
So i'll wait for your fixed version of the script.

Thanks for helping out!

/Peter


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 3:36 am 
Offline
Joined: Mon Jun 21, 2004 5:28 am
Posts: 700
Location: Germany
Here's the version of m3u2myth.pl I use for Mythtv 0.20.

Code:
#!/usr/bin/perl
#
# m3u2myth.pl
#
# m3u <==> MythMusic DB
# created: 08/25/2003
#
# Copyright (C) 2005 Joseph N. Mondloch
# #
# # This program is free software; you can redistribute it and/or modify
# # it under the terms of the GNU General Public License version 2,
# # as published by the Free Software Foundation
# #
# # This program is distributed in the hope that it will be useful,
# # but WITHOUT ANY WARRANTY; without even the implied warranty of
# # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# # GNU General Public License for more details.
# #
# # http://www.gnu.org/licenses/gpl.txt
# #
#
# insert m3u playlist files into MythMusic DB
# build m3u playlist files from MythMusic DB
#
#
# Version: 0.02162005 + fixes for Myth 0.20 by Allen Hainer

use Getopt::Long;
use DBI;
use MP3::Info;
                                                                                                                                               
my $DBuser = 'mythtv';
my $DBpass = 'mythtv';
my $DBhost = 'localhost';
my $FEhost = 'myth';
my %playlist;
my %playlist_id;
my $playlistname;
my $filename;
my $mode = 0;
my $force = 0;
my $dbh;

print "\n---------------------------------------\n";
print "m3u <==> MythMusic DB Conversion Script\n";
print "---------------------------------------\n\n";
GetOptions (
   'file=s'    => \$filename,
   'name=s'    => \$playlistname,
   'id=i'      => \$playlist_id,
   'user=s'    => \$DBuser,
   'pass=s'    => \$DBpass,
   'host=s'    => \$DBhost,
   'fehost=s'  => \$FEhost,
   'list'      => sub { $mode = 1; },
   'toDB'      => sub { $mode = 2; },
   'toM3U'     => sub { $mode = 3; },
   'force'     => sub { $force = 1; },
);

if ($mode == 1) {
   $dbh = DBI->connect("dbi:mysql:database=mythconverg;host=$DBhost;user=$DBuser;password=$DBpass") || die "$DBI::errstr";
   &listDB();
} elsif ($mode == 2) {
   $dbh = DBI->connect("dbi:mysql:database=mythconverg;host=$DBhost;user=$DBuser;password=$DBpass") || die "$DBI::errstr";
   if (defined($filename) && defined($playlistname)) {   
      &readM3U();
      &writeDB();
   } else {
      print "ERROR: --toDB requires: --file & --name\n";
   }
} elsif ($mode == 3) {
   $dbh = DBI->connect("dbi:mysql:database=mythconverg;host=$DBhost;user=$DBuser;password=$DBpass") || die "$DBI::errstr";
   if (defined($filename) && defined($playlist_id)) {   
      &readDB($playlist_id);
      &writeM3U($playlist_id);
   } else {
      print "ERROR: --toM3U requires: --file & --id\n";
   }
} else { &showHelp(); }
exit(0);

sub showHelp {
   print "Usage:\n";
   print " $0\n";
   print "   --list\t\t\t [list Playlists in DB]\n";
   print "   --toDB\t\t\t [Load m3u file into DB]\n";
   print "   --toM3U\t\t\t [Build m3u file from DB]\n";
   print "   --file <file.m3u>\t\t [m3u playlist file]\n";
   print "   --id 'playlist id'\t\t [DB playlist id number]\n";
   print "   --force\t\t\t [Override File/DB entry exists errors]\n";
   print "   --name 'playlist name'\t [name for playlist (db/file)]\n";
   print "   --fehost 'hostname'\t\t [MythTV Frontend Hostname]\n";
   print "   --user 'username'\t\t [DB user -- Default: $DBuser]\n";
   print "   --pass 'password'\t\t [DB password -- Default: $DBpass]\n";
   print "   --host 'hostname'\t\t [DB host -- Default: $DBhost]\n";
}

sub listDB {
   $sth = $dbh->prepare("SELECT playlist_id,playlist_name,hostname FROM music_playlists;");
   $sth->execute || die "Unable to execute query: $dbh->errstr\n";
                 
   print "Current playlist(s) in DB:\n";                                                                                                                               
   while($row = $sth->fetchrow_arrayref)
   {
      print "ID: $row->[0]\t Name: $row->[1]\t Host: $row->[2]\n";
   }
}

sub readDB {
   my $playlist_id = $_[0];
   my @songids;

   print "Retrieving playlist: $playlist_id...\n";
   $sth = $dbh->prepare("SELECT playlist_name,playlist_songs,hostname FROM music_playlists WHERE playlist_id=$playlist_id;");
   $sth->execute || die "Unable to execute query: $dbh->errstr\n";
                                                                                                                                               
   while($row = $sth->fetchrow_arrayref)
   {
      $playlist{$playlist_id}{'playlist_name'} = $row->[0];
      @songids = split /,/, $row->[1];
      $playlist{$playlist_id}{'hostname'} = $row->[2];
   }

   foreach(@songids) {
      if ($_ < 0) {
         print "Playlist contains sub-playlist ($_)...\n";
         $playlist{$playlist_id}{'playlist_songs'} = $playlist{$playlist_id}{'playlist_songs'} . &readDB(0 - $_) . ",";
      } else {
         $playlist{$playlist_id}{'playlist_songs'} = $playlist{$playlist_id}{'playlist_songs'} . $_ . ",";
      }
   }
   chop($playlist{$playlist_id}{'playlist_songs'});

   return($playlist{$playlist_id}{'playlist_songs'});
}


sub writeDB {
   my $playlist_songs;

   $sth = $dbh->prepare("SELECT * FROM music_playlists WHERE name=\"$playlistname\" AND hostname=\"$FEhost\";");
   $sth->execute || die "Unable to execute query: $dbh->errstr\n";
   if ($sth->rows() > 0) {
      if ($force == 0) {
         print "DB: $playlistname already exists. Use --force to override.\n";
         exit(1);
      }
      else {
         $sth = $dbh->prepare("DELETE FROM music_playlists WHERE name=\"$playlistname\" AND hostname=\"$FEhost\";");
         $sth->execute || die "Unable to execute query: $dbh->errstr\n";
      }
   }

   foreach $file (@{ $playlist{'m3u'} }) {
      $sth = $dbh->prepare("SELECT intid FROM musicmetadata WHERE filename=\"$file\";");
      $sth->execute || die "Unable to execute query: $dbh->errstr\n";
 
      while($row = $sth->fetchrow_arrayref)
      {
         $playlist_songs = $playlist_songs . $row->[0] . ",";
      }
   }
   chop($playlist_songs);

   print "Inserting new playlist to DB: $playlistname:$playlist_songs\n";
   $sth = $dbh->prepare("INSERT INTO music_playlists (name,playlist_songs,hostname) VALUES (\"$playlistname\",\"$playlist_songs\",\"$FEhost\");");
   $sth->execute || die "Unable to execute query: $dbh->errstr\n";
}

sub readM3U {
   print "Reading data from m3u file...\n";
   open(HAND, "$filename") || die("unable to open m3u file: $!");
   while(<HAND>) {
      chomp;
      next if /^#EXT/;
      push @{ $playlist{'m3u'} }, $_;
   }
   close(HAND);
}

sub writeM3U {
   my $playlist_id = $_[0];

   print "Writing playlist ($playlist{$playlist_id}{'name'}) to m3u file...\n";   
   my @songids = split /,/, $playlist{$playlist_id}{'playlist_songs'};

   if ((-e $filename) && ($force == 0)) {   
      print "FILE: $filename already exists. Use --force to override.\n";
      exit(1);
   }
   open(HAND, ">$filename") || die("unable to open m3u output file: $!");
   print HAND "#EXTM3U\n";
   foreach(@songids) {
      $sth = $dbh->prepare("SELECT filename FROM music_songs WHERE song_id=\"$_\";");
      $sth->execute || die "Unable to execute query: $dbh->errstr\n";
           
      while($row = $sth->fetchrow_arrayref)
      {
         my $mp3Tag = get_mp3tag($row->[0],2,1);
         my $mp3Info = get_mp3info($row->[0],2,1);
         $mp3Tag->{'TPE1'} =~ tr/\000-\010//d;
         $mp3Tag->{'TIT2'} =~ tr/\000-\010//d;
         print HAND "#EXTINF:" . int($mp3Info->{'SECS'}) . "," . $mp3Tag->{'TPE1'} . " - $mp3Tag->{'TIT2'}\n";
         print HAND "$row->[0]\n";
      }
   }
   close(HAND);
}

_________________
ASUS AT3N7A-I (Atom 330)
TBS 8922 PCI (DVB-S2)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 02, 2007 1:02 pm 
Offline
Joined: Sat Feb 04, 2006 1:36 pm
Posts: 3
Thanks a bunch for the working script alien!
I haven't been here for a while so i missed your update.

/Peter


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 


All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 20 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu