{"id":993,"date":"2017-10-10T05:34:39","date_gmt":"2017-10-10T05:34:39","guid":{"rendered":"http:\/\/digital.eca.ed.ac.uk\/sounddesignmedia\/?p=993"},"modified":"2019-10-01T11:21:48","modified_gmt":"2019-10-01T11:21:48","slug":"more-commandline-help","status":"publish","type":"post","link":"https:\/\/digital.eca.ed.ac.uk\/sounddesignmedia\/2017\/10\/10\/more-commandline-help\/","title":{"rendered":"More commandline help"},"content":{"rendered":"<p>This post contains some useful information. While I&#8217;m not interested in encouraging you to hack DVDs and make production companies suffer, we do need to find ways to extract parts of films pull their audio and perform analysis on them. Some of the information below should help. It&#8217;s been tested for OSX users, but because most of what&#8217;s advised is command line based, you can port the information below to PC or Linux.<\/p>\n<h4>Importing a DVD<\/h4>\n<p>To import a DVD to a digital file for your archives, you can use makemkv: <a href=\"http:\/\/www.makemkv.com\/\" class=\"autohyperlink\">www.makemkv.com\/<\/a>. This makes a .mkv container file which holds all the streams (video, audio, subtitles etc.) of your DVD. Think of it as a disc image of the DVD, it runs just like the DVD with all menus and extra options. A full DVD extraction will probably be around 8gb. The main feature, probably 4-5gb.<\/p>\n<p>This format isn&#8217;t that helpful for an analysis, expecially if we wish to inspect the audio, rather it would be really nice to see the audio in Reaper, to listen to the 5.1 or stereo files and perform audio analysis on them.<\/p>\n<h4>Coming up&#8230;<\/h4>\n<p>What follows may seem reasonably convoluted for a basic user of a computer, but it&#8217;s intended to open up a universe of possiblities that will become important to you in the future. Using FFMPEG and other commandline processing tools can even save you money and bring you into much closer contact with the engines behind many of the very expensive apps, DAWs and Video editors out there.<\/p>\n<h4>Install xcode<\/h4>\n<p>If you want to use xCode on other projects, install it , but be prepared to loose lots of HDD space and time downloading it. <a href=\"https:\/\/developer.apple.com\/xcode\/\" class=\"autohyperlink\">developer.apple.com\/xcode\/<\/a><\/p>\n<p>If you install the commandline tools, this should be quicker, it&#8217;s explained in detail here:<\/p>\n<p><a href=\"http:\/\/railsapps.github.io\/xcode-command-line-tools.html\" class=\"autohyperlink\">railsapps.github.io\/xcode-command-line-tools.html<\/a><\/p>\n<p>I think you should be able to open the terminal and type:<\/p>\n<blockquote>\n<pre>xcode-select --install<\/pre>\n<\/blockquote>\n<p>When these are installed,&nbsp; you can do what follows. I realise that this is a non-trivial task, but if you&#8217;re interested in building apps for phones and are working with Unity etc. you&#8217;ll need xCode installed for iOS development anyway so, might as well bite the bullet now.<\/p>\n<h4>Install Homebrew<\/h4>\n<p>Open the terminal and paste this in:<\/p>\n<blockquote>\n<pre class=\"wiki\">ruby -e \"$(curl -fsSL https:\/\/raw.githubusercontent.com\/Homebrew\/install\/master\/install)\"<\/pre>\n<\/blockquote>\n<p class=\"wiki\">Above info from: <a href=\"https:\/\/trac.ffmpeg.org\/wiki\/CompilationGuide\/MacOSX\" class=\"autohyperlink\">trac.ffmpeg.org\/wiki\/CompilationGuide\/MacOSX<\/a><\/p>\n<p class=\"wiki\">More useful information about homebrew and how it works;<\/p>\n<p><a href=\"http:\/\/www.howtogeek.com\/211541\/homebrew-for-os-x-easily-installs-desktop-apps-and-terminal-utilities\/\" class=\"autohyperlink\">www.howtogeek.com\/211541\/homebrew-for-os-x-easily-installs-desktop-apps-and-terminal-utilities\/<\/a><\/p>\n<h4>Installing FFMPEG<\/h4>\n<p>FFMPEG is a command line utility for converting media files. It&#8217;s powerful, fast and accurate.<\/p>\n<p>In the terminal type<\/p>\n<blockquote>\n<pre class=\"wiki\">brew install ffmpeg<\/pre>\n<\/blockquote>\n<h4>Installing Handbrake<\/h4>\n<p>In the terminal type<\/p>\n<blockquote>\n<pre class=\"wiki\">brew install handbrake<\/pre>\n<\/blockquote>\n<p>This will install handbrake and allow you to simply and quickly select chapters from the .mkv file you created from the DVD in the first place if you want to extract such.<\/p>\n<h4>Installing Makemkv command line<\/h4>\n<blockquote>\n<pre class=\"wiki\">brew cask install makemkv<\/pre>\n<\/blockquote>\n<p>When you&#8217;ve got FFMPEG working and installed you can extract your film from the DVD, convert the file to something useful so you can do your analysis. I know, this is all a bit of a faff, but bear with it.<\/p>\n<h4>Install SoX while you&#8217;re at it<\/h4>\n<blockquote>\n<pre class=\"wiki\">brew install sox<\/pre>\n<\/blockquote>\n<h4>Extract some audio from your film for analysis<\/h4>\n<p>Your DVD\/.mkv file will have various streams within its container, subtitles, the main film, dvd extras, and the sound for each of these extras or dubs will all be in differnt streams, so to find out which stream the audio you want is on, you first need to probe the .mkv for the right stream. So in the terminal, first navigate to the directory where your film is:<\/p>\n<blockquote>\n<pre class=\"wiki\">cd &lt;path to the directory where your film is&gt;\n\n<\/pre>\n<\/blockquote>\n<p class=\"wiki\">e.g<\/p>\n<blockquote>\n<pre class=\"wiki\">cd \/Users\/mparker\/Movies\/Hukkle<\/pre>\n<\/blockquote>\n<p class=\"wiki\">then<\/p>\n<blockquote>\n<pre class=\"wiki\">ffprobe movieName.mkv<\/pre>\n<\/blockquote>\n<p>you should get a nice pile of information printed to the terminal window.<\/p>\n<span class=\"collapseomatic \" id=\"id69fb8538e26ad\"  tabindex=\"0\" title=\"see the kind of code you might get\"    >see the kind of code you might get<\/span><div id=\"target-id69fb8538e26ad\" class=\"collapseomatic_content \">\n<blockquote>\n<pre>ffprobe version 3.2.3 Copyright (c) 2007-2017 the FFmpeg developers\n&nbsp; built with Apple LLVM version 8.0.0 (clang-800.0.42.1)\n&nbsp; configuration: --prefix=\/usr\/local\/Cellar\/ffmpeg\/3.2.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-vda\n&nbsp; libavutil&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 55. 34.101 \/ 55. 34.101\n&nbsp; libavcodec&nbsp;&nbsp;&nbsp;&nbsp; 57. 64.101 \/ 57. 64.101\n&nbsp; libavformat&nbsp;&nbsp;&nbsp; 57. 56.101 \/ 57. 56.101\n&nbsp; libavdevice&nbsp;&nbsp;&nbsp; 57.&nbsp; 1.100 \/ 57.&nbsp; 1.100\n&nbsp; libavfilter&nbsp;&nbsp;&nbsp;&nbsp; 6. 65.100 \/&nbsp; 6. 65.100\n&nbsp; libavresample&nbsp;&nbsp; 3.&nbsp; 1.&nbsp; 0 \/&nbsp; 3.&nbsp; 1.&nbsp; 0\n&nbsp; libswscale&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4.&nbsp; 2.100 \/&nbsp; 4.&nbsp; 2.100\n&nbsp; libswresample&nbsp;&nbsp; 2.&nbsp; 3.100 \/&nbsp; 2.&nbsp; 3.100\n&nbsp; libpostproc&nbsp;&nbsp;&nbsp; 54.&nbsp; 1.100 \/ 54.&nbsp; 1.100\nInput #0, matroska,webm, from 'hukkle.mkv':\n&nbsp; Metadata:\n&nbsp;&nbsp;&nbsp; encoder&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : libmakemkv v1.10.4 (1.3.3\/1.4.4) darwin(x86-release)\n&nbsp;&nbsp;&nbsp; creation_time&nbsp;&nbsp; : 2017-02-08T14:11:13.000000Z\n&nbsp; Duration: 01:14:17.04, start: 0.000000, bitrate: 6691 kb\/s\n&nbsp;&nbsp;&nbsp; Chapter #0:0: start 0.000000, end 317.720000\n&nbsp;&nbsp;&nbsp; Metadata:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; title&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Chapter 01\n&nbsp;&nbsp;&nbsp; Chapter #0:1: start 317.720000, end 641.160000\n&nbsp;&nbsp;&nbsp; Metadata:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; title&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Chapter 02\n&nbsp;&nbsp;&nbsp; Chapter #0:2: start 641.160000, end 1080.640000\n&nbsp;&nbsp;&nbsp; Metadata:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; title&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Chapter 03\n&nbsp;&nbsp;&nbsp; Chapter #0:3: start 1080.640000, end 1441.800000\n&nbsp;&nbsp;&nbsp; Metadata:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; title&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Chapter 04\n&nbsp;&nbsp;&nbsp; Chapter #0:4: start 1441.800000, end 1757.240000\n&nbsp;&nbsp;&nbsp; Metadata:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; title&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Chapter 05\n&nbsp;&nbsp;&nbsp; Chapter #0:5: start 1757.240000, end 1903.840000\n&nbsp;&nbsp;&nbsp; Metadata:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; title&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Chapter 06\n&nbsp;&nbsp;&nbsp; Chapter #0:6: start 1903.840000, end 2171.480000\n&nbsp;&nbsp;&nbsp; Metadata:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; title&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Chapter 07\n&nbsp;&nbsp;&nbsp; Chapter #0:7: start 2171.480000, end 2388.000000\n&nbsp;&nbsp;&nbsp; Metadata:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; title&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Chapter 08\n&nbsp;&nbsp;&nbsp; Chapter #0:8: start 2388.000000, end 2758.440000\n&nbsp;&nbsp;&nbsp; Metadata:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; title&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Chapter 09\n&nbsp;&nbsp;&nbsp; Chapter #0:9: start 2758.440000, end 3593.520000\n&nbsp;&nbsp;&nbsp; Metadata:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; title&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Chapter 10\n&nbsp;&nbsp;&nbsp; Chapter #0:10: start 3593.520000, end 3971.800000\n&nbsp;&nbsp;&nbsp; Metadata:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; title&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Chapter 11\n&nbsp;&nbsp;&nbsp; Chapter #0:11: start 3971.800000, end 4457.040000\n&nbsp;&nbsp;&nbsp; Metadata:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; title&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Chapter 12\n&nbsp;&nbsp;&nbsp; Stream #0:0(eng): Video: mpeg2video (Main), yuv420p(tv, top first), 720x576 [SAR 64:45 DAR 16:9], 25 fps, 25 tbr, 1k tbn, 50 tbc\n&nbsp;&nbsp;&nbsp; Metadata:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BPS-eng&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 6493847\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DURATION-eng&nbsp;&nbsp;&nbsp; : 01:14:17.040000000\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NUMBER_OF_FRAMES-eng: 111426\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NUMBER_OF_BYTES-eng: 3617917132\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SOURCE_ID-eng&nbsp;&nbsp; : 0100E0\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _STATISTICS_WRITING_APP-eng: MakeMKV v1.10.4 darwin(x86-release)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _STATISTICS_WRITING_DATE_UTC-eng: 2017-02-08 14:11:13\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID\n&nbsp;&nbsp;&nbsp; Stream #0:1(eng): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb\/s (default)\n&nbsp;&nbsp;&nbsp; Metadata:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; title&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Stereo\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BPS-eng&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 192000\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DURATION-eng&nbsp;&nbsp;&nbsp; : 01:14:17.024000000\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NUMBER_OF_FRAMES-eng: 139282\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NUMBER_OF_BYTES-eng: 106968576\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SOURCE_ID-eng&nbsp;&nbsp; : 0180BD\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _STATISTICS_WRITING_APP-eng: MakeMKV v1.10.4 darwin(x86-release)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _STATISTICS_WRITING_DATE_UTC-eng: 2017-02-08 14:11:13\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID\n&nbsp;&nbsp;&nbsp; Stream #0:2(eng): Subtitle: dvd_subtitle, 720x576 (default)\n&nbsp;&nbsp;&nbsp; Metadata:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BPS-eng&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 119\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DURATION-eng&nbsp;&nbsp;&nbsp; : 01:13:31.555200000\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NUMBER_OF_FRAMES-eng: 21\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NUMBER_OF_BYTES-eng: 65804\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SOURCE_ID-eng&nbsp;&nbsp; : 0120BD\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _STATISTICS_WRITING_APP-eng: MakeMKV v1.10.4 darwin(x86-release)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _STATISTICS_WRITING_DATE_UTC-eng: 2017-02-08 14:11:13\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID<\/pre>\n<\/blockquote>\n<\/div>\n<p>You are probably interested in stream #0:1 which is most likely to have the .ac3 audio file in either stereo or 5.1. To extract that to PCM audio with the channel ordering in ITU FILM format (L,R,C,sub,Ls,Rs).<\/p>\n<p><em><strong>This<\/strong> <\/em>will extract the audio of stream #0:1 to a 16bit pcm wav file in 2 channels (I think FFMPEG actually makes a down mix (removing the LFE channel))&nbsp; if this is a 5.1 .ac3 file:<\/p>\n<blockquote>\n<pre>ffmpeg -i video.mkv -map 0:1 -acodec pcm_s16le -ac 2 audio.wav<\/pre>\n<\/blockquote>\n<p>For more channel munging FFMPEG skills read this: <a href=\"https:\/\/trac.ffmpeg.org\/wiki\/AudioChannelManipulation\" class=\"autohyperlink\">trac.ffmpeg.org\/wiki\/AudioChannelManipulation<\/a><\/p>\n<p>You&#8217;ll see in the command line above, we call the FFMPEG software, specify the input, map the stream you want to the audio codec (acodec) pcam_s16e with 2 audio channels [-ac 2] to filename audio.wav<\/p>\n<p>If you want to extract the 5.1 without downmixing (reccommended)<\/p>\n<blockquote>\n<pre>ffmpeg -i video.mkv -map 0:1 -acodec pcm_s16le -ac 6 audio.wav<\/pre>\n<\/blockquote>\n<p>The only thing we&#8217;ve changed is the number of audio channels. What would you change if you wanted to get a 24bit audio file?<\/p>\n<h4>PCM channel ordering<\/h4>\n<p>What if the channel ordering is messed up? You can hardwire the channel ordering like this:<\/p>\n<blockquote>\n<pre class=\"wiki\">ffmpeg -i video.mkv -map 0:1 -acodec pcm_s24le -ac 6 -af pan=\"5.1(side):c0=FL|c1=FR|c2=FC|c3=LFE|c4=SL|c5=SR\" audio.wav<\/pre>\n<\/blockquote>\n<h4>Extracting stems<\/h4>\n<p>If you want to extract the stems to individual files from the audio track you get above, try this;<\/p>\n<blockquote>\n<pre>ffmpeg -i yourAudioFile.wav -filter_complex \"channelsplit=channel_layout=5.1[FL][FR][FC][LFE][BL][BR]\" -map \"[FL]\" front_left.wav -map \"[FR]\" front_right.wav -map \"[FC]\" front_center.wav -map \"[LFE]\" lfe.wav -map \"[BL]\" back_left.wav -map \"[BR]\" back_right.wav<\/pre>\n<\/blockquote>\n<h4>Using FFMPEG to extract a segment of your input file and export to something useful for your analysis:<\/h4>\n<p>Of course, you don&#8217;t really want to do this with a whole DVD and you may want to import the film with PCM audio into Reaper. So, decide which bit of the film you want to analyse. Get the start point in hours, minutes, seconds and find the <em><strong>duration<\/strong><\/em> and specify this<em> -t<\/em>. Specify the video codec for output, container format <em>-f mov&nbsp;<\/em>output movie name.<\/p>\n<blockquote>\n<pre class=\"wiki\">ffmpeg -i input.mkv -ss 00:01:45 -t 00:02:00 -vcodec h264 -acodec pcm_s24le -ac 6 -af pan=\"5.1(side):c0=FL|c1=FR|c2=FC|c3=LFE|c4=SL|c5=SR\" -f mov output.mov<\/pre>\n<\/blockquote>\n<p class=\"wiki\">e.g.<\/p>\n<blockquote>\n<pre class=\"wiki\">ffmpeg -i bbss.mkv -ss 00:01:45 -t 00:00:30 -vcodec h264 -acodec pcm_s24le -ac 6 -af pan=\"5.1(side):c0=FL|c1=FR|c2=FC|c3=LFE|c4=SL|c5=SR\" -f mov mySelection.mov\n\n<\/pre>\n<\/blockquote>\n<p class=\"wiki\">To get just the audio of your extract, perhaps as a downmixed stereo file to make some forms of analysis slightly simpler, you could try this<\/p>\n<blockquote>\n<pre>ffmpeg -i movieSource.mkv -ss 00:01:45 -t 00:00:30 -map 0:1 -acodec pcm_s24le -ac 2 stereoAudioDownMixOfSelection.wav<\/pre>\n<\/blockquote>\n<p>for a 5.1 version of the same<\/p>\n<blockquote>\n<pre>ffmpeg -i movieSource.mkv -ss 00:01:45 -t 00:00:30 -map 0:1 -acodec pcm_s24le -ac 6 -af pan=\"5.1(side):c0=FL|c1=FR|c2=FC|c3=LFE|c4=SL|c5=SR\" surroundVersionOfSelection.wav<\/pre>\n<\/blockquote>\n<h3 class=\"wiki\">UPDATE<\/h3>\n<p>I have found that if you extract your video as .mov with hard wired 5.1 as above, Reaper doesn&#8217;t seem to like to import it nicely, even though it plays fine in media players. So run this on your extract and then import to Reaper and it seems to work<\/p>\n<blockquote>\n<pre>ffmpeg -i yourExtract.mov -vcodec copy -acodec pcm_s24le -ac 6 -af pan=\"5.1:c0=FL|c1=FR|c2=FC|c3=LFE|c4=SL|c5=SR\" -f mov yourExtractToReaper.mov<\/pre>\n<\/blockquote>\n<h3 class=\"wiki\"><\/h3>\n<h3 class=\"wiki\">Analysis of your audio<\/h3>\n<p>Check out SoX and install it on your machine (see above);<\/p>\n<p><a href=\"http:\/\/sox.sourceforge.net\/\" class=\"autohyperlink\">sox.sourceforge.net\/<\/a><\/p>\n<p>Look at the file formats that SoX can cope with;<\/p>\n<p><a href=\"http:\/\/sox.sourceforge.net\/soxformat.html\" class=\"autohyperlink\">sox.sourceforge.net\/soxformat.html<\/a><\/p>\n<p>Handy tutorial on generating spectrograms from SoX<\/p>\n<p><a href=\"http:\/\/jdesbonnet.blogspot.co.uk\/2013\/08\/using-sox-spectrogram-tool-to-analyze.html\" class=\"autohyperlink\">jdesbonnet.blogspot.co.uk\/2013\/08\/using-sox-spectrogram-tool-to-analyze.html<\/a><\/p>\n<p>Try this in the command line<\/p>\n<blockquote>\n<pre>sox surroundVersionOfSelection.wav -n spectrogram -o spectrum.png<\/pre>\n<\/blockquote>\n<p>It might give you something like this, a spectrogram of each channel.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-319\" src=\"http:\/\/digital.eca.ed.ac.uk\/soundandfixedmedia\/files\/2017\/02\/spectrum.png\" alt=\"\" width=\"944\" height=\"473\"><\/p>\n<p>How about generating a spectrogram of Channel 3?<\/p>\n<p>Extract the centre channel<\/p>\n<blockquote>\n<pre>sox surroundVersionOfSelection.wav centre.wav remix 3<\/pre>\n<\/blockquote>\n<p>Generate your spectrogram<\/p>\n<blockquote>\n<pre>sox centre.wav -n spectrogram -o centreSpectrogram.png<\/pre>\n<\/blockquote>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-321\" src=\"http:\/\/digital.eca.ed.ac.uk\/soundandfixedmedia\/files\/2017\/02\/centreSpectrogram.png\" alt=\"\" width=\"944\" height=\"591\"><\/p>\n<p>Want more detail from the key areas of the voice or extract? Try resampling. The command below will take your source audio, select 40 seconds starting at 20 seconds, resample the 48k to 6k, giving you a focus on the first 3k of the spectrum, it will do this to channel 3 and produce you a spectrogram of that 40 second clip:<\/p>\n<blockquote>\n<pre>sox audio.wav -n trim 20 40 rate 6k remix 3 spectrogram -o centreSpectrogram.png<\/pre>\n<\/blockquote>\n<p>You could explore some useful ways of exporting an image for every keyframe that you select in Reaper by exporting your markers as a csv or text file and using these indices to generate a still from the film and a spectrogram.<\/p>\n<p>Here&#8217;s a way to extract a segment of audio that you want to concentrate on. It should take your surround audio file, generate a new file called Klangers.wav, trim 10 seconds at second 33 and give you only the centre channel. This is useful because it gives you the sound file of the same extract you&#8217;ve visualised.<\/p>\n<blockquote>\n<pre>sox audio.wav klangers.wav trim 33 10 remix 3 -n rate 5k spectrogram -o klangers.png<\/pre>\n<\/blockquote>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-328\" src=\"http:\/\/digital.eca.ed.ac.uk\/soundandfixedmedia\/files\/2017\/02\/klangers.png\" alt=\"\" width=\"944\" height=\"591\"><\/p>\n<h3>Extra\/off-topic &#8211; using &#8216;for&#8217; to do batch conversion<\/h3>\n<p>batch convert from flac to alac (apple lossless) and add image file, navigate to your folder of flacs and&nbsp; punch this in<\/p>\n<blockquote>\n<pre>for f in *.flac; do ffmpeg -i \"$f\" -c:a alac \"${f\/%flac\/m4a}\"; done<\/pre>\n<\/blockquote>\n<p>batch add artwork with mp4 art. This is part of the mp4v2 package which you simply install with<\/p>\n<blockquote>\n<pre>brew install mp4v2<\/pre>\n<\/blockquote>\n<p>Then try this, which looks for all the m4a (apple lossless files in the direcotry, then adds the .jpg file in the same directory.<\/p>\n<blockquote>\n<pre>for f in *.m4a; do mp4art --add *.jpg \"$f\"; done<\/pre>\n<\/blockquote>\n<p>to join them both if conversion to ALAC was successful, use &amp;&amp;<\/p>\n<blockquote>\n<pre>for f in *.flac; do ffmpeg -i \"$f\" -c:a alac \"${f\/%flac\/m4a}\"; done &amp;&amp; for f in *.m4a; do mp4art --add *.jpg \"$f\"; done<\/pre>\n<\/blockquote>\n<h3>Links<\/h3>\n<p>Some useful links and starter tips for command-line processing<\/p>\n<h4>SoX<\/h4>\n<blockquote class=\"wp-embedded-content\" data-secret=\"FHRq1OMr0U\"><p><a href=\"https:\/\/www.thegeekstuff.com\/2009\/05\/sound-exchange-sox-15-examples-to-manipulate-audio-files\/\">15 Awesome Examples to Manipulate Audio Files Using Sound eXchange (SoX)<\/a><\/p><\/blockquote>\n<p><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"https:\/\/www.thegeekstuff.com\/2009\/05\/sound-exchange-sox-15-examples-to-manipulate-audio-files\/embed\/#?secret=FHRq1OMr0U\" data-secret=\"FHRq1OMr0U\" width=\"600\" height=\"338\" title=\"&#8220;15 Awesome Examples to Manipulate Audio Files Using Sound eXchange (SoX)&#8221; &#8212; The Geek Stuff\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<h4>FFMPEG<\/h4>\n<p><a href=\"http:\/\/ffmpeg.org\/\" class=\"autohyperlink\">ffmpeg.org\/<\/a><br \/>\nFFMPEG Audio RESAMPLER: <a href=\"http:\/\/ffmpeg.org\/ffmpeg-resampler.html\" class=\"autohyperlink\">ffmpeg.org\/ffmpeg-resampler.html<\/a><br \/>\nCommands for all needs;<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"P6SUipk7qQ\"><p><a href=\"https:\/\/www.catswhocode.com\/blog\/19-ffmpeg-commands-for-all-needs\">19 ffmpeg commands for all needs<\/a><\/p><\/blockquote>\n<p><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"https:\/\/www.catswhocode.com\/blog\/19-ffmpeg-commands-for-all-needs\/embed#?secret=P6SUipk7qQ\" data-secret=\"P6SUipk7qQ\" width=\"600\" height=\"338\" title=\"&#8220;19 ffmpeg commands for all needs&#8221; &#8212; CatsWhoCode\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><br \/>\nBatch Scripting, yeah!<br \/>\n<a href=\"http:\/\/www.gna-productions.com\/tutos\/video\/how-to-use-ffmpeg-with-batch-scripts\" class=\"autohyperlink\">www.gna-productions.com\/tutos\/video\/how-to-use-ffmpeg-with-batch-scripts<\/a><\/p>\n<p>Helpful indeed:<\/p>\n<p><a href=\"https:\/\/gist.github.com\/protrolium\/e0dbd4bb0f1a396fcb55\" class=\"autohyperlink\">gist.github.com\/protrolium\/e0dbd4bb0f1a396fcb55<\/a><\/p>\n<p>Useful too:<\/p>\n<p><a href=\"http:\/\/superuser.com\/questions\/538112\/meaningful-thumbnails-for-a-video-using-ffmpeg\" class=\"autohyperlink\">superuser.com\/questions\/538112\/meaningful-thumbnails-for-a-video-using-ffmpeg<\/a><\/p>\n<h4>SPEAR<\/h4>\n<p><a href=\"http:\/\/www.klingbeil.com\/spear\/\" class=\"autohyperlink\">www.klingbeil.com\/spear\/<\/a><\/p>\n<h4>Sonic Visualiser<\/h4>\n<p><a href=\"http:\/\/sonicvisualiser.org\/\" class=\"autohyperlink\">sonicvisualiser.org\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post contains some useful information. While I&#8217;m not interested in encouraging you to hack DVDs and make production companies suffer, we do need to find ways to extract parts of films pull their audio and perform analysis on them. &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/digital.eca.ed.ac.uk\/sounddesignmedia\/2017\/10\/10\/more-commandline-help\/\"> <span class=\"screen-reader-text\">More commandline help<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/digital.eca.ed.ac.uk\/sounddesignmedia\/wp-json\/wp\/v2\/posts\/993"}],"collection":[{"href":"https:\/\/digital.eca.ed.ac.uk\/sounddesignmedia\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/digital.eca.ed.ac.uk\/sounddesignmedia\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/digital.eca.ed.ac.uk\/sounddesignmedia\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/digital.eca.ed.ac.uk\/sounddesignmedia\/wp-json\/wp\/v2\/comments?post=993"}],"version-history":[{"count":5,"href":"https:\/\/digital.eca.ed.ac.uk\/sounddesignmedia\/wp-json\/wp\/v2\/posts\/993\/revisions"}],"predecessor-version":[{"id":1299,"href":"https:\/\/digital.eca.ed.ac.uk\/sounddesignmedia\/wp-json\/wp\/v2\/posts\/993\/revisions\/1299"}],"wp:attachment":[{"href":"https:\/\/digital.eca.ed.ac.uk\/sounddesignmedia\/wp-json\/wp\/v2\/media?parent=993"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digital.eca.ed.ac.uk\/sounddesignmedia\/wp-json\/wp\/v2\/categories?post=993"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digital.eca.ed.ac.uk\/sounddesignmedia\/wp-json\/wp\/v2\/tags?post=993"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}