0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

mpg123でリモートのファイルの再生

Last updated at Posted at 2023-09-16

I2Sで新潟精密のFN1241が接続されたAtherosのモジュールはUSBもあるのですが、USBから再生するとなぜか音がよくないので、別のサーバに音源をおくことを考えてみました。

MP3ファイルはUSB HDが接続されたNetBSD/c1kにおきます。

MP3やストリームで検索するとicecast2がでてきます。c1kのarmv6はnon hfでpkgはarmv4しか使えません。

armv6hfのpkgにはicecast2はありますが、armv4にはないのでセルフでコンパイルしてみます。

結構コンパイルも苦労したのですが、どうにかビルドは出来たのですが使い方が分かりません。ネットで検索しても古い情報とか多くてよく分かりません。

そもそもicecast2はmp3ファイルを、操作しているようで、音質劣化につながると思われ、他の方法を調べてみます。

mini_httpdでmp3ファイルを見えるようにすればmpg123は再生できます。

ただ、連続して再生する事が出来ません。

mpg123にはemacsのフロントエンドがあるようですが、emacsは大きいです。

また自分でスクリプトを書くのも面倒です。

mpg123のソースを見てみたところplaylistという機能があることがわかりました。

playlistはhttpでも拾えるのでmp3のファイルがあるサーバにhttpのplaylistを置いておいて、それで再生する事ができました。

# /usr/local/bin/mpg123 --utf8 --ignore-mime -@ http://10.0.1.41:8080/shibuya/li
st.txt
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
        version 1.31.1; written and copyright by Michael Hipp and others
        free software (LGPL) without any warranty but with best wishes

Directory: http://10.0.1.41:8080/shibuya/

Terminal control enabled, press 'h' for listing of keys and functions.

Playing MPEG stream 1 of 8: 01.mp3 ...

MPEG 1.0 L III cbr192 44100 stereo

Title:   Lawns                           Artist: 渋谷毅                            
Comment: 8+C52CC56F4F83279DE1FC2A89A38954B9+84696548
Album:   カーラ・ブレイが好き
Year:    2022                            Genre:  Jazz,                          

--ignore-mimeを付けないとエラーになりました。

MP3Play.png

list.txtはURLではなくファイル名だけでいけました。

list.txt
01.mp3
02.mp3
03.mp3
04.mp3
05.mp3
06.mp3
07.mp3
08.mp3

以下のようにして、list.txtを作ります。

# ls -1 *.mp3 > list.txt

CDのリッピングはiBook Dual-USB MacOS X 10.4のiTunesでおこなっています。MP3でもcbr192くらいあれば十分高音質です。

MP3ファイルをコピーして、ファイル名変換してからtarでくくってNetBSDにもっていきます。

ほぼ一行野郎のCGIでlistを作るようにしてみました。

list.cgi
#!/bin/sh

echo "Content-type: text/html
"

LIST=`ls -1 ../${QUERY_STRING}/*.mp3 | sed 's/^.../http:\/\/'${SERVER_NAME}'\//'`

echo "${LIST}"
# /usr/local/bin/mpg123 --utf8 --ignore-mime -@ http://10.0.1.41:8080/cgi/list.cgi?shibuya

みたいに使えます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?