Home of the Squeezebox™ & Transporter® network music players.
Page 1 of 11 123 ... LastLast
Results 1 to 10 of 102
  1. #1
    Senior Member chill's Avatar
    Join Date
    Mar 2007
    Location
    Nottingham, UK
    Posts
    1,652

    How can I maintain a compressed copy of my music folder?

    Looking for advice/experience, especially if it's relevant to Linux, particularly pCP.

    My music library sits on a hard disk attached to a Raspberry Pi (3B+) pCP server via USB - this drive is shared on the network via Samba. I have another Raspberry Pi (Zero W), also running pCP, that mounts this drive as a network share. This second RPi has a backup hard drive attached via USB that maintains an exact copy of the main library via a cron job that runs rsync once a day.

    What I'd like to do in addition is maintain a second, compressed (MP3), copy of the main library in a separate folder on the backup disk. I'll use this as a 'portable' copy that I can copy to a flash drive for use in another pCP in my camper van. I expect another cron job, running a transcoding script of some sort, would be the way to go, but what should go in that script?

    My desired script will only have to deal with 'whole album' FLAC files with associated CUE files (all other types of file will be dealt with in a one-off initial copy/transcode task). I think I'd want to transcode these to per-track MP3s, although if it's feasible to convert a 'whole album' FLAC file to a 'whole album' MP3, and automatically (via a script) adjust the CUE file to work with this MP3 file then I'd be interested.

    So how would I go about this? Could I somehow configure rsync to create a file list of changed files, to determine when files need to be added to the portable copy? What software would I use on a pCP to transcode a whole album FLAC file into single-track MP3 files, and how could I script this?

  2. #2
    Senior Member
    Join Date
    Feb 2011
    Location
    Cheshire, UK
    Posts
    5,002
    Quote Originally Posted by chill View Post
    Looking for advice/experience, especially if it's relevant to Linux, particularly pCP.

    My music library sits on a hard disk attached to a Raspberry Pi (3B+) pCP server via USB - this drive is shared on the network via Samba. I have another Raspberry Pi (Zero W), also running pCP, that mounts this drive as a network share. This second RPi has a backup hard drive attached via USB that maintains an exact copy of the main library via a cron job that runs rsync once a day.

    What I'd like to do in addition is maintain a second, compressed (MP3), copy of the main library in a separate folder on the backup disk. I'll use this as a 'portable' copy that I can copy to a flash drive for use in another pCP in my camper van. I expect another cron job, running a transcoding script of some sort, would be the way to go, but what should go in that script?

    My desired script will only have to deal with 'whole album' FLAC files with associated CUE files (all other types of file will be dealt with in a one-off initial copy/transcode task). I think I'd want to transcode these to per-track MP3s, although if it's feasible to convert a 'whole album' FLAC file to a 'whole album' MP3, and automatically (via a script) adjust the CUE file to work with this MP3 file then I'd be interested.

    So how would I go about this? Could I somehow configure rsync to create a file list of changed files, to determine when files need to be added to the portable copy? What software would I use on a pCP to transcode a whole album FLAC file into single-track MP3 files, and how could I script this?
    Can't answer the scripting question but wondering which MP3 players (apart from LMS) can actually read cue files i.e. is there any point in creating them?
    VB2.4 storage QNAP TS419p (NFS)
    Living Room - Joggler & SB3 -> Onkyo TS606 -> Celestion F20s
    Office - Pi3+Sreen -> Sony TAFE320 -> Celestion F10s / Pi2+DAC & SB3 -> Onkyo CRN755 -> Wharfedale Modus Cubes
    Dining Room -> SB Boom
    Kitchen -> UE Radio (upgraded to SB Radio)
    Bedroom (Bedside) - Pi2+DAC ->ToppingTP21 ->AKG Headphones
    Bedroom (TV) - SB Touch ->Sherwood AVR ->Mordaunt Short M10s
    Everything controlled by iPeng

  3. #3
    Senior Member chill's Avatar
    Join Date
    Mar 2007
    Location
    Nottingham, UK
    Posts
    1,652
    Quote Originally Posted by d6jg View Post
    Can't answer the scripting question but wondering which MP3 players (apart from LMS) can actually read cue files i.e. is there any point in creating them?
    I agree that file-per-track MP3s will be more versatile in that respect, but I'll be using LMS in my camper (RPi 3A+) so it doesn't matter to me at this stage if my CUE sheets would be a bit 'niche'.

    Had a quick look at sox, and couldn't immediately see a way to split a FLAC into MP3s using a CUE sheet, so in fact editing the CUE sheet to suit a transcoded 'whole album' MP3 might not be such a bad idea. I'll have a play to see what changes might be required.

  4. #4
    Senior Member
    Join Date
    Apr 2005
    Location
    UK/London
    Posts
    2,919
    I suspect it would be easiest to keep the MP3 as whole album (unless there is a clever tool that reads .cue files to do the splits) and then change the contents of the .cue to refer to the new .mp3 instead of the .flac

    pCP has LAME installed I think (if not - then it can be added) so you could probably have something like
    lame --resample 44.1 -b 128 infile.flac infile.mp3

    then use SED to change the contents of the .cue file

    sed 's/flac/mp3/g' infile.cue

    If you get that working from the command line first ... then you could put it into a shell scripts and take "infile" as a parameter.
    Paul Webster
    http://dabdig.blogspot.com
    Author of "Now Playing" plugins covering Radio France (FIP etc), KCRW, Supla Finland, ABC Australia, CBC/Radio-Canada and RTE Ireland

  5. #5
    Senior Member chill's Avatar
    Join Date
    Mar 2007
    Location
    Nottingham, UK
    Posts
    1,652
    Thanks Paul - I'll give those a try.

  6. #6
    Senior Member
    Join Date
    Feb 2011
    Location
    Cheshire, UK
    Posts
    5,002
    Quote Originally Posted by chill View Post
    I agree that file-per-track MP3s will be more versatile in that respect, but I'll be using LMS in my camper (RPi 3A+) so it doesn't matter to me at this stage if my CUE sheets would be a bit 'niche'.

    Had a quick look at sox, and couldn't immediately see a way to split a FLAC into MP3s using a CUE sheet, so in fact editing the CUE sheet to suit a transcoded 'whole album' MP3 might not be such a bad idea. I'll have a play to see what changes might be required.
    So its a Pi in a camper. Why bother with compressed files at all? Is your library of FLACs that large that it won't fit on a USB disk or is it a question of power?
    VB2.4 storage QNAP TS419p (NFS)
    Living Room - Joggler & SB3 -> Onkyo TS606 -> Celestion F20s
    Office - Pi3+Sreen -> Sony TAFE320 -> Celestion F10s / Pi2+DAC & SB3 -> Onkyo CRN755 -> Wharfedale Modus Cubes
    Dining Room -> SB Boom
    Kitchen -> UE Radio (upgraded to SB Radio)
    Bedroom (Bedside) - Pi2+DAC ->ToppingTP21 ->AKG Headphones
    Bedroom (TV) - SB Touch ->Sherwood AVR ->Mordaunt Short M10s
    Everything controlled by iPeng

  7. #7
    Senior Member chill's Avatar
    Join Date
    Mar 2007
    Location
    Nottingham, UK
    Posts
    1,652
    Quote Originally Posted by d6jg View Post
    So its a Pi in a camper. Why bother with compressed files at all? Is your library of FLACs that large that it won't fit on a USB disk or is it a question of power?
    It'll fit on a USB disk (that's where it is now), and power isn't an issue. I'd just prefer to have a nice compact solid state USB flash drive, rather than another device that will need securing down. I'm even toying with the idea of a third partition on the micro SD card - a 128GB card should be sufficient if everything is converted to MP3.

  8. #8
    Senior Member
    Join Date
    Apr 2005
    Location
    UK/London
    Posts
    2,919
    I did not check that lame can read flac ... if it cannot then something like this should work (would need to install ffmpeg ... and best to get it from pCP repo not the piCore one).

    for f in *.flac; do ffmpeg -i "$f" -b:a 128k "${f%flac}mp3"; done
    Paul Webster
    http://dabdig.blogspot.com
    Author of "Now Playing" plugins covering Radio France (FIP etc), KCRW, Supla Finland, ABC Australia, CBC/Radio-Canada and RTE Ireland

  9. #9
    Senior Member chill's Avatar
    Join Date
    Mar 2007
    Location
    Nottingham, UK
    Posts
    1,652
    Quote Originally Posted by Paul Webster View Post
    I did not check that lame can read flac ... if it cannot then something like this should work (would need to install ffmpeg ... and best to get it from pCP repo not the piCore one).

    for f in *.flac; do ffmpeg -i "$f" -b:a 128k "${f%flac}mp3"; done
    Good grief - thanks Paul. I shall give that a try. There's a whole scripting lesson in that one line! Am I right that that only looks for flacs in the current directory? Is there an easy way to make it recurse through all the subdirectories as well?

    Before you posted that, I did install pcp-lame, and it didn't recognise my flac file. So I installed pcp-flac, then googled a way to chain them together:

    flac --decode --stdout test.flac | lame --preset extreme - test.mp3

    A single 250MB flac took ages to convert on my Pi Zero W. It would make sense to use a faster machine for the initial bulk conversion. For future additions to the library it won't matter that it's a bit slow with one or two disks at a time.

    I haven't tried the resulting mp3 file with an edited cue sheet in LMS yet - a job for later this evening.
    Last edited by chill; 2019-04-24 at 11:13.

  10. #10
    Senior Member
    Join Date
    Apr 2005
    Location
    UK/London
    Posts
    2,919

    How can I maintain a compressed copy of my music folder?

    I found that line somewhere else and yes, it would only do the current directory.
    The minimal shell in pCP might mean that some scripting bits need to be tweaked.

    A full version for you would probably need to check the exit status and remove the .flac if it looked like the writing of the .mp3 worked.
    Paul Webster
    http://dabdig.blogspot.com
    Author of "Now Playing" plugins covering Radio France (FIP etc), KCRW, Supla Finland, ABC Australia, CBC/Radio-Canada and RTE Ireland

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •