Page: 1, 2, 3, 4  Next

acxi - audio conversion flac to ogg / mp3 script - sync data
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 4128
Location: East Coast, West Coast? I know it's one of them.
Reply Quote
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.

Github: github.com/smxi/acxi

Version History:
  • 3.3.12 - 2019-08-12 - added --aggregate/-G and --alt-ag [track id] to allow for collecting auto.tag or other file names in one directory, to help distribute to others, or see which you have updated with those file names.
  • 3.3.05 - 2019-08-10 - added --autotag-create-multi. Supports numbering of disks/tracks in multidisk sets.
  • 3.3.03 - 2019-08-09 - added --checksum-verify/-V, verifies checksums and flac integrity.
  • 3.3.0 - 2019-07-27 - Rolled together all recent updates, added doc pages at: smxi.org/docs/acxi-man.htm and smxi.org/docs/acxi-options.htm
  • 3.2.16 - 2019-07-27 - added --update/-U self updater, makes getting newest easier.
  • 3.2.11 - 2019-07-27 - added --autotag-create-single/-S. Auto number single disk collections.
  • 3.2.8 - 2019-07-26 - added --autotag-create/-C. Second part of autotagging suite.
  • 3.2.4 - 2019-07-24 - added --autotag/-A. First part of auto tagging suite.
  • 3.2.2 - 2019-07-21 - added --checksum, --chedksum-delete, to make new ffp and md5 checksum files, and delete old ones if you want.
  • 3.2.0 - 2019-07-15 - Added --forking, for multithreaded syncing operations. Added shn -> flac converter. New option --append, so you can add to copy list. Got rid of legacy print output control terms, added -log [0-4] to make output controls easier to remember.
  • 3.1.0 - 2018-12-18 - Added Opus output type. Updated man/help to be more clear and unconfusing.
  • 3.0.0 - 2018-12-11 - Fixed MP3 tagging bugs. Added --test flag to allow testing of configurations. Refactored completely, to modern Perl, added warnings/strict, and set for Perl 5.010 or newer explicitly. Cleaned up and made more consistent output formatting and widths. Added a man page, for any packagers out there who might want to package it. Removed most shell subshell commands and replaced them with Perl native features. This also means you can in theory run acxi on Mac OSX or Windows. Not tested, but it should work if you put in the right paths. Improved error handling. Note I tested with $ in the music file name, and it worked fine, so I removed that filter for now. Added --clean option to remove files/directories from destination not found in source. Use with care!!
  • 2.9.0 - 2011-07-26 - 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 - 2011-03-23 - 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 - 2011-03-22 - 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 - 2010-04-12 - Added more defaults to list of file types: 'tif', 'doc', 'docx', 'odt'
  • 2.6.0 - 2010--2-12 -
    • 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.

See online options html page for current options: smxi.org/docs/acxi-options.htm

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
Back to top
The script fails if you have dollars in your filenames
joelwright
Status: New User - Welcome
Joined: 26 Jul 2011
Posts: 1
Reply Quote
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";

Back to top
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 4128
Location: East Coast, West Coast? I know it's one of them.
Reply Quote
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.
Back to top
etique
Status: Curious
Joined: 27 Oct 2011
Posts: 7
Location: France
Reply Quote
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 :)
Back to top
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 4128
Location: East Coast, West Coast? I know it's one of them.
Reply Quote
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.
Back to top
etique
Status: Curious
Joined: 27 Oct 2011
Posts: 7
Location: France
Reply Quote
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...
Back to top
etique
Status: Curious
Joined: 27 Oct 2011
Posts: 7
Location: France
Reply Quote
Doesn't check the files though. I'll work on that.
Back to top
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 4128
Location: East Coast, West Coast? I know it's one of them.
Reply Quote
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.
Back to top
etique
Status: Curious
Joined: 27 Oct 2011
Posts: 7
Location: France
Reply Quote
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.";
      }
   }
}

Back to top
etique
Status: Curious
Joined: 27 Oct 2011
Posts: 7
Location: France
Reply Quote
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.
Back to top
Display posts from previous:   
Page: 1, 2, 3, 4  Next
All times are GMT - 8 Hours