zigford.org/burning-a-cd-cli-style.html
2020-07-21 06:49:32 +10:00

81 lines
3.6 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="main.css" type="text/css" />
<link rel="stylesheet" href="blog.css" type="text/css" />
<link rel="alternate" type="application/rss+xml" title="Subscribe to this page..." href="feed.rss" />
<title>Burning a CD CLI Style</title>
</head><body>
<div id="divbodyholder">
<div class="headerholder"><div class="header">
<div id="title">
<h1 class="nomargin"><a class="ablack" href="http://zigford.org/index.html">zigford.org</a></h1>
<div id="description"><a href="about.html">About</a><a href="links.html"> | Links</a><a href="scripts.html"> | Scripts</a><br>Sharing linux/windows scripts and tips</br></div>
</div></div></div>
<div id="divbody"><div class="content">
<!-- entry begin -->
<h3><a class="ablack" href="burning-a-cd-cli-style.html">
Burning a CD CLI Style
</a></h3>
<!-- bashblog_timestamp: #201812182246.18# -->
<div class="subtitle">December 18, 2018 &mdash;
Jesse Harris
</div>
<!-- text begin -->
<p>I've written about <a href="ripping-an-album-from-youtube---cli-style.html">ripping an album cli style</a>, and sometimes it still
makes sense to have older tech around. Like for example if you have 6 kids,
you can't exactly afford to buy them all iPods. Or, maybe you can't afford
the latest cars, and your car still has cd audio.</p>
<p>Thanksfully with Linux we don't have to resort to some clunky UI. We can do
anything on the good ole' command line</p>
<hr />
<p>So, you got your Audio files. They may not be titled with nice numbers so
that the list well with <code>ls</code> or a <code>*</code> glob. Not to worry. You probably
downloaded them in order. We can fix this in bash. The <code>ls</code> command sorts
files by default in alphabetical order. <code>ls -U</code> on the other hand, disables
sorting and they should be shown in order they were added to the filesystem
:</p>
<pre><code> i=1
ls -U | while read f
do
mv "${f}" "$(printf %02d $i)_${f}"
i=$((i+1));
done
</code></pre>
<p>With this touch of cli magic, we have prepended a 01..etc number to each
file.</p>
<p>Next we need to ensure the files are in the right format for cdrecord to
burn. The command line tool cdrecord, needs files to be in WAV, stereo at
44100hz. ffmpeg to the rescue! <em>PS, you might need to adjust for file ext</em></p>
<pre><code> mkdir burn
for i in *.webm
do
ffmpeg -i "${i}" -ar 44100 burn/"${i}".wav
done
</code></pre>
<p>Now we are ready to burn those files to disc with cdrecord:</p>
<pre><code> cdrecord -v -nofix -audio -pad *.wav
</code></pre>
<p>And finally we need to finalize the disc if we want any hope of reading it
on a regular old cd player</p>
<pre><code> cdrecord -v -fix -eject
</code></pre>
<p>Tags: <a href='tag_ffmpeg.html'>ffmpeg</a>, <a href='tag_cli.html'>cli</a>, <a href='tag_burn-a-cd.html'>burn-a-cd</a>, <a href='tag_linux.html'>linux</a>, <a href='tag_mp3.html'>mp3</a>, <a href='tag_music.html'>music</a>, <a href='tag_bash.html'>bash</a>, <a href='tag_youtube.html'>youtube</a></p>
<!-- text end -->
<!-- entry end -->
</div>
<div id="footer">&copy <a href="http://twitter.com/zigford_org">Jesse Harris</a> &mdash; <a href="mailto:jesse&#64;zigford&#46;org">jesse&#64;zigford&#46;org</a><br/>
Generated with <a href="https://github.com/cfenollosa/bashblog">bashblog</a>, a single bash script to easily create blogs like this one</div>
</div></div>
</body></html>