0
(0)

[IT] フリーのオーディオフォーマット「Opus」 で遊んでみた / Win32

同僚からオーパスが RFC 6716 になったよ!とチャター経由で教えて貰ってから妄想が膨らみ、帰宅直後に遊んでみました。

[amazon_enhanced asin=”4844329278″ container=”” container_class=”” price=”All” background_color=”FFFFFF” link_color=”000000″ text_color=”0000FF” /]  [amazon_enhanced asin=”4873114829″ container=”” container_class=”” price=”All” background_color=”FFFFFF” link_color=”000000″ text_color=”0000FF” /]  [amazon_enhanced asin=”4822296121″ container=”” container_class=”” price=”All” background_color=”FFFFFF” link_color=”000000″ text_color=”0000FF” /]  [amazon_enhanced asin=”4774150673″ container=”” container_class=”” price=”All” background_color=”FFFFFF” link_color=”000000″ text_color=”0000FF” /]

詳細はコチラをどうぞ → http://sourceforge.jp/magazine/12/09/13/1237230

rfc http://tools.ietf.org/html/rfc6716

メモ:ナローバンド(狭帯域)なので、 無線通信にも使えそうと妄想したが、

 The Opus codec scales from 6 kbit/s narrowband mono speech to 510 kbit/s fullband stereo music, with algorithmic delays ranging from 5 ms to 65.2 ms. At any given time, either the LP layer, the MDCT layer, or both, may be active. It can seamlessly switch between all of its various operating modes, giving it a great deal of flexibility to adapt to varying content and network conditions without renegotiating the current session. The codec allows input and output of various audio bandwidths, defined as follows: +----------------------+-----------------+-------------------------+ | Abbreviation | Audio Bandwidth | Sample Rate (Effective) | +----------------------+-----------------+-------------------------+ | NB (narrowband) | 4 kHz | 8 kHz | | | | | | MB (medium-band) | 6 kHz | 12 kHz | | | | | | WB (wideband) | 8 kHz | 16 kHz | | | | | | SWB (super-wideband) | 12 kHz | 24 kHz | | | | | | FB (fullband) | 20 kHz (*) | 48 kHz | +----------------------+-----------------+-------------------------+

なので、そうでもなかった。

■環境

— 

■遊んでみた

0.導入時メモ

Wed Sep 19 19:18:06 /cygdrive/c/Users/yukio/Downloads/opus-tools-0.1.5-win32
yukio@Lets-note:$ sha256sum -c SHA256SUMS.txt
COPYING.txt: OK
opusdec.exe: OK
opusdec.html: OK
opusenc.exe: OK
opusenc.html: OK
opusinfo.exe: OK
opusinfo.html: OK
README.txt: OK

ハッシュ値は問題なし!

yukio@Lets-note:$ gpg –verify SHA256SUMS.txt.asc
gpg: WARNING: using insecure memory!
gpg: please see http://www.gnupg.org/faq.html for more information
gpg: Signature made Wed Sep 5 03:08:00 2012 JST using RSA key ID B1441DEF
gpg: Can’t check signature: public key not found

うわ!署名整合なしwwww

遊ぶだけなら、別にいいか、な。(自己責任でやってね!

1.まずはオプション引数なしで実行した。

yukio@Lets-note:$ ./opusenc.exe gohan.wav gohan.opus ← エンコード 入力ファイル名 出力ファイル名
Encoding using libopus 1.0.1-rc3 (audio)
—————————————————–
Input: 44.1kHz 2 channels
Output: 2 channels (2 coupled)
20ms packets, 96kbit/sec VBR
Preskip: 356

Encoding completee+004x realtime, 99.25kbit/s
—————————————————–
Encoded: 3.62 seconds
Runtime: 1e-006 seconds
(3.62e+006x realtime)
Wrote: 46631 bytes, 181 packets, 6 pages
Bitrate: 101.94kbit/s (without overhead)
Rate range: 73.6kbit/s to 164.4kbit/s
(184 to 411 bytes per packet)
Overhead: 1.08% (container+metadata)

RFC の定義では、

 o 8-12 kbit/s for NB speech, o 16-20 kbit/s for WB speech, o 28-40 kbit/s for FB speech, o 48-64 kbit/s for FB mono music, and o 64-128 kbit/s for FB stereo music.

Opus 引数はそれぞれの目的にあった可変エンコードが推奨されている。

2.入出力例

入力ファイル 620 KB (635,410 バイト) に対し、出力ファイル 45.5 KB (46,631 バイト)である。

エンコード情報出力は、パケット数、ページ数も表示される。

通常のエンコードならばビットレートや圧縮率、可変ビットレートなどの情報のはず、

3.バイナリエディタでヘッダだけ参照

まずは、WAV ファイル(ものの見事にスカスカ)

次に Opus オーパス形式(どのライブラリで符号化されたのか情報入り)

RFC の定義では

table-of-contents (TOC) header
 0 0 1 2 3 4 5 6 7 +-+-+-+-+-+-+-+-+ | config |s| c | +-+-+-+-+-+-+-+-+ Figure 1: The TOC Byte

であるが、そこまで細分化チェックを目的としていないので、すみません。

4.OPUS 情報と妥当性チェックを実施。

yukio@Lets-note:$ ./opusinfo gohan.opus
Processing file “gohan.opus”…

New logical stream (#1, serial: 000028f5): type opus
Encoded with libopus 1.0.1-rc3
User comments section follows…
ENCODER=opusenc from opus-tools 0.1.5
Opus stream 1:
Pre-skip: 356
Playback gain: 0 dB
Channels: 2
Original sample rate: 44100Hz
Packet duration: 20.0ms (max), 20.0ms (avg), 20.0ms (min)
Page duration: 1000.0ms (max), 905.0ms (avg), 620.0ms (min)
Total data length: 46631 bytes (overhead: 1.08%)
Playback length: 0m:03.599s
Average bitrate: 103.6 kb/s, w/o overhead: 102.5 kb/s
Logical stream 1 ended

完全に音声パケットとしてのフレーム情報を読んでいるような錯覚になるね。不思議!

5.エンコードしたものをデコードしてみよう

(符号化から復号化!)

yukio@Lets-note:$ ./opusdec gohan.opus gohan2.wav  ← デコード 入力ファイル名 出力ファイル名
Decoding to 44100 Hz (2 channels)
Encoded with libopus 1.0.1-rc3
ENCODER=opusenc from opus-tools 0.1.5
Decoding complete.

ここでは、当初ファイルと区別するために gohan2.wav を出力してみた

結果:620 KB (635,084 バイト)

6.ここまで遊び結果

元ファイル:「お腹空いたね、ご飯食べに行こ!」とオッサンが囁く。
WAV ( 620 KB (635,410 バイト) / 無圧縮)

標準エンコードファイル:「お腹空いたね、ご飯食べに行こ!」とオッサンが囁く。
OPUS (45.5 KB (46,631 バイト) / 圧縮)

デコードファイル:「お腹空いたね、ご飯食べに行こ!」とオッサンが囁く。
WAV 620 KB (635,084 バイト)  無圧縮?

ヘッダ直後のバイナリデータが変化している。

が、無視できる程度。

RFC の定義では

 +-----------------------+-----------+-----------+-------------------+ | Configuration | Mode | Bandwidth | Frame Sizes | | Number(s) | | | | +-----------------------+-----------+-----------+-------------------+ | 0...3 | SILK-only | NB | 10, 20, 40, 60 ms | | | | | | | 4...7 | SILK-only | MB | 10, 20, 40, 60 ms | | | | | | | 8...11 | SILK-only | WB | 10, 20, 40, 60 ms | | | | | | | 12...13 | Hybrid | SWB | 10, 20 ms | | | | | | | 14...15 | Hybrid | FB | 10, 20 ms | | | | | | | 16...19 | CELT-only | NB | 2.5, 5, 10, 20 ms | | | | | | | 20...23 | CELT-only | WB | 2.5, 5, 10, 20 ms | | | | | | | 24...27 | CELT-only | SWB | 2.5, 5, 10, 20 ms | | | | | | | 28...31 | CELT-only | FB | 2.5, 5, 10, 20 ms | +-----------------------+-----------+-----------+-------------------+

やはりモード目的別に帯域幅とフレームサイズをプリセットして使用するのが推奨されている。

■全然纏まっていないが

decode に関しての man example に興味深いことが掲載されているので取り上げる。

Decode a file input.opus to output.wav
opusdec input.opus output.wav

Play a file input.opus and force output at 48000 regardless of the original sampling rate

(48kHz output may be faster, due to avoiding resampling and some sound hardware produces higher quality output when run at 48kHz)

opusdec –rate 48000 input.opus

Re-encode a high bitrate Opus file to a lower rate
opusdec input.opus – | opusenc –bitrate 64 – output.opus

Play an http stream http://icecast.somwhere.org:8000/stream.opus with the help of curl on a system with pulseaudio

(press ctrl-c to quit)

curl http://icecast.somwhere.org:8000/stream.opus | padsp opusdec –

ということ。パルスオーディオと併用することで、オーパスの真価検証が出来そうな。

ref.) http://www.freedesktop.org/wiki/Software/PulseAudio

今日はここまで。

ではまたー。

以上

 

 

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

投稿者 斉藤之雄 (Yukio Saito)

Global Information and Communication Technology OTAKU / Sports volunteer / Social Services / Master of Technology in Innovation for Design and Engineering, AIIT / BA, Social Welfare, NFU / twitter@yukio_saitoh