{"id":2000,"date":"2022-01-23T20:11:44","date_gmt":"2022-01-24T00:11:44","guid":{"rendered":"https:\/\/lowtek.ca\/roo\/?p=2000"},"modified":"2022-01-23T20:11:44","modified_gmt":"2022-01-24T00:11:44","slug":"ripping-cds-to-flac-on-linux","status":"publish","type":"post","link":"https:\/\/lowtek.ca\/roo\/2022\/ripping-cds-to-flac-on-linux\/","title":{"rendered":"Ripping CDs to FLAC on Linux"},"content":{"rendered":"<p>This weekend I was messing around with ripping CDs again. Almost my entire collection has been digital for years, but all in <a href=\"https:\/\/en.wikipedia.org\/wiki\/MP3\">MP3<\/a> format. Way back when ripping a CD to MP3 was a trade-off of time to encode, quality of playback, size of file I&#8217;d made some choices about what I was going to use as my standard for digitizing my collection.<\/p>\n<p>I arrived at <span class=\"detail\">192 kbps<\/span> encoding (fixed bitrate), MP3 format encoded with the LAME encoder for the most part. To arrive at this bitrate I&#8217;d done a lot of A\/B sampling between songs &#8211; with my best attempts at blind listening comparison to see which ones I could tell the difference between. After about 160 kbps I couldn&#8217;t hear any significant differences, and certainly after 192 kbps it was all the same. If you want to learn more about bitrates and encoding formats, this seems like a <a href=\"https:\/\/homedjstudio.com\/audio-bitrates-formats\/\">good article.<\/a><\/p>\n<p>Since then &#8211; computers have gotten stupidly faster, so encoding time doesn&#8217;t matter . Storage is also cheap and plentiful, so I don&#8217;t care about file sizes. My main media server is <a href=\"https:\/\/www.plex.tv\/\">Plex<\/a>, which will happily transcode from <a href=\"https:\/\/www.xiph.org\/flac\/\">FLAC<\/a> for me to MP3 when I need it. There is also the <a href=\"https:\/\/khenriks.github.io\/mp3fs\/\">mp3fs<\/a> userspace filesystem that I can use to map FLAC to MP3 when I need it. I&#8217;d arrived at the conclusion that my archive format should be FLAC a couple of years ago, but I&#8217;d failed to get Linux setup to rip successfully.<\/p>\n<p>With Windows machines there has been <a href=\"https:\/\/www.exactaudiocopy.de\/\">EAC<\/a> which is basically the default way people who care will rip their music. It ensures &#8216;perfect&#8217; copies. I found <a href=\"https:\/\/github.com\/whipper-team\/whipper\">whipper<\/a> which seemed to provide a similar solution on Linux, but a couple of years ago I failed to get this to work with either of the optical drives I have installed in my box. I could get all the tracks but the last one on the disc, very frustrating.<\/p>\n<p>In my recent revisit to this, I started with <a href=\"https:\/\/abcde.einval.com\/wiki\/\">abcde<\/a>. This resulted in a simple docker container that I could run that would rip a disc to FLAC without much fuss. It worked well, but then I re-discovered my notes on using whipper and figured I&#8217;d see if the project had progressed.<\/p>\n<p>It had &#8211; and whipper works great with one of my optical drives, but not the other. That&#8217;s fine as one is enough. My working drive is an <code>ASUS DRW-1814BL<\/code> and so far no problems except for one disc. The one problematic CD was one that I&#8217;d failed to rip in the past as well, there is a little bit of physical damage and whipper would bail dealing with the index.<\/p>\n<p>It turns out my abcde setup worked great on this bad CD and was able to rip it to FLAC. I&#8217;ve less confidence that the abcde process is as robust and exact as whipper &#8211; but I&#8217;d rather have the music ripped than not at all.<\/p>\n<p>For abcde I have a Makefile<\/p>\n<pre class=\"lang:default decode:true \">build:\r\n        docker build . --tag flac\r\n\r\n\r\nrun:\r\n        docker run \\\r\n                --device \/dev\/sr1 \\\r\n                -it \\\r\n                -v $(shell pwd)\/out:\/data \\\r\n                -e OUTPUTDIR=\/data \\\r\n                flac abcde -V -N -d \/dev\/sr1 -o flac\r\n<\/pre>\n<p>And a Dockerfile<\/p>\n<pre class=\"lang:default decode:true \">FROM ubuntu:latest\r\n\r\nRUN apt update\r\n\r\nRUN DEBIAN_FRONTEND=noninteractive apt install -y abcde flac\r\n<\/pre>\n<p>You&#8217;ll want to customize it to point at the right device, but there isn&#8217;t much here. Make build, make run and you&#8217;re good to go.<\/p>\n<p>For whipper, it&#8217;s ever easier. I just used a shell script to call the pre-built container.<\/p>\n<pre class=\"lang:default decode:true \">#!\/bin\/bash\r\ndocker run -ti --rm --device=\/dev\/sr0 \\\r\n    --mount type=bind,source=${PWD}\/config,target=\/home\/worker\/.config\/whipper \\\r\n    --mount type=bind,source=${PWD}\/output,target=\/output \\\r\n    whipperteam\/whipper cd rip\r\n<\/pre>\n<p>There is a little bit of setup for whipper, best to follow the <a href=\"https:\/\/github.com\/whipper-team\/whipper#getting-started\">documentation<\/a>. Briefly you need to analyze the drive and figure out the offset. I also tweaked the generated config file to change the directory and file naming scheme.<\/p>\n<p>That&#8217;s it. Ripping your CDs with high quality is trivial now, and with nicely featured media servers the format doesn&#8217;t matter. Now I just have to slowly re-rip CDs that I care about having high quality archives of.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This weekend I was messing around with ripping CDs again. Almost my entire collection has been digital for years, but all in MP3 format. Way back when ripping a CD to MP3 was a trade-off of time to encode, quality of playback, size of file I&#8217;d made some choices about what I was going to &hellip; <a href=\"https:\/\/lowtek.ca\/roo\/2022\/ripping-cds-to-flac-on-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Ripping CDs to FLAC on Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-2000","post","type-post","status-publish","format-standard","hentry","category-how-to"],"_links":{"self":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts\/2000","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/comments?post=2000"}],"version-history":[{"count":4,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts\/2000\/revisions"}],"predecessor-version":[{"id":2004,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts\/2000\/revisions\/2004"}],"wp:attachment":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/media?parent=2000"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/categories?post=2000"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/tags?post=2000"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}