LoginSignup
0
2

More than 3 years have passed since last update.

Raspberry Pi で作る謎のラジオサーバ

Posted at

radiko.jp でいいじゃん。

毎回 FFmpeg のコマンドラインを忘れるのでメモ。

用意するもの

  • サン電子 RDPC-101 USB ラジオレシーバー
    • すでに入手困難
  • rdpc101.py
  • Raspberry Pi
    • Pi4B で動作確認。たぶん AAC エンコーダがリアルタイムにできればどんなボードでもいける。

やり方

拙作 rdpc101.py で RDPC-101 を同調させておく。

$ python3 rdpc101.py 77.2        # 77.2MHz -- FM NORTH WAVE@札幌大通

これで RDPC-101 のオーディオ入力にラジオの音声が来るので、Raspberry Pi の FFmpeg をこんな感じで実行する。

ffmpeg_stream.sh
#!/bin/sh

mkdir -p hls/
rm -f hls/*

ffmpeg -hide_banner -re \
    -f alsa -ar 48000 -ac 2 -i hw:1 \
    -ar 48000 -ac 2 \
    -c:a aac -b:a 192k \
    -f segment -segment_format mpegts -segment_time 10 -segment_wrap 6 \
    -segment_list_flags live \
    -segment_list hls/radio.m3u8 hls/radio.%04d.ts

こうして hls/ ディレクトリにセグメントとプレイリストができるので、cd hls && python -m http.server 3000 とかして hls/ ディレクトリを公開し、VLC とかで公開したサーバの index.m3u8 を(http で)開くと再生できる。

0
2
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
2