Page: 1, 2, 3  Next

techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 3485
Location: East Coast, West Coast? I know it's one of them.
Back to top
Posted: Feb 9, 10, 15:50    acxi - audio conversion flac to ogg / mp3 script - sync data
acxi (click to open file, or right click and use the Save As option, in most browsers) is an expanded, cleaned up, and feature enhanced fork of the original logic of the classic flac2ogg.pl script.

Version History:
  • 2.9.0 - 26 July 2011 - Added patch to support $ character in file names. Updated verbosity levels to use the method that will run in version 3.0, which if you had set B_QUIET or B_SILENT in your user config file will require changing that to LOG_LEVEL=<0-3> (for example: LOG_LEVEL=2
  • 2.8.0 - 23 March 2011 - Added new options: --quiet and --silent. --quiet turns off flac/oggenc/lame output. --silent activates --quiet and also minimizes screen output to the bare minimum required, no lines or extra graphical elements, and less text.
  • 2.7.0 - 22 March 2011 - Added Flac -> MP3 ID3 tagging. This fixes a long time functional absence. MP3 ID3 tagging patch created by Odd Eivind Ebbesen.
    Fixed a few long standing little glitches, now -h/--help will read your user config files if you have it and show the right paths etc if you have them set in configs. A few smaller output glitches and errors also corrected, and cleaned up code a bit as well.
  • 2.6.1: 12 April 2010
    Added more defaults to list of file types: 'tif', 'doc', 'docx', 'odt'
  • 2.6.0: 12 February 2010
    • Added -c/---copy option to allow for user set files to sync/copy types. Overrides defaults.
    • Structured code further to allow for /etc/acxi.conf as well as $HOME/.acxi.conf files to override defaults.
    • Reordered globals to be more clear and user readable.

In addition to converting flac (or wav, raw, with ogg output) to ogg or mp3, acxi also copies over all txt, bmp, jpg, and pdf files from the source/flac directories to the new destination/ogg (or mp3) directories, which is convenient if you are ripping flac torrents with their data stuff to ogg/mp3.

I'll probably add more features over time, once I figure out how perl actually works, but for now it's all working nicely, it's been cleaned up and put into structured functions to make it more powerful and useful.

To get it, do this:
:: Code ::
cd /usr/local/bin && wget -Nc smxi.org/acxi && chmod +x acxi


See acxi -h
for list of supported options.
then edit the top variables to fit your system as defaults, most can be overridden with options however.

:: Code ::
acxi -h
acxi v: 2.9.0 :: Supported Options:
Examples: acxi -q 8 --destination /music/main/ogg
acxi --input wav --output ogg
acxi --copy doc,docx,bmp
-----------------------------------------------------------------
--copy -c         List of alternate data types to copy to Output type directories.
                  Must be comma separated, no spaces, see sample above.
                  Your current copy types are: bmp jpg jpeg tif doc docx odt pdf txt
--debug           Full screen output, including full verbosity of flac/oggenc/lame
                  conversion process for MP3 or OGG output.
--default         Single line per operation screen output, default value for acxi.
--destination -d  The path to the directory where you want the processed (eg, ogg) files to go.
                  Your current script default is: /path/to/your/output/directory
--force -f        Overwrite the ogg/jpg/txt files, even if they already exist.
--help -h         This help menu.
--input -i        Input type: supported - flac, wav, raw. mp3 only supports flac input.
                  Your current script default is: flac
--output -o       Output type: supported - ogg, mp3.
                  Your current script default is: ogg
--quality n -q n  For ogg: n can be 1-10, 10 is the biggest file/highest quality.
                  For mp3: n can be 0-9 (variable bit rate), 0 biggest file/highest quality.
                  Your current script default is: 7
--quiet --silent  Turns off all screen output, except for error messages.
--source -s       The path to the top-most directory containing your source files (eg, flac).
                  Your current script default is: /home/fred/music/flac
--verbose         Without full verbosity of debug, no flac/oggenc/lame for MP3 or OGG
                  conversion process screen output, but more verbose than default.
--version -v      Show acxi version.

-----------------------------------------------------------------
User Configs: $HOME/.acxi.conf or /etc/acxi.conf
Requires this syntax (any user modifiable variable can be used)
DIR_PREFIX_SOURCE=/home/me/music/flac
Do not use the $ or ", ' in the config data


Script features error handling for all user input, so it's a bit safer than the old flac2ogg.pl, which didn't do any checking of anything.

Currently supported:
output: ogg
input: wav, raw, flac
quality: 1-10

output: mp3
input: flac
quality: 0-9 ( uses -V n - variable bit rate, highest is lowest quality, lowest number, 0, is highest quality and largest)

Updated: as of version 2.7.x, acxi Flac to MP3 does now copy ID3 tags over to the MP# files from the Flac files, if present.

Copy types (sync from source to destination):
defauts: bmp jpg jpeg tif doc docx odt pdf txt
user set: any you want
joelwright
Status: New User - Welcome
Joined: 26 Jul 2011
Posts: 1
Back to top
Posted: Jul 26, 11, 5:18    The script fails if you have dollars in your filenames
Great work on the script, saved me a lot of time! I did come across one small bug with my library though - if files have a $ in the name the transcode fails with a file not found exception.

I've made a little patch that quotes dollars in the names if they exist.

:: Code ::
***************
*** 436,441 ****
--- 436,443 ----
        # or the srcfile is more recent then the dest file, we encode.
        if ( !$destInfo || $B_FORCE || ( $srcModTime > $destModTime) ) {
           $file =~ s/\`/\'/g;
+               $file =~ s/\$/\\\$/g;
+               $destinationFile =~ s/\$/\\\$/g;
           $inFile = "$DIR_PREFIX_SOURCE/$file" . "c";
           chop ($inFile);
           $outFile = "$DIR_PREFIX_DEST/$destinationFile" . "g";
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 3485
Location: East Coast, West Coast? I know it's one of them.
Back to top
Posted: Jul 26, 11, 12:43    
Version 2.9.0 features that patch, and also now has the new verbosity level method that 3.0 is going to have.

Those levels are: --default, single line per operation, same as earlier --silent

this is default, so if you want that, just leave it as is.

That's my preferred screen output mode for what it's worth, which is why it's now the default.

--debug is the old default, and is the full output, including flac, ogg, conversion output.

--verbose is a bit more verbose than --default, without the full conversion output from the flac/ogg/mp3 functions.

Thanks for the patch, hope you continue to find acxi useful, I certainly do.

Remember, if you create user config file, you don't need to update the actual script itself, and with version 3.0, you will have to use a user config file no matter what, so best to start now.

When will 3.0 come? Who knows, but I do see signs that it will support wav and other things, ie, it should be fairly complete, but I'm not the one doing the coding on it so whenever it will be ready is when it will be ready. But for now, 2.9 will work fine for everyone, 3 will simply have a few more options and features from what I understand.
etique
Status: Curious
Joined: 27 Oct 2011
Posts: 7
Location: France
Back to top
Posted: Oct 27, 11, 0:42    
I'm a happy user of your script.

I was wondering though if you planned to add multithread capabilities?

I've an Atom-based NAS and I'm sure the 3 other idle cores would be happy to participate to my daily mirroring effort :)
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 3485
Location: East Coast, West Coast? I know it's one of them.
Back to top
Posted: Oct 27, 11, 10:05    
Do I have any plans to multithread this basic perl script? No, I don't.

Will I accept an intelligently and competently written patch that seamlessly integrates into the existing code, alters no functionality, but adds multithreading? Yes, I will.
etique
Status: Curious
Joined: 27 Oct 2011
Posts: 7
Location: France
Back to top
Posted: Nov 8, 11, 22:35    
Well, not a multithread patch, but I just created a function that cleans the DEST path of folders that disappeared in the SOURCE path.

:: Code ::

sub clean_target_directories {
   my $dir; @dirs; $bDirDeleted;
   $bDirDeleted = '0';
   @dirs = `cd "$DIR_PREFIX_DEST" && find . -type d -print`;
   
   eval $PRINT_LINE_LARGE;
   if ( ! $B_SILENT ) {
      print "Checking to see if script needs to remove target directories...\n";
   }
   else {
      print "Update destination directories... ";
   }
   
   foreach $dir (@dirs) {
      $dir =~ s/\n$//;
      $dir =~ s/^\.\///;
      
      # check to see if the destination dir still exists
      if ( !(stat ("$DIR_PREFIX_SOURCE/$dir")) ) {
         # stat failed so delete the target directory
         eval $PRINT_LINE_SMALL;
         if ( ! $B_SILENT ) {
            print "REMOVING TARGET DIRECTORY:\n\t$DIR_PREFIX_DEST/$dir\n";
         }
         else {
            print "\nRemoving target directory: $dir";
         }
         $dir =~ s/\`/\'/g;
         $result = `cd "$DIR_PREFIX_DEST" && rm -R "$dir"`;
         $bDirDeleted = 'true';
         $B_DEST_CHANGED = 'true';
      }
   }
   if ( ! $bDirDeleted ){
      if ( ! $B_SILENT ) {
         print "No clean up required. Continuing...\n";
      }
      else {
         print "none required.";
      }
   }
}


I'm looking into multithreading just for curiosity sake, but it's way beyond my skills...
etique
Status: Curious
Joined: 27 Oct 2011
Posts: 7
Location: France
Back to top
Posted: Nov 9, 11, 4:33    
Doesn't check the files though. I'll work on that.
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 3485
Location: East Coast, West Coast? I know it's one of them.
Back to top
Posted: Nov 9, 11, 21:06    
looking good so far, once it's done looks like it will work.

Something like this will probably be an option, not a default though.
etique
Status: Curious
Joined: 27 Oct 2011
Posts: 7
Location: France
Back to top
Posted: Nov 29, 11, 21:10    
New function that clean the DEST folder. I recommend to use first the directory cleaning function and then this one, just to speed up the process.

:: Code ::

sub clean_target_files {
   my $file; @files; $sourceFile; $srcInfo;
   my $bFileDeleted;   
   $file = '';
   $rmFile = '';
   $sourceFile = '';
   $bFileDeleted = '0';
   $srcInfo = '';


   @files = `cd "$DIR_PREFIX_DEST" && find . -type f -print`;

   foreach $file (@files) {
      $file =~ s/\n$//;
      $file =~ s/^\.\///;
      #print "F: $DIR_PREFIX_DEST/$file\n";
      
      # Figure out what the source file would be...
      $sourceFile = $file;
      $sourceFile =~ s/\.$OUTPUT_TYPE$/\.$INPUT_TYPE/; # Not replaced if not of $OUTPUT_TYPE
      #print "S: $DIR_PREFIX_SOURCE/$sourceFile\n";

      # Now stat the sourceFile, and see if it exists. If not delete the converted file
      $srcInfo = stat ("$DIR_PREFIX_SOURCE/$sourceFile");

      if ( !$srcInfo ) {
         $file =~ s/\`/\'/g;
         $rmFile = "$DIR_PREFIX_DEST/$file" . "g";
         chop ($rmFile);
         eval $PRINT_LINE_SMALL;
         if ( ! $B_SILENT ) {
            print "REMOVE: $file\n";
         }
         else {
            print "\nRemoving $file...";
         }
         $rmFile =~ s/\0//g;
         #print "R: $rmFile\n";
         $result = `rm "$rmFile"`;
         $bFileDeleted = 'true';
         $B_DEST_CHANGED = 'true';
      }
   }
   if ( ! $bFileDeleted ){
      if ( ! $B_SILENT ) {
         print "No files to remove from the destination folder\n";
      }
      else {
         print "everything is clean.";
      }
   }
}
etique
Status: Curious
Joined: 27 Oct 2011
Posts: 7
Location: France
Back to top
Posted: Nov 30, 11, 23:38    
Ok made some good progress on the multithread side :)

Need to use Thread::Queue to limit the number of concurrent threads (my first test resulted in n threads, n being the number of FLAC files needing to be converted, which is a bit too much ;))

Should come back soon with a proper patch.
Display posts from previous:   
Page: 1, 2, 3  Next
All times are GMT - 8 Hours