Terence Eden. He has a beard and is smiling.
Theme Switcher:

Convert Surround Sound WAV albums to individual opus files

· 200 words


As ever, notes to myself. This is a method to take a .wav and .cue and transform it into individual files. In this case, .opus.

Transform to .flac

FLAC is a good intermediary file format, especially for surround sound files.

avconv -i file.wav out.flac

Transform to .opus

An optional step if you want smaller files. Maximum quality for 6 channel audio.

opusenc --bitrate 4096 out.flac out.opus

Create an .mkv

Add to an MKV with all the chapter information.

mkvmerge -o test.mkv --chapters file.cue out.opus

Split to individual files

Individual MKVs

mkvmerge test.mkv --split chapters:all -o track.mkv

Extract the Audio

One at a time:

mkvextract tracks "track-001.mkv" 0:"individual.opus"

All-In-One bash script

 Bash#!/bin/bash
json=$(ffprobe -i "file.mkv" -print_format json -show_chapters -loglevel error)
count=$(echo $json | jq ".chapters | length" )

mkvmerge test.mkv -D -S --split chapters:all -o "%02d.mkv"

COUNTER=1
while [ $COUNTER -le $count ]; do

  printf -v zerotrack "%02d" $COUNTER

  json=$(ffprobe -i "$zerotrack.mkv" -print_format json -show_chapters -loglevel error)
  title=$(echo $json | jq ".chapters[0].tags.title" -r)
  filename="[$zerotrack] $title"

  mkvextract tracks "$zerotrack.mkv" 0:"$filename.opus"
  let COUNTER=COUNTER+1 
done

Share this post on…

What are your reckons?

All comments are moderated and may not be published immediately. Your email address will not be published.

See allowed HTML elements: <a href="" title="">
<abbr title="">
<acronym title="">
<b>
<blockquote cite="">
<br>
<cite>
<code>
<del datetime="">
<em>
<i>
<img src="" alt="" title="" srcset="">
<p>
<pre>
<q cite="">
<s>
<strike>
<strong>

To respond on your own website, write a post which contains a link to this post - then enter the URl of your page here. Learn more about WebMentions.