NHKネットラジオらじる★らじるをラズベリーパイで自動録音する

目的

NHKネットラジオことらじる★らじる(以下,NHKラジオと記載)をRaspberry Pi(以下,ラズパイと記載)にてシェルスクリプトおよびcronで自動録音する方法を記載する*1

きっかけは,語学をNHKラジオで学習するにあたり

  1. 言語によっては日中の業務時間中しか放送しておらず聴取できない*2
  2. その日の予定によっては朝または夜の放送時間に聴取できないことがある

という理由から,番組ごとに自動録音させるものを作りたかったことによる.また,音楽サーバー(Volumio2導入済だが,ほとんど使っていない)として初代のラズパイモデルBを持っており,作成当時,それを活用することとした.

本記事で紹介するおもな環境は下表のとおり:

名称 規格 製造会社 備考
ラズパイ Raspberry Pi Type B(SoC:BCM2835 ARM11,RAM:512[MB]など) ラズベリーパイ財団 購入時3,940JPY,
RS品番*3756-8308
nasne(ナスネ) CECH-ZNR2J01,HDD 1[TB] ソニー・インタラクティブエンタテインメント 購入時20,019JPY
オペレーティングシステム Volumio 2.882 Volumio Community Volumio2系
コーデックライブラリー avconv version 11.12-6:11.12-1~deb8u1+rpi1 the Livav developers avconv -versionで確認

また,GitHubリポジトリーは以下: github.com

要求・要件

  1. 録音したい番組のみを録音し,音声ファイルとして保存したい
    1. 該当するラジオ局のストリーミングデータが必要
    2. 該当する番組の放送時間(開始時刻と継続時間)が必要
    3. 音声ファイルとしての保存が必要
  2. 指定したファイルサーバーまたはGoogle Driveにその音声ファイルを保存したい
    1. ファイルサーバーへの設定が必要
    2. 【未】Google Driveへアップロードする設定が必要
  3. PCやスマートフォンアプリで再生できるファイル形式としたい
  4. 音質は重視しないのでなるべくファイルサイズは小さくしたい
    1. 圧縮する音声コーデックが必要
  5. 【未】音声ファイルを見ただけで,いつの何の番組なのか知りたい
    1. 該当する番組の情報取得が必要

設計

該当するラジオ局のストリーミングデータが必要

参考URLの2によれば,NHKラジオには通常のラジオと同じく第1,第2およびFMがあり,第2は全国共通だが,第1およびFMは各地方の放送局ごとに存在する.

今回は,語学放送が録音できればよいため第2放送が録音できればよいが,第1およびFMも録音できるようなつくりとする.東京放送局を採用するとすると,それぞれの放送局URLは以下のとおりである:

  1. 第1(東京):https://nhkradioakr1-i.akamaihd.net/hls/live/511633/1-r1/1-r1-01.m3u8
  2. 第2(東京):https://nhkradioakr2-i.akamaihd.net/hls/live/511929/1-r2/1-r2-01.m3u8
  3. FM:https://nhkradioakfm-i.akamaihd.net/hls/live/512290/1-fm/1-fm-01.m3u8

該当する番組の放送時間(開始時刻と継続時間)が必要

番組情報取得ができれば動的に取得できると思われるが現状未対応(2021/11/11現在).

音声ファイルとしての保存が必要

参考URLの9によれば,m3u8はHTTP Live Streaming(HLS)と呼ばれ,音声のみならず動画のストリーミングに用いられるそう.さらに,配信サーバー側では元となる動画や音声を10秒ごとのMPEG-2 Transport Stream形式のファイルに分割してから,時系列のM3U8形式のリストとしてプレイヤー側に送っているとのこと.

したがって,これをffmpeg(または同等のコーデックライブラリー)にて音声ファイルとして切り出す必要がある.今回はffmpegはうまく導入できなかったので(後述),同等のavconvを利用する.

ファイルサーバーへの設定が必要

Volumio2のGUIより設定する.書込権限が必要.

【未】Google Driveへアップロードする設定が必要

現状未対応(2021/11/11現在).

圧縮する音声コーデックが必要

上記,音声ファイルとしての保存が必要の項目でのffmpeg(または同等のコーデックライブラリー)にてで対応できるものを選ぶ.

今回は,Advanced Audio Coding(以下,AACと記載)を使用する.

【未】該当する番組の情報取得が必要

NHK番組表APIを使用すれば,実現可能性があるが未実装(2021/11/11現在).

そのため,エクスプローラーで見ると,一見何のファイルか判別がつかない.

エクスプローラーで見たファイル群

実装

事前準備

事前準備として,単純な設定やパッケージのインストールをおこなう

ファイルサーバーへの設定が必要

まず,ファイルサーバーの設定は以下のとおりで,Optionsの欄にバージョン指定と書込権限を追加する必要がある(vers=1.0,rw).語学学習用ということでGOGAKUと名付けた:

Volumio2でのnasneのマウント設定

コーデックライブラリーavconvのインストール

ffmpegはうまく導入できなかったので(後述),同等のavconvを利用する.

volumio@volumio:~$ sudo apt install libav-tools
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  libavdevice55 libavfilter5 libdc1394-22 libdrm-amdgpu1 libdrm-freedreno1 libdrm-nouveau2 libdrm-radeon1 libelf1 libgl1-mesa-dri
  libgl1-mesa-glx libglapi-mesa libglu1-mesa libllvm3.9 libopencv-core2.4 libopencv-imgproc2.4 libraw1394-11 libswscale3
  libtxc-dxtn-s2tc0 libvdpau1 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-sync1 libxshmfence1 libxxf86vm1
Suggested packages:
  frei0r-plugins libraw1394-doc vdpau-driver
The following NEW packages will be installed:
  libav-tools libavdevice55 libavfilter5 libdc1394-22 libdrm-amdgpu1 libdrm-freedreno1 libdrm-nouveau2 libdrm-radeon1 libelf1
  libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa libglu1-mesa libllvm3.9 libopencv-core2.4 libopencv-imgproc2.4 libraw1394-11 libswscale3
  libtxc-dxtn-s2tc0 libvdpau1 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-sync1 libxshmfence1 libxxf86vm1
0 upgraded, 27 newly installed, 0 to remove and 0 not upgraded.
Need to get 16.8 MB of archives.
After this operation, 65.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.volumio.org/raspbian/ jessie/main libraw1394-11 armhf 2.1.0-3 [41.7 kB]
Get:2 http://archive.volumio.org/raspbian/ jessie/main libdc1394-22 armhf 2.2.3-1 [96.4 kB]
Get:3 http://archive.volumio.org/raspbian/ jessie/main libavdevice55 armhf 6:11.12-1~deb8u1+rpi1 [98.2 kB]
Get:4 http://archive.volumio.org/debian/ jessie/main libglapi-mesa armhf 13.0.0-1+rpi1 [64.7 kB]
Get:5 http://archive.volumio.org/raspbian/ jessie/main libxcb-dri2-0 armhf 1.10-3 [12.1 kB]
Get:6 http://archive.volumio.org/raspbian/ jessie/main libxcb-dri3-0 armhf 1.10-3 [10.6 kB]
Get:7 http://archive.volumio.org/raspbian/ jessie/main libxcb-glx0 armhf 1.10-3 [23.8 kB]
Get:8 http://archive.volumio.org/raspbian/ jessie/main libxcb-present0 armhf 1.10-3 [10.8 kB]
Get:9 http://archive.volumio.org/raspbian/ jessie/main libxcb-sync1 armhf 1.10-3 [13.2 kB]
Get:10 http://archive.volumio.org/raspbian/ jessie/main libxshmfence1 armhf 1.1-4+rpi1 [6,704 B]
Get:11 http://archive.volumio.org/raspbian/ jessie/main libxxf86vm1 armhf 1:1.1.3-1 [20.0 kB]
Get:12 http://archive.volumio.org/debian/ jessie/main libgl1-mesa-glx armhf 13.0.0-1+rpi1 [156 kB]
Get:13 http://archive.volumio.org/raspbian/ jessie/main libglu1-mesa armhf 9.0.0-2 [166 kB]
Get:14 http://archive.volumio.org/raspbian/ jessie/main libopencv-core2.4 armhf 2.4.9.1+dfsg-1+deb8u2 [622 kB]
Get:15 http://archive.volumio.org/raspbian/ jessie/main libopencv-imgproc2.4 armhf 2.4.9.1+dfsg-1+deb8u2 [529 kB]
Get:16 http://archive.volumio.org/raspbian/ jessie/main libswscale3 armhf 6:11.12-1~deb8u1+rpi1 [158 kB]
Get:17 http://archive.volumio.org/raspbian/ jessie/main libavfilter5 armhf 6:11.12-1~deb8u1+rpi1 [201 kB]
Get:18 http://archive.volumio.org/debian/ jessie/main libvdpau1 armhf 1.1.1-1~bpo8+1 [38.6 kB]
Get:19 http://archive.volumio.org/raspbian/ jessie/main libav-tools armhf 6:11.12-1~deb8u1+rpi1 [462 kB]
Get:20 http://archive.volumio.org/debian/ jessie/main libdrm-amdgpu1 armhf 2.4.71-1+rpi1 [24.2 kB]
Get:21 http://archive.volumio.org/debian/ jessie/main libdrm-freedreno1 armhf 2.4.71-1+rpi1 [23.8 kB]
Get:22 http://archive.volumio.org/debian/ jessie/main libdrm-nouveau2 armhf 2.4.71-1+rpi1 [23.9 kB]
Get:23 http://archive.volumio.org/debian/ jessie/main libdrm-radeon1 armhf 2.4.71-1+rpi1 [27.8 kB]
Get:24 http://archive.volumio.org/raspbian/ jessie/main libelf1 armhf 0.159-4.2 [159 kB]
Get:25 http://archive.volumio.org/debian/ jessie/main libllvm3.9 armhf 1:3.9-4 [9,772 kB]
Get:26 http://archive.volumio.org/debian/ jessie/main libgl1-mesa-dri armhf 13.0.0-1+rpi1 [3,973 kB]
Get:27 http://archive.volumio.org/raspbian/ jessie/main libtxc-dxtn-s2tc0 armhf 0~git20131104-1.1 [53.3 kB]
Fetched 16.8 MB in 46s (363 kB/s)
Selecting previously unselected package libraw1394-11:armhf.
(Reading database ... 26627 files and directories currently installed.)
Preparing to unpack .../libraw1394-11_2.1.0-3_armhf.deb ...
Unpacking libraw1394-11:armhf (2.1.0-3) ...
Selecting previously unselected package libdc1394-22:armhf.
Preparing to unpack .../libdc1394-22_2.2.3-1_armhf.deb ...
Unpacking libdc1394-22:armhf (2.2.3-1) ...
Selecting previously unselected package libavdevice55:armhf.
Preparing to unpack .../libavdevice55_6%3a11.12-1~deb8u1+rpi1_armhf.deb ...
Unpacking libavdevice55:armhf (6:11.12-1~deb8u1+rpi1) ...
Selecting previously unselected package libglapi-mesa:armhf.
Preparing to unpack .../libglapi-mesa_13.0.0-1+rpi1_armhf.deb ...
Unpacking libglapi-mesa:armhf (13.0.0-1+rpi1) ...
Selecting previously unselected package libxcb-dri2-0:armhf.
Preparing to unpack .../libxcb-dri2-0_1.10-3_armhf.deb ...
Unpacking libxcb-dri2-0:armhf (1.10-3) ...
Selecting previously unselected package libxcb-dri3-0:armhf.
Preparing to unpack .../libxcb-dri3-0_1.10-3_armhf.deb ...
Unpacking libxcb-dri3-0:armhf (1.10-3) ...
Selecting previously unselected package libxcb-glx0:armhf.
Preparing to unpack .../libxcb-glx0_1.10-3_armhf.deb ...
Unpacking libxcb-glx0:armhf (1.10-3) ...
Selecting previously unselected package libxcb-present0:armhf.
Preparing to unpack .../libxcb-present0_1.10-3_armhf.deb ...
Unpacking libxcb-present0:armhf (1.10-3) ...
Selecting previously unselected package libxcb-sync1:armhf.
Preparing to unpack .../libxcb-sync1_1.10-3_armhf.deb ...
Unpacking libxcb-sync1:armhf (1.10-3) ...
Selecting previously unselected package libxshmfence1:armhf.
Preparing to unpack .../libxshmfence1_1.1-4+rpi1_armhf.deb ...
Unpacking libxshmfence1:armhf (1.1-4+rpi1) ...
Selecting previously unselected package libxxf86vm1:armhf.
Preparing to unpack .../libxxf86vm1_1%3a1.1.3-1_armhf.deb ...
Unpacking libxxf86vm1:armhf (1:1.1.3-1) ...
Selecting previously unselected package libgl1-mesa-glx:armhf.
Preparing to unpack .../libgl1-mesa-glx_13.0.0-1+rpi1_armhf.deb ...
Unpacking libgl1-mesa-glx:armhf (13.0.0-1+rpi1) ...
Selecting previously unselected package libglu1-mesa:armhf.
Preparing to unpack .../libglu1-mesa_9.0.0-2_armhf.deb ...
Unpacking libglu1-mesa:armhf (9.0.0-2) ...
Selecting previously unselected package libopencv-core2.4:armhf.
Preparing to unpack .../libopencv-core2.4_2.4.9.1+dfsg-1+deb8u2_armhf.deb ...
Unpacking libopencv-core2.4:armhf (2.4.9.1+dfsg-1+deb8u2) ...
Selecting previously unselected package libopencv-imgproc2.4:armhf.
Preparing to unpack .../libopencv-imgproc2.4_2.4.9.1+dfsg-1+deb8u2_armhf.deb ...
Unpacking libopencv-imgproc2.4:armhf (2.4.9.1+dfsg-1+deb8u2) ...
Selecting previously unselected package libswscale3:armhf.
Preparing to unpack .../libswscale3_6%3a11.12-1~deb8u1+rpi1_armhf.deb ...
Unpacking libswscale3:armhf (6:11.12-1~deb8u1+rpi1) ...
Selecting previously unselected package libavfilter5:armhf.
Preparing to unpack .../libavfilter5_6%3a11.12-1~deb8u1+rpi1_armhf.deb ...
Unpacking libavfilter5:armhf (6:11.12-1~deb8u1+rpi1) ...
Selecting previously unselected package libvdpau1:armhf.
Preparing to unpack .../libvdpau1_1.1.1-1~bpo8+1_armhf.deb ...
Unpacking libvdpau1:armhf (1.1.1-1~bpo8+1) ...
Selecting previously unselected package libav-tools.
Preparing to unpack .../libav-tools_6%3a11.12-1~deb8u1+rpi1_armhf.deb ...
Unpacking libav-tools (6:11.12-1~deb8u1+rpi1) ...
Selecting previously unselected package libdrm-amdgpu1:armhf.
Preparing to unpack .../libdrm-amdgpu1_2.4.71-1+rpi1_armhf.deb ...
Unpacking libdrm-amdgpu1:armhf (2.4.71-1+rpi1) ...
Selecting previously unselected package libdrm-freedreno1:armhf.
Preparing to unpack .../libdrm-freedreno1_2.4.71-1+rpi1_armhf.deb ...
Unpacking libdrm-freedreno1:armhf (2.4.71-1+rpi1) ...
Selecting previously unselected package libdrm-nouveau2:armhf.
Preparing to unpack .../libdrm-nouveau2_2.4.71-1+rpi1_armhf.deb ...
Unpacking libdrm-nouveau2:armhf (2.4.71-1+rpi1) ...
Selecting previously unselected package libdrm-radeon1:armhf.
Preparing to unpack .../libdrm-radeon1_2.4.71-1+rpi1_armhf.deb ...
Unpacking libdrm-radeon1:armhf (2.4.71-1+rpi1) ...
Selecting previously unselected package libelf1:armhf.
Preparing to unpack .../libelf1_0.159-4.2_armhf.deb ...
Unpacking libelf1:armhf (0.159-4.2) ...
Selecting previously unselected package libllvm3.9:armhf.
Preparing to unpack .../libllvm3.9_1%3a3.9-4_armhf.deb ...
Unpacking libllvm3.9:armhf (1:3.9-4) ...
Selecting previously unselected package libgl1-mesa-dri:armhf.
Preparing to unpack .../libgl1-mesa-dri_13.0.0-1+rpi1_armhf.deb ...
Unpacking libgl1-mesa-dri:armhf (13.0.0-1+rpi1) ...
Selecting previously unselected package libtxc-dxtn-s2tc0:armhf.
Preparing to unpack .../libtxc-dxtn-s2tc0_0~git20131104-1.1_armhf.deb ...
Unpacking libtxc-dxtn-s2tc0:armhf (0~git20131104-1.1) ...
Processing triggers for libc-bin (2.19-18+deb8u10) ...
Setting up libraw1394-11:armhf (2.1.0-3) ...
Setting up libdc1394-22:armhf (2.2.3-1) ...
Setting up libavdevice55:armhf (6:11.12-1~deb8u1+rpi1) ...
Setting up libglapi-mesa:armhf (13.0.0-1+rpi1) ...
Setting up libxcb-dri2-0:armhf (1.10-3) ...
Setting up libxcb-dri3-0:armhf (1.10-3) ...
Setting up libxcb-glx0:armhf (1.10-3) ...
Setting up libxcb-present0:armhf (1.10-3) ...
Setting up libxcb-sync1:armhf (1.10-3) ...
Setting up libxshmfence1:armhf (1.1-4+rpi1) ...
Setting up libxxf86vm1:armhf (1:1.1.3-1) ...
Setting up libgl1-mesa-glx:armhf (13.0.0-1+rpi1) ...
Setting up libglu1-mesa:armhf (9.0.0-2) ...
Setting up libopencv-core2.4:armhf (2.4.9.1+dfsg-1+deb8u2) ...
Setting up libopencv-imgproc2.4:armhf (2.4.9.1+dfsg-1+deb8u2) ...
Setting up libswscale3:armhf (6:11.12-1~deb8u1+rpi1) ...
Setting up libavfilter5:armhf (6:11.12-1~deb8u1+rpi1) ...
Setting up libvdpau1:armhf (1.1.1-1~bpo8+1) ...
Setting up libav-tools (6:11.12-1~deb8u1+rpi1) ...
Setting up libdrm-amdgpu1:armhf (2.4.71-1+rpi1) ...
Setting up libdrm-freedreno1:armhf (2.4.71-1+rpi1) ...
Setting up libdrm-nouveau2:armhf (2.4.71-1+rpi1) ...
Setting up libdrm-radeon1:armhf (2.4.71-1+rpi1) ...
Setting up libelf1:armhf (0.159-4.2) ...
Setting up libllvm3.9:armhf (1:3.9-4) ...
Setting up libgl1-mesa-dri:armhf (13.0.0-1+rpi1) ...
Setting up libtxc-dxtn-s2tc0:armhf (0~git20131104-1.1) ...
update-alternatives: using /usr/lib/arm-linux-gnueabihf/libtxc_dxtn_s2tc.so.0 to provide /usr/lib/arm-linux-gnueabihf/libtxc_dxtn.so (libtxc-dxtn-arm-linux-gnueabihf) in auto mode
Processing triggers for libc-bin (2.19-18+deb8u10) ...

cronのインストール

定刻になったら自動で録音させたいが,Volumio2にはcronがデフォルトでは導入されていないのでインストールが必要:

volumio@volumio:~$ sudo apt install cron
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  bsd-mailx exim4 exim4-base exim4-config exim4-daemon-light liblockfile-bin liblockfile1
Suggested packages:
  anacron logrotate checksecurity mail-reader eximon4 exim4-doc-html exim4-doc-info spf-tools-perl swaks
Recommended packages:
  mailx
The following NEW packages will be installed:
  bsd-mailx cron exim4 exim4-base exim4-config exim4-daemon-light liblockfile-bin liblockfile1
0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
Need to get 2,333 kB of archives.
After this operation, 4,166 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.volumio.org/raspbian/ jessie/main cron armhf 3.0pl1-127+deb8u1 [90.4 kB]
Get:2 http://archive.volumio.org/raspbian/ jessie/main liblockfile-bin armhf 1.09-6 [18.2 kB]
Get:3 http://archive.volumio.org/raspbian/ jessie/main liblockfile1 armhf 1.09-6 [14.7 kB]
Get:4 http://archive.volumio.org/raspbian/ jessie/main exim4-config all 4.84.2-2+deb8u5 [503 kB]
Get:5 http://archive.volumio.org/raspbian/ jessie/main exim4-base armhf 4.84.2-2+deb8u5 [1,046 kB]
Get:6 http://archive.volumio.org/raspbian/ jessie/main exim4-daemon-light armhf 4.84.2-2+deb8u5 [578 kB]
Get:7 http://archive.volumio.org/raspbian/ jessie/main bsd-mailx armhf 8.1.2-0.20141216cvs-2 [74.3 kB]
Get:8 http://archive.volumio.org/raspbian/ jessie/main exim4 all 4.84.2-2+deb8u5 [8,542 B]
Fetched 2,333 kB in 4s (468 kB/s)
Preconfiguring packages ...
Selecting previously unselected package cron.
(Reading database ... 28650 files and directories currently installed.)
Preparing to unpack .../cron_3.0pl1-127+deb8u1_armhf.deb ...
Unpacking cron (3.0pl1-127+deb8u1) ...
Selecting previously unselected package liblockfile-bin.
Preparing to unpack .../liblockfile-bin_1.09-6_armhf.deb ...
Unpacking liblockfile-bin (1.09-6) ...
Selecting previously unselected package liblockfile1:armhf.
Preparing to unpack .../liblockfile1_1.09-6_armhf.deb ...
Unpacking liblockfile1:armhf (1.09-6) ...
Selecting previously unselected package exim4-config.
Preparing to unpack .../exim4-config_4.84.2-2+deb8u5_all.deb ...
Unpacking exim4-config (4.84.2-2+deb8u5) ...
Selecting previously unselected package exim4-base.
Preparing to unpack .../exim4-base_4.84.2-2+deb8u5_armhf.deb ...
Unpacking exim4-base (4.84.2-2+deb8u5) ...
Selecting previously unselected package exim4-daemon-light.
Preparing to unpack .../exim4-daemon-light_4.84.2-2+deb8u5_armhf.deb ...
Unpacking exim4-daemon-light (4.84.2-2+deb8u5) ...
Selecting previously unselected package bsd-mailx.
Preparing to unpack .../bsd-mailx_8.1.2-0.20141216cvs-2_armhf.deb ...
Unpacking bsd-mailx (8.1.2-0.20141216cvs-2) ...
Selecting previously unselected package exim4.
Preparing to unpack .../exim4_4.84.2-2+deb8u5_all.deb ...
Unpacking exim4 (4.84.2-2+deb8u5) ...
Processing triggers for systemd (215-17+deb8u8) ...
Setting up cron (3.0pl1-127+deb8u1) ...
Adding group `crontab' (GID 119) ...
Done.
update-rc.d: warning: start and stop actions are no longer supported; falling back to defaults
Setting up liblockfile-bin (1.09-6) ...
Setting up liblockfile1:armhf (1.09-6) ...
Setting up exim4-config (4.84.2-2+deb8u5) ...
Adding system-user for exim (v4)
Setting up exim4-base (4.84.2-2+deb8u5) ...
exim: DB upgrade, deleting hints-db
Setting up exim4-daemon-light (4.84.2-2+deb8u5) ...
Setting up bsd-mailx (8.1.2-0.20141216cvs-2) ...
update-alternatives: using /usr/bin/bsd-mailx to provide /usr/bin/mailx (mailx) in auto mode
Setting up exim4 (4.84.2-2+deb8u5) ...
Processing triggers for systemd (215-17+deb8u8) ...
Processing triggers for libc-bin (2.19-18+deb8u10) ...

本実装

本実装として,実動の部分を作成する.

シェルスクリプト

4つの引数

  1. 放送局指定(第1ならr1,第2ならr2,FMならfm
  2. 録音時間指定(分単位)
  3. 音声ファイルの一時保存ディレクトリーパス指定
  4. 音声ファイルのファイルサーバー保存ディレクトリーパス指定

を与える.一番の注意点はavconvにて,-bsf:a aac_adtstoascのオプションがないと,VLC media player以外のプレイヤーでは再生できない(おそらく正しいAACファイルとならない).

実行例は以下のcronの項目参照.

cron

/etc/crontab

  1. 実行開始時刻(日時と曜日)
  2. 実行ユーザー
  3. 上記シェルスクリプトパス
  4. 選局
  5. 録音時間[分]
  6. 音声ファイルの一時保存ディレクトリーパス
  7. 音声ファイルのファイルサーバー保存ディレクトリーパス

を記載する:

 /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/bin:/bin:/usr/bin

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/nhk-radio-recorder/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/nhk-radio-recorder/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/nhk-radio-recorder/anacron || ( cd / && run-parts --report /etc/cron.monthly )

# まいにちフランス語(入門編)
30  7   * * 1-3 volumio /home/volumio/nhk-radio-recorder/nhk-radio-recorder.sh r2 16 /home/volumio      /mnt/NAS/GOGAKU
# まいにち中国語
15  8   * * 1-5 volumio /home/volumio/nhk-radio-recorder/nhk-radio-recorder.sh r2 16 /home/volumio      /mnt/NAS/GOGAKU
# 英会話タイムトライアル
30  8   * * 1-5 volumio /home/volumio/nhk-radio-recorder/nhk-radio-recorder.sh r2 11 /home/volumio      /mnt/NAS/GOGAKU
# ボキャブライダー
 5  9   * * 1-5 volumio /home/volumio/nhk-radio-recorder/nhk-radio-recorder.sh r2  6 /home/volumio      /mnt/NAS/GOGAKU
#エンジョイ・シンプル・イングリッシュ 
10  9   * * 1-5 volumio /home/volumio/nhk-radio-recorder/nhk-radio-recorder.sh r2  6 /home/volumio      /mnt/NAS/GOGAKU
# ラジオビジネス英語
15  9   * * 1-2 volumio /home/volumio/nhk-radio-recorder/nhk-radio-recorder.sh r2 16 /home/volumio      /mnt/NAS/GOGAKU
# ステップアップ中国語
 0 22   * * 1-2 volumio /home/volumio/nhk-radio-recorder/nhk-radio-recorder.sh r2 16 /home/volumio      /mnt/NAS/GOGAKU
# 高校生からはじめる「現代英語」
 0 22   * * 4-5 volumio /home/volumio/nhk-radio-recorder/nhk-radio-recorder.sh r2 16 /home/volumio      /mnt/NAS/GOGAKU
# ニュースで英語術
55 12   * * 1-5 volumio /home/volumio/nhk-radio-recorder/nhk-radio-recorder.sh r2  6 /home/volumio      /mnt/NAS/GOGAKU

例えば,まいにちフランス語(入門編)の場合,7時30分で,月~水曜日,ラジオ第2,15分なので

30  7   * * 1-3 volumio /home/volumio/nhk-radio-recorder/nhk-radio-recorder.sh r2 16 /home/volumio      /mnt/NAS/GOGAKU

と記載する.15分であるにもかかわらず16という指定なのは,バッファーの関係(?)で録音開始時には直前の番組の終了30秒程度を録音してしまうためである.改善方法をご存じの方がいらっしゃいましたら教えてください!

その他

ffmpeg導入検討→失敗

aptでインストールできるとの情報や,add-apt-repositoryを使用すればよいとの情報があったが,結局失敗した:

volumio@volumio:~$ sudo apt install ffmpeg
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package ffmpeg is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'ffmpeg' has no installation candidate
volumio@volumio:~$ sudo add-apt-repository ppa:mc3man/trusty-media
sudo: add-apt-repository: command not found
volumio@volumio:~$ sudo apt install software-properties-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  apt-utils dh-python iso-codes libapt-inst1.5 libmpdec2 libpython3-stdlib libpython3.4-minimal libpython3.4-stdlib lsb-release
  python-apt-common python3 python3-apt python3-dbus python3-gi python3-minimal python3-software-properties python3.4 python3.4-minimal
  unattended-upgrades
Suggested packages:
  isoquery lsb python3-doc python3-tk python3-venv python3-apt-dbg python-apt-doc python-dbus-doc python3-dbus-dbg python3.4-venv
  python3.4-doc binutils binfmt-support bsd-mailx mail-transport-agent
The following NEW packages will be installed:
  apt-utils dh-python iso-codes libapt-inst1.5 libmpdec2 libpython3-stdlib libpython3.4-minimal libpython3.4-stdlib lsb-release
  python-apt-common python3 python3-apt python3-dbus python3-gi python3-minimal python3-software-properties python3.4 python3.4-minimal
  software-properties-common unattended-upgrades
0 upgraded, 20 newly installed, 0 to remove and 0 not upgraded.
Need to get 8,102 kB of archives.
After this operation, 38.3 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.volumio.org/raspbian/ jessie/main libapt-inst1.5 armhf 1.0.9.8.4 [166 kB]
Get:2 http://archive.volumio.org/raspbian/ jessie/main libmpdec2 armhf 2.4.1-1 [65.8 kB]
Get:3 http://archive.volumio.org/raspbian/ jessie/main libpython3.4-minimal armhf 3.4.2-1+deb8u1 [483 kB]
Get:4 http://archive.volumio.org/raspbian/ jessie/main libpython3.4-stdlib armhf 3.4.2-1+deb8u1 [2,012 kB]
Get:5 http://archive.volumio.org/raspbian/ jessie/main python3.4-minimal armhf 3.4.2-1+deb8u1 [1,354 kB]
Get:6 http://archive.volumio.org/raspbian/ jessie/main apt-utils armhf 1.0.9.8.4 [353 kB]
Get:7 http://archive.volumio.org/raspbian/ jessie/main python3.4 armhf 3.4.2-1+deb8u1 [204 kB]
Get:8 http://archive.volumio.org/raspbian/ jessie/main python3-minimal armhf 3.4.2-2 [34.7 kB]
Get:9 http://archive.volumio.org/raspbian/ jessie/main libpython3-stdlib armhf 3.4.2-2 [18.1 kB]
Get:10 http://archive.volumio.org/raspbian/ jessie/main python3 armhf 3.4.2-2 [21.2 kB]
Get:11 http://archive.volumio.org/raspbian/ jessie/main dh-python all 1.20141111-2 [66.4 kB]
Get:12 http://archive.volumio.org/raspbian/ jessie/main iso-codes all 3.57-1 [2,265 kB]
Get:13 http://archive.volumio.org/raspbian/ jessie/main lsb-release all 4.1+Debian13+rpi1+nmu1 [26.7 kB]
Get:14 http://archive.volumio.org/raspbian/ jessie/main python-apt-common all 0.9.3.12 [89.9 kB]
Get:15 http://archive.volumio.org/raspbian/ jessie/main python3-apt armhf 0.9.3.12 [154 kB]
Get:16 http://archive.volumio.org/raspbian/ jessie/main python3-dbus armhf 1.2.0-2+b1 [186 kB]
Get:17 http://archive.volumio.org/raspbian/ jessie/main python3-gi armhf 3.14.0-1 [436 kB]
Get:18 http://archive.volumio.org/raspbian/ jessie/main unattended-upgrades all 0.81+rpi1 [45.7 kB]
Get:19 http://archive.volumio.org/raspbian/ jessie/main python3-software-properties all 0.92.25debian1 [41.4 kB]
Get:20 http://archive.volumio.org/raspbian/ jessie/main software-properties-common all 0.92.25debian1 [79.3 kB]
Fetched 8,102 kB in 11s (678 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libapt-inst1.5:armhf.
(Reading database ... 24831 files and directories currently installed.)
Preparing to unpack .../libapt-inst1.5_1.0.9.8.4_armhf.deb ...
Unpacking libapt-inst1.5:armhf (1.0.9.8.4) ...
Selecting previously unselected package libmpdec2:armhf.
Preparing to unpack .../libmpdec2_2.4.1-1_armhf.deb ...
Unpacking libmpdec2:armhf (2.4.1-1) ...
Selecting previously unselected package libpython3.4-minimal:armhf.
Preparing to unpack .../libpython3.4-minimal_3.4.2-1+deb8u1_armhf.deb ...
Unpacking libpython3.4-minimal:armhf (3.4.2-1+deb8u1) ...
Selecting previously unselected package libpython3.4-stdlib:armhf.
Preparing to unpack .../libpython3.4-stdlib_3.4.2-1+deb8u1_armhf.deb ...
Unpacking libpython3.4-stdlib:armhf (3.4.2-1+deb8u1) ...
Selecting previously unselected package python3.4-minimal.
Preparing to unpack .../python3.4-minimal_3.4.2-1+deb8u1_armhf.deb ...
Unpacking python3.4-minimal (3.4.2-1+deb8u1) ...
Selecting previously unselected package apt-utils.
Preparing to unpack .../apt-utils_1.0.9.8.4_armhf.deb ...
Unpacking apt-utils (1.0.9.8.4) ...
Selecting previously unselected package python3.4.
Preparing to unpack .../python3.4_3.4.2-1+deb8u1_armhf.deb ...
Unpacking python3.4 (3.4.2-1+deb8u1) ...
Selecting previously unselected package python3-minimal.
Preparing to unpack .../python3-minimal_3.4.2-2_armhf.deb ...
Unpacking python3-minimal (3.4.2-2) ...
Selecting previously unselected package libpython3-stdlib:armhf.
Preparing to unpack .../libpython3-stdlib_3.4.2-2_armhf.deb ...
Unpacking libpython3-stdlib:armhf (3.4.2-2) ...
Selecting previously unselected package python3.
Preparing to unpack .../python3_3.4.2-2_armhf.deb ...
Unpacking python3 (3.4.2-2) ...
Selecting previously unselected package dh-python.
Preparing to unpack .../dh-python_1.20141111-2_all.deb ...
Unpacking dh-python (1.20141111-2) ...
Selecting previously unselected package iso-codes.
Preparing to unpack .../iso-codes_3.57-1_all.deb ...
Unpacking iso-codes (3.57-1) ...
Selecting previously unselected package lsb-release.
Preparing to unpack .../lsb-release_4.1+Debian13+rpi1+nmu1_all.deb ...
Unpacking lsb-release (4.1+Debian13+rpi1+nmu1) ...
Selecting previously unselected package python-apt-common.
Preparing to unpack .../python-apt-common_0.9.3.12_all.deb ...
Unpacking python-apt-common (0.9.3.12) ...
Selecting previously unselected package python3-apt.
Preparing to unpack .../python3-apt_0.9.3.12_armhf.deb ...
Unpacking python3-apt (0.9.3.12) ...
Selecting previously unselected package python3-dbus.
Preparing to unpack .../python3-dbus_1.2.0-2+b1_armhf.deb ...
Unpacking python3-dbus (1.2.0-2+b1) ...
Selecting previously unselected package python3-gi.
Preparing to unpack .../python3-gi_3.14.0-1_armhf.deb ...
Unpacking python3-gi (3.14.0-1) ...
Selecting previously unselected package unattended-upgrades.
Preparing to unpack .../unattended-upgrades_0.81+rpi1_all.deb ...
Unpacking unattended-upgrades (0.81+rpi1) ...
Selecting previously unselected package python3-software-properties.
Preparing to unpack .../python3-software-properties_0.92.25debian1_all.deb ...
Unpacking python3-software-properties (0.92.25debian1) ...
Selecting previously unselected package software-properties-common.
Preparing to unpack .../software-properties-common_0.92.25debian1_all.deb ...
Unpacking software-properties-common (0.92.25debian1) ...
Processing triggers for mime-support (3.58) ...
Processing triggers for systemd (215-17+deb8u8) ...
Processing triggers for dbus (1.8.22-0+deb8u1) ...
Setting up libapt-inst1.5:armhf (1.0.9.8.4) ...
Setting up libmpdec2:armhf (2.4.1-1) ...
Setting up libpython3.4-minimal:armhf (3.4.2-1+deb8u1) ...
Setting up libpython3.4-stdlib:armhf (3.4.2-1+deb8u1) ...
Setting up python3.4-minimal (3.4.2-1+deb8u1) ...
Setting up apt-utils (1.0.9.8.4) ...
Setting up python3.4 (3.4.2-1+deb8u1) ...
Setting up python3-minimal (3.4.2-2) ...
Setting up libpython3-stdlib:armhf (3.4.2-2) ...
Setting up iso-codes (3.57-1) ...
Setting up lsb-release (4.1+Debian13+rpi1+nmu1) ...
Setting up python-apt-common (0.9.3.12) ...
Setting up python3 (3.4.2-2) ...
running python rtupdate hooks for python3.4...
running python post-rtupdate hooks for python3.4...
Setting up dh-python (1.20141111-2) ...
Setting up python3-apt (0.9.3.12) ...
Setting up python3-dbus (1.2.0-2+b1) ...
Setting up python3-gi (3.14.0-1) ...
Setting up unattended-upgrades (0.81+rpi1) ...
update-rc.d: warning: start and stop actions are no longer supported; falling back to defaults
Setting up python3-software-properties (0.92.25debian1) ...
Setting up software-properties-common (0.92.25debian1) ...
Processing triggers for libc-bin (2.19-18+deb8u10) ...
Processing triggers for systemd (215-17+deb8u8) ...
Processing triggers for dbus (1.8.22-0+deb8u1) ...
volumio@volumio:~$ sudo add-apt-repository ppa:mc3man/trusty-media
You are about to add the following PPA to your system:
 Upgraded, advanced or not normally available multimedia packages for Trusty
Xenial users go here - https://launchpad.net/~mc3man/+archive/ubuntu/xerus-media

*Please note that if using this ppa I would *not* try upgrading to 14.10/15.04, ect. Do a fresh install instead. The intent here is just for users wishing to stay on 14.04*

If upgrading releases anyway use ppa-purge *First* -
sudo ppa-purge  ppa:mc3man/trusty-media

Also note that using this ppa then disabling may cause issue for installing i386 packages like used by wine. So once enabled leave enabled or purge before removing.

Additionally if using apt-get * sudo  apt-get dist-upgrade will be needed* at times.(pay attention).  Otherwise package managers may be ok.

So typically to enable & first use -
sudo add-apt-repository ppa:mc3man/trusty-media
sudo apt-get update
sudo apt-get dist-upgrade

A few notes:
gstreamer0.10-ffmpeg - needed for some apps that still use gstreamer-0.10 & also provides h.264 in html5 decoding for firefox < 30.
Note that Firefox 30 will support h.264 in html5 thru gstreamer1.0-libav & should be available soon

A standalone ppa is here for gstreamer0.10-ffmpeg  -
https://launchpad.net/~mc3man/+archive/ubuntu/gstffmpeg-keep

Vlc: after upgrading please remove ~/.config/vlc folder to ensure proper runnning

Totem - New - have added a --no-existing-session option to open a 2nd instance. Unity users can also find it in the totem quicklist

Totem+grilo - it's quite possible this & RB+grilo will show in 14.04 by first point release, if so will probably remove. Also note some plugins work well, some don't at all, bit of a mess. Note that the youtube plugin is again broken, I'll not fix.

rhythmbox+grilo - needs to be enabled in rhythmbox > tools > plugins
Plus install grilo-plugins if not already

mpv - has been removed as 14.04.4-lts requires higher libva than what's in 14.04 or in this ppa
Available here with newer libva & i965 driver
https://launchpad.net/~mc3man/+archive/mpv-tests

mplayer - described here, note mencoder is not inc. & likely will not be, you may be able to use repo mencoder..
https://launchpad.net/~mc3man/+archive/mplayer-test

fdkaac (fdkaac-encoder) - described here
https://launchpad.net/~mc3man/+archive/fdkaac-encoder

x264 - for use with ffmpeg from here, supports both 8 & 10 bit encoding

ffmpeg -
a static build for use of the binaries, installed to /opt/ffmpeg
binaries are symlinked in /usr/bin (ffmpeg, ffplay, ffprobe
ffmpeg has nvenc enabled, ymmv depending on hardware/source files, ect.
See for encoder names -
ツffmpeg -encoders 2>/dev/null | grep nvenc

For info on using libfdk_aac see here -
http://trac.ffmpeg.org/wiki/Encode/AAC

Can be used for both 8 & 10 bit x264 encoding with this ppa's libx264, default is 8
For 10 bit preload the 10 bit .so first in terminal, eg.,
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/x264-10bit/libx264.so.142
or
export LD_PRELOAD=/usr/lib/i386-linux-gnu/x264-10bit/libx264.so.142

libav - has fdkaac encoding enabled

yasm -
ツhas been patched to improve compiling x265

devede -
ツcan use either avconv or ffmpeg from here
ツ1st choice for previewer is mplayer (version here is best

K9copy -
Mainly for ripping, as far as encoding there are better apps. If inclined to use for encoding then use mencoder as ffmpeg support is quite limited

For rhythmbox users a wide range of plugins can be found here -
https://launchpad.net/~fossfreedom/+archive/rhythmbox-plugins

Abcde -
ck. Suggested in synaptic for add. useful packages
A guide to config is here -
http://www.andrews-corner.org/abcde.html

An excellent  audio recorder is available here -
https://launchpad.net/~osmoma/+archive/audio-recorder

A good blender ppa is here -
ツhttps://launchpad.net/~irie/+archive/blender

To further extend this ppa to libav11 check here -
https://launchpad.net/~mc3man/+archive/ubuntu/testing6

To repeat -
*Please note that if using this ppa I would *not* try upgrading to 14.10/15.04, ect. Do a fresh install instead. The intent here is just for users wishing to stay on 14.04*
If upgrading anyway use ppa-purge first -
sudo ppa-purge  ppa:mc3man/trusty-media

Also note that with apt-get a sudo apt-get dist-upgrade is needed for initial setup & with some package upgrades
 More info: https://launchpad.net/~mc3man/+archive/ubuntu/trusty-media
Press [ENTER] to continue or ctrl-c to cancel adding it

Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 167, in <module>
    sp = SoftwareProperties(options=options)
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 105, in __init__
    self.reload_sourceslist()
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 595, in reload_sourceslist
    self.distro.get_sources(self.sourceslist)
  File "/usr/lib/python3/dist-packages/aptsources/distro.py", line 89, in get_sources
    (self.id, self.codename))
aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template for Raspbian/jessie

参考URL

  1. 最新:HLS版らじるらじるをラズベリーパイで録音する - LinuxやGadgetが好き(2021/11/11現在)
  2. らじる★らじる m3u8 を ffmpeg で録音する(8放送局)2017/9 以降対応 - 別館 子子子子子子(ねこのここねこ)はてブロ部(2021/11/11現在)
  3. [Volumio 2] タイムゾーンを変更する | R-Y-O の IT 備忘録 Ver.2.0(2021/11/11現在)
  4. [Volumio 2] cron のインストール | R-Y-O の IT 備忘録 Ver.2.0(2021/11/11現在)
  5. avconvの使い方(2021/11/11現在)
  6. Raspberry Pi (Raspbian Jessie)でRadiko録音 - Loftal Insider's Blog(2021/11/11現在)
  7. [Volumio 2] ロケールを日本語にする | R-Y-O の IT 備忘録 Ver.2.0(2021/11/11現在)
  8. Raspberry piでRadiko(ffmpegやcronの問題) - Qiita(2021/11/11現在)
  9. M3U8ファイル(.m3u8ファイル)とは - IT用語辞典 e-Words(2021/11/11現在)
  10. NHK番組表API(2021/11/11現在)

*1:なお,運用開始からは,今日(2021/11/11)時点で既に3年程度経過しており,そのときの構成メモから備忘録の意味も込めて記事とした.

*2:土日にまとめてその週の再放送,または見逃し配信にて1週間前のものは聴取できる

*3:千石電商にていくらか在庫ありを確認2018/06/19時点