{"id":1983,"date":"2018-09-16T19:08:03","date_gmt":"2018-09-16T19:08:03","guid":{"rendered":"http:\/\/blog.paranoidprofessor.com\/?p=1983"},"modified":"2018-09-16T19:08:03","modified_gmt":"2018-09-16T19:08:03","slug":"ripping-compact-discs-to-audio-files","status":"publish","type":"post","link":"https:\/\/blog.paranoidprofessor.com\/index.php\/2018\/09\/16\/ripping-compact-discs-to-audio-files\/","title":{"rendered":"ripping compact discs to audio files"},"content":{"rendered":"<p>Perhaps it is not necessary for another article about how to convert cd&#8217;s to a format that can be used on our mp3 or ogg music players. \u00a0I have used k3b program for extracting ogg files in the past.<\/p>\n<p>I suspect that there are also a number of similar programs on the windows side that are just as easy to use. \u00a0I would have used this method but I had a small stack of disc&#8217;s that needed to be ripped and I would prefer to just kick off a command line to do the task.<\/p>\n<p>There already exists a fabulous script called &#8220;abcde&#8221; for doing most of this work. \u00a0This script extracts the audio data as wav data and then uses the desired codec for converting this wav data into the new format (ie mp3 or ogg).<\/p>\n<p>The abcde script also downloads the names of the songs as well as the album art (for abcde version 2.7 and higher).<\/p>\n<p>I knocked together the following script which will extract either ogg or mp3 files and rename the temporary directory into the name of the album. \u00a0By default, this script will call abcde and convert the ripped files to ogg format. \u00a0If this script is called with mp3 it will then rip the files and convert them to mp3.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nFORMAT=ogg\r\nif [ $# -eq 1 ]\r\nthen\r\n   FORMAT=$1\r\nfi\r\n\r\nTMPDIR=abcde.`cd-discid | sed 's\/ .*\/\/'`\r\n\r\nabcde -N -g -d \/dev\/sr0 -a read,encode,tag,getalbumart,clean -o $FORMAT -x\r\n\r\ncd $TMPDIR\r\n\r\nCNT=$((`cat cddbchoices | wc -l` - 2))\r\nIDX=1\r\n\r\nwhile [ $CNT -gt 1 ]\r\ndo\r\n  TRACK=`tail -$CNT cddbchoices | head -1`\r\n  TRACK=`echo $TRACK | sed 's\/^..: \/\/'`\r\n  TRACK=`echo $TRACK | sed 's\/^.: \/\/'`\r\n\r\n  TRACK=`echo $TRACK | sed 's\/ \/_\/g' | sed 's\/[^a-zA-Z0-9_-]\/\/g'`\r\n\r\n  FILENAME=$IDX\r\n  if [ $IDX -lt 10 ]\r\n  then\r\n    FILENAME=0$IDX\r\n  fi\r\n\r\n  DEST_FILENAME=&quot;$FILENAME - $TRACK.$FORMAT&quot;\r\n  SRC_FILENAME=track${IDX}.$FORMAT\r\n\r\n  if [ -f $SRC_FILENAME ]\r\n  then\r\n     echo mv &quot;$SRC_FILENAME&quot; &quot;$DEST_FILENAME&quot;\r\n     mv &quot;$SRC_FILENAME&quot; &quot;$DEST_FILENAME&quot;\r\n  fi\r\n\r\n  CNT=$(($CNT - 1))\r\n  IDX=$(($IDX + 1))\r\nCNT=1\r\ndone\r\n\r\nALBUM=`head -2 cddbchoices | tail -1 | sed 's\/ \/_\/g' | sed 's\/[^a-zA-Z0-9_]\/\/g'`\r\nALBUM=`echo $ALBUM | sed 's\/^_\/\/g'`\r\nALBUM=`echo $ALBUM | sed 's\/_$\/\/g'`\r\n\r\ncd ..\r\nmv $TMPDIR $ALBUM\r\necho $ALBUM\r\n<\/pre>\n<p>To be honest all of this scripting should be unnecessary. \u00a0Logic exists for doing all of this for you. \u00a0Simply change the configuration file to select the output format.<\/p>\n<p>The standard configuration file \/etc\/abcde.conf allows for a lot of individual configuration. \u00a0Simply uncomment the OUTPUTFORMAT variable and change it to fit your needs.<\/p>\n<pre class=\"bbcode_code\">#OUTPUTFORMAT='${ARTISTFILE}-${ALBUMFILE}\/${TRACKNUM}.${TRACKFILE}'<\/pre>\n<p>For reasons unknown, this didn&#8217;t work for me. \u00a0Nor did creating a configuration file <strong>.abcde.conf<\/strong> in my home directory.<\/p>\n<p>There is a lot information on the internet about how to use or configure and use this utility.<\/p>\n<p><a href=\"http:\/\/www.andrews-corner.org\/linux\/abcde\/index.html\">http:\/\/www.andrews-corner.org\/linux\/abcde\/index.html<\/a><\/p>\n<p><a href=\"https:\/\/www.mankier.com\/1\/abcde\">https:\/\/www.mankier.com\/1\/abcde<\/a><\/p>\n<p>One of the more interesting things about the abcde script is that you can create multiple output files at the same time. \u00a0It is possible to create both mp3 and ogg files at the same time. \u00a0If both types of files are required then this is actually the fastest way to convert into both types of data.<\/p>\n<p>Simply create a list of all formats when running the script.<\/p>\n<pre class=\"bbcode_code\">-o mpg,ogg<\/pre>\n<p>Note: After writing this small script I discovered it didn&#8217;t work. \u00a0Well, it worked just fine for CD&#8217;s that only had one IMDB entry. \u00a0Even not using my script, the abcde script is fabulously useful.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Perhaps it is not necessary for another article about how to convert cd&#8217;s to a format that can be used on our mp3 or ogg music players. \u00a0I have used k3b program for extracting ogg files in the past. I &hellip; <a href=\"https:\/\/blog.paranoidprofessor.com\/index.php\/2018\/09\/16\/ripping-compact-discs-to-audio-files\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[20],"tags":[17,39],"_links":{"self":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts\/1983"}],"collection":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/comments?post=1983"}],"version-history":[{"count":6,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts\/1983\/revisions"}],"predecessor-version":[{"id":2276,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts\/1983\/revisions\/2276"}],"wp:attachment":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/media?parent=1983"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/categories?post=1983"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/tags?post=1983"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}