Commit 8f676bc3 authored by Steve Tjoa's avatar Steve Tjoa

sox and ffmpeg

parent 7accef05
......@@ -11819,6 +11819,7 @@ div#notebook {
<li><a href="python_basics.html">Python Basics and Dependencies</a> (<a href="python_basics.ipynb">ipynb</a>)</li>
<li><a href="get_good_at_ipython.html">Jupyter Basics</a> (<a href="get_good_at_ipython.ipynb">ipynb</a>)</li>
<li><a href="ipython_audio.html">Jupyter Audio Basics</a> (<a href="ipython_audio.ipynb">ipynb</a>)</li>
<li><a href="sox_and_ffmpeg.html">SoX and ffmpeg</a> (<a href="sox_and_ffmpeg.ipynb">ipynb</a>)</li>
<li><a href="numpy_basics.html">NumPy and SciPy Basics</a> (<a href="numpy_basics.ipynb">ipynb</a>)</li>
<li><a href="alphabetical_index.html">Alphabetical Index of Terms</a> (<a href="alphabetical_index.ipynb">ipynb</a>)</li>
</ol>
......
......@@ -40,6 +40,7 @@
"1. [Python Basics and Dependencies](python_basics.html) ([ipynb](python_basics.ipynb))\n",
"1. [Jupyter Basics](get_good_at_ipython.html) ([ipynb](get_good_at_ipython.ipynb))\n",
"1. [Jupyter Audio Basics](ipython_audio.html) ([ipynb](ipython_audio.ipynb))\n",
"1. [SoX and ffmpeg](sox_and_ffmpeg.html) ([ipynb](sox_and_ffmpeg.ipynb))\n",
"1. [NumPy and SciPy Basics](numpy_basics.html) ([ipynb](numpy_basics.ipynb))\n",
"1. [Alphabetical Index of Terms](alphabetical_index.html) ([ipynb](alphabetical_index.ipynb))"
]
......
......@@ -12308,173 +12308,6 @@ funk_groove.mp3 tone_440.wav
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="SoX">SoX<a class="anchor-link" href="#SoX">&#182;</a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p><a href="http://sox.sourceforge.net/">SoX</a> is a command-line utility for audio processing, e.g. convert file format, convert sample rate, remix, trim, pad, normalize, etc.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>To install, for Mac:</p>
<pre><code>brew install sox</code></pre>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>To play or record audio from the command line:</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<pre><code>rec test.wav
play test.wav</code></pre>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Resample to 22050 Hz:</p>
<pre><code>sox in.wav -r 22050 out.wav</code></pre>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Normalize gain, e.g. to avoid clipping:</p>
<pre><code>sox in.wav --norm out.wav</code></pre>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Down-mix all input channels to mono:</p>
<pre><code>sox in.wav out.wav remix -</code></pre>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Convert to 16-bit signed integer:</p>
<pre><code>sox in.wav -b 16 -e signed-integer out.wav</code></pre>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Trim the audio file starting at 1 min 15 sec and ending at 1 min 45 sec:</p>
<pre><code>sox in.wav out.wav trim 1:15 =1:45
sox in.wav out.wav trim 1:15 0:30
sox in.wav out.wav trim 75 30</code></pre>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Pad 1 second of silence to the beginning and 2 seconds of silence to the end:</p>
<pre><code>sox in.wav out.wav pad 1 2</code></pre>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="ffmpeg">ffmpeg<a class="anchor-link" href="#ffmpeg">&#182;</a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p><a href="https://www.ffmpeg.org/">ffmpeg</a> is a framework to convert among different audio and video file formats. Use <code>ffmpeg</code> if you want to convert WAV to MP3.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>To install on MacOS:</p>
<pre><code>brew install ffmpeg</code></pre>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Convert a WAV file to MP3:</p>
<pre><code>ffmpeg -i in.wav out.mp3 </code></pre>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Down-mix all input channels to mono with a bitrate of 128k:</p>
<pre><code>ffmpeg -i in.wav -ac 1 -ab 128k out.mp3</code></pre>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
......
......@@ -490,158 +490,6 @@
"librosa.output.write_wav('audio/tone_440.wav', x, sr)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## SoX"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"source": [
"[SoX](http://sox.sourceforge.net/) is a command-line utility for audio processing, e.g. convert file format, convert sample rate, remix, trim, pad, normalize, etc."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To install, for Mac:\n",
"\n",
" brew install sox"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"source": [
"To play or record audio from the command line:"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
" rec test.wav\n",
" \n",
" play test.wav"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Resample to 22050 Hz:\n",
"\n",
" sox in.wav -r 22050 out.wav"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Normalize gain, e.g. to avoid clipping:\n",
"\n",
" sox in.wav --norm out.wav"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Down-mix all input channels to mono:\n",
"\n",
" sox in.wav out.wav remix -"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Convert to 16-bit signed integer:\n",
"\n",
" sox in.wav -b 16 -e signed-integer out.wav"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Trim the audio file starting at 1 min 15 sec and ending at 1 min 45 sec:\n",
"\n",
" sox in.wav out.wav trim 1:15 =1:45\n",
" sox in.wav out.wav trim 1:15 0:30\n",
" sox in.wav out.wav trim 75 30"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Pad 1 second of silence to the beginning and 2 seconds of silence to the end:\n",
"\n",
" sox in.wav out.wav pad 1 2"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## ffmpeg"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[ffmpeg](https://www.ffmpeg.org/) is a framework to convert among different audio and video file formats. Use `ffmpeg` if you want to convert WAV to MP3."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To install on MacOS:\n",
"\n",
" brew install ffmpeg"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Convert a WAV file to MP3:\n",
"\n",
" ffmpeg -i in.wav out.mp3 "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Down-mix all input channels to mono with a bitrate of 128k:\n",
"\n",
" ffmpeg -i in.wav -ac 1 -ab 128k out.mp3"
]
},
{
"cell_type": "markdown",
"metadata": {},
......
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[&larr; Back to Index](index.html)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"# SoX"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"source": [
"[SoX](http://sox.sourceforge.net/) is a command-line utility for audio processing, e.g. convert file format, convert sample rate, remix, trim, pad, normalize, etc."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To install, for Mac:\n",
"\n",
" brew install sox"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"source": [
"To play or record audio from the command line:"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
" rec test.wav\n",
" \n",
" play test.wav"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Resample to 22050 Hz:\n",
"\n",
" sox in.wav -r 22050 out.wav"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Normalize gain, e.g. to avoid clipping:\n",
"\n",
" sox in.wav --norm out.wav"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Down-mix all input channels to mono:\n",
"\n",
" sox in.wav out.wav remix -"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Convert to 16-bit signed integer:\n",
"\n",
" sox in.wav -b 16 -e signed-integer out.wav"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Trim the audio file starting at 1 min 15 sec and ending at 1 min 45 sec:\n",
"\n",
" sox in.wav out.wav trim 1:15 =1:45\n",
" sox in.wav out.wav trim 1:15 0:30\n",
" sox in.wav out.wav trim 75 30"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Pad 1 second of silence to the beginning and 2 seconds of silence to the end:\n",
"\n",
" sox in.wav out.wav pad 1 2"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# ffmpeg"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[ffmpeg](https://www.ffmpeg.org/) is a framework to convert among different audio and video file formats. Use `ffmpeg` if you want to convert WAV to MP3."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To install on MacOS:\n",
"\n",
" brew install ffmpeg"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Convert a WAV file to MP3:\n",
"\n",
" ffmpeg -i in.wav out.mp3 "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Down-mix all input channels to mono with a bitrate of 128k:\n",
"\n",
" ffmpeg -i in.wav -ac 1 -ab 128k out.mp3"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To do the above command for all wav files in a directory:\n",
"\n",
" for i in wav/*; do ffmpeg -y -i \"$i\" -ac 1 -ab 128k mp3/`basename \"$i\" .wav`.mp3; done\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[&larr; Back to Index](index.html)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.4"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment