thejasonparker Posted May 9, 2020 Posted May 9, 2020 (edited) After completing my Lidarr setup using the 'binhex lidarr' docker I noticed that most music files listed these days are in the FLAC format. Being old school and still using a iPod Video 5th Gen I wanted my collections to be in MP3 format so wanted a way to automatically convert these. I searched through the Lidarr GitHub and the unraid forums here and couldn't find a solution but did come across a Lidarr docker container which had the functionality via a shell script. https://hub.docker.com/r/thecaptain989/lidarr As I'd already setup Lidarr I wondered if it was possible to edit my docker container and apply the scripts from the above container. To my surprise the short answer is YES If this is something you want to do here's a short tutorial on how I did it... First, you ned to get access to your Lidarr Docker container. To do this I simply followed spaceinvaderone's YouTube tutorial - How to easily bash into a running docker container (NOTE: I had to use 'bash docker-shell' to run the command) Now I had access to the Lidarr container I needed to check to see of the two dependices 'ffmpeg' and 'awk' needed to run the 'flac2mp3.sh' script were already installed. This I did by just trying to run them and to my surprise both were already in the 'binhex-lidarr' container. ffmpeg awk The next stage was to get to the correct place to download and run the scripts from... cd /usr/local/bin/ Download the scripts from the GitHub repo.. curl -O https://raw.githubusercontent.com/TheCaptain989/lidarr-flac2mp3/7fda34528327e907cf583385c68260512ffb4ba3/flac2mp3.sh curl -O https://raw.githubusercontent.com/TheCaptain989/lidarr-flac2mp3/7fda34528327e907cf583385c68260512ffb4ba3/flac2mp3-debug.sh Make them executable... chmod +x flac2mp3.sh chmod +x flac2mp3-debug.sh Now, if you're happy to have 320Kbps MP3 conversions you can ignore this next section. The default output is 320kbps but if you want to change this because you have a large collection and file size is an important consideration (compare mp3 file sizes here https://audio-rescue.com/file-size/) you can do this by creating a 'wrapper' script which will send arguments to the 'flac2mp3.sh' script First, you'll need to create a new wrapper script so copy the debug script. Copy the 'flac2mp3-debug.sh' file cp flac2mp3-debug.sh flac2mp3-options.sh Edit it in nano nano flac2mp3-options.sh You can remove the 'debug logging' argument -d and add -b with your desired bitrate at the end like below and then save the file. #!/bin/bash . /usr/local/bin/flac2mp3.sh -b 190k You should be done with the terminal now Login to your unread server and go to your Lidarr Docker WebUI and go to 'Settings > Connect'. Create a 'Custom Script' trigger by selecting the + and then 'Custom Script'. Name it something like 'FLAC to MP3' and select 'On Release Import' and 'On Upgrade' as the only notification triggers (these have been tested). In the path find the script you just setup either the default script '/usr/local/bin/flac2mp3.sh' or your wrapper script. Click test to check and if all is good click save and you're done. Now when you download any Flac files once they have been downloaded and moved to your Lidarr directory they will be converted into mp3's You can see this happening if you open the directories as they are being processed. Huge thanks go to thecaptain989 who had done most of the work and @SpaceInvaderOne for the help on editing the doacker container files. Edited April 3, 2021 by thejasonparker Updated GitHub urls 1 Quote
JonathanM Posted May 9, 2020 Posted May 9, 2020 Something that may be of interest to you. I've never tried to set it up, but in principle it sounds like what you wanted to accomplish without losing the quality of the original lossless files. https://khenriks.github.io/mp3fs/ 1 Quote
thejasonparker Posted May 10, 2020 Author Posted May 10, 2020 Thanks for the info. It looks an interesting way of dealing with FLAC and MP3's files. Quote
Frod Posted November 21, 2020 Posted November 21, 2020 Hi all I was having a heck of a time getting this to work, lidarr would keep spitting out error 255 when i went to test the conection. I did some digging and discovered that the link https://raw.githubusercontent.com/TheCaptain989/lidarr-flac2mp3/master/flac2mp3.sh simply downloads a file containing the words "error 404 not found" if you replace the above link with https://raw.githubusercontent.com/TheCaptain989/lidarr-flac2mp3/7fda34528327e907cf583385c68260512ffb4ba3/flac2mp3.sh you can get the script to work within Lidarr, it looks like TheCaptain989 has stopped supporting this script over at github, and the link i have provided is the one that was likey used when thejasonparker wrote this original post. I am very very very new to all of this linux buisness so im sure anyone who reads this could come up with a beter way of fixing this tutorial, but it worked for me :) Hope i helped Frod 1 Quote
Kesp Posted December 1, 2020 Posted December 1, 2020 Any way this works already imported files? Quote
thejasonparker Posted April 3, 2021 Author Posted April 3, 2021 On 11/21/2020 at 8:34 AM, Frod said: Hi all I was having a heck of a time getting this to work, lidarr would keep spitting out error 255 when i went to test the conection. I did some digging and discovered that the link https://raw.githubusercontent.com/TheCaptain989/lidarr-flac2mp3/master/flac2mp3.sh simply downloads a file containing the words "error 404 not found" if you replace the above link with https://raw.githubusercontent.com/TheCaptain989/lidarr-flac2mp3/7fda34528327e907cf583385c68260512ffb4ba3/flac2mp3.sh you can get the script to work within Lidarr, it looks like TheCaptain989 has stopped supporting this script over at github, and the link i have provided is the one that was likey used when thejasonparker wrote this original post. I am very very very new to all of this linux buisness so im sure anyone who reads this could come up with a beter way of fixing this tutorial, but it worked for me Hope i helped Frod I've updated the guide with the new urls thanks to @Frod Quote
DreamKiller Posted June 14 Posted June 14 (edited) Adding an update to this guide in case someone else finds it like I did. Thanks to the OP for posting this guide, I wanted to do the same thing to auto convert FLAC files to smaller MP3 files and this put me on the right track. It seems that TheCaptain989 has continued his work on this and if you use the linuxserver/lidarr docker container, there is a easier way to add this and do it so that whenever the container is updated, this mod will also persist and be added to the update automatically. In the linuxserver/lidarr Unraid template, you just add the variable DOCKER_MODS with this value "thecaptain989/lidarr-flac2mp3:latest" and then apply the changes. This will pull in the scripts. Then in Lidarr add the Connection custom script as described above: And just like that it worked for me. And the mod should persist when linuxserver updates their lidarr container. Note that as is, this will convert to MP3 @ 320Kbps. Looks like you change this, but I haven't tried that yet (see readme at TheCaptain989). Update: Adding this environment variable to the Lidarr Unraid docker template, you can set the MP3 output bit rate to whatever you want. The below sets it to 256kbits/sec. And again, thanks to OP thejasonparker and TheCaptain989! Love this and works perfectly for me. Edited June 14 by DreamKiller Quote
XxStalker6052xX Posted June 16 Posted June 16 (edited) I've been searching for a way to batch convert FLAC to MP3, same basic reasons as thejasonparker, I want FLAC for home and mp3 for the lower data usage for streaming to my phone, etc., so I'm just wondering if anyone has a clear answer on does this replace your FLAC or can you save a copy? I'm going to set it up and install with just a few copied directories to see what happens but would appreciate any input from anyone? I'm just barely wrapping my head around all the docker stuff now... Edited June 16 by XxStalker6052xX spelling Quote
DreamKiller Posted June 16 Posted June 16 9 hours ago, XxStalker6052xX said: I've been searching for a way to batch convert FLAC to MP3, same basic reasons as thejasonparker, I want FLAC for home and mp3 for the lower data usage for streaming to my phone, etc., so I'm just wondering if anyone has a clear answer on does this replace your FLAC or can you save a copy? I'm going to set it up and install with just a few copied directories to see what happens but would appreciate any input from anyone? I'm just barely wrapping my head around all the docker stuff now... As set up as I described above, this does auto-convert to MP3 and then deletes the FLAC files since my goal is to save space. But reading the docs for lidarr-flac2mp3, you should be able to do what you want by adding the -k option to the FLAC2MP3_ARGS variable. Not sure how you would handle the noted operation though ("Note: This also disables importing the new files into Lidarr after conversion.") There is also a BATCH mode as described in the FLAC2MP3 dos you could use manually from a console terminal, but I haven't explored this yet. To really do what I think you want to do, you may need to have 2 instances of Lidarr, one for lossy MP3 and one for lossless. And 2 different libraries setup in Plex if that is what you use. Maybe look at RiffSphere Home Assistant YouTube channel. He shows how to do this. I have found that it is easier to find FLAC versions than MP3 so you would need to add the FLAC2MP3 mod to the lossy Lidarr instance and setup the qualities and profiles to get the FLAC files if that is all there is. However this seems to me that you are now downloading the same music twice if you have data limits on you internet. See these videos: Unraid - Lidarr: Install Unraid - Lidarr: Configuration Unraid - Lidarr-lossless: Install Unraid - Lidarr-lossless: Configuration Good luck! 1 Quote
XxStalker6052xX Posted June 20 Posted June 20 @DreamKiller, thank you for the detailed explanation! I'll hopefully get some time this coming weekend to take a look at it and see if I can get it setup like you said and watch those videos. I did install Lidarr and followed (I think) what you had said but I wasn't getting very far... I managed to import my test library but that was where it ended.. no conversion or anything... time is always my issue so hopefully I can get it sorted. I agree with the FLAC being easier to find, and yes I do have 2 libraries in Plex already as well as unlimited 3gb symetrical internet so I'm not worried about downloading or storage space right now Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.