BBCのネットラジオ

NHKはHLSなのですが、BBCはMPEG-DASHを使っているので、調べてみました。

MPEG-DASHはHLSと同じでメタデータとtsの組み合わせのようです。メタデータはXML形式でパースしてtsのURLを探し出す必要があるようです。

とりあえずFireFoxの開発者用ツールで、tsファイルのURLを探して、取得してます。

```
% file bbc_world_service-audio=96000-261993339.m4s 
bbc_world_service-audio=96000-261993339.m4s: data
% ls -l bbc_world_service-audio=96000-261993339.m4s 
-rw-r--r--  1 hiroki  1001  77595 Feb 19 06:55 bbc_world_service-audio=96000-261993339.m4s
% hd bbc_world_service-audio=96000-261993339.m4s | more
00000000  00 00 02 bc 6d 6f 6f 66  00 00 00 10 6d 66 68 64  |....moof....mfhd|
00000010  00 00 00 00 0f 9d b3 7b  00 00 02 a4 74 72 61 66  |.......{....traf|
00000020  00 00 00 1c 74 66 68 64  00 02 00 2a 00 00 00 01  |....tfhd...*....|
00000030  00 00 00 01 00 00 08 00  02 80 00 40 00 00 00 14  |...........@....|
00000040  74 66 64 74 01 00 00 00  00 00 49 33 39 4b e0 00  |tfdt......I39K..|
00000050  00 00 02 6c 74 72 75 6e  00 00 02 01 00 00 00 96  |...ltrun........|
00000060  00 00 02 c4 00 00 02 00  00 00 02 1d 00 00 01 e5  |................|
00000070  00 00 01 e5 00 00 01 ed  00 00 02 77 00 00 01 f1  |...........w....|
00000080  00 00 01 e9 00 00 02 82  00 00 01 cc 00 00 01 d7  |................|
00000090  00 00 01 c8 00 00 02 04  00 00 02 87 00 00 02 0d  |................|
000000a0  00 00 02 2f 00 00 01 c1  00 00 02 8f 00 00 01 a0  |.../............|
000000b0  00 00 01 ac 00 00 01 ba  00 00 02 2b 00 00 01 c2  |...........+....|
000000c0  00 00 01 da 00 00 01 de  00 00 02 0f 00 00 02 10  |................|
000000d0  00 00 01 f7 00 00 02 0a  00 00 02 11 00 00 02 03  |................|
000000e0  00 00 02 59 00 00 01 cc  00 00 02 04 00 00 01 d1  |...Y............|
000000f0  00 00 01 db 00 00 01 d7  00 00 01 e9 00 00 02 69  |...............i|
00000100  00 00 01 f7 00 00 01 fa  00 00 02 4c 00 00 02 06  |...........L....|
00000110  00 00 01 ef 00 00 01 ec  00 00 01 fc 00 00 01 f6  |................|
00000120  00 00 02 13 00 00 01 e9  00 00 01 ff 00 00 02 02  |................|
00000130  00 00 02 06 00 00 02 07  00 00 01 ec 00 00 01 eb  |................|
00000140  00 00 02 2a 00 00 02 a6  00 00 01 b1 00 00 01 cb  |...*............|
00000150  00 00 01 d3 00 00 01 eb  00 00 01 f4 00 00 01 e2  |................|
00000160  00 00 01 e3 00 00 02 1f  00 00 02 08 00 00 02 4c  |...............L|
00000170  00 00 02 32 00 00 01 e5  00 00 01 d6 00 00 02 0d  |...2............|
00000180  00 00 02 14 00 00 02 07  00 00 01 e9 00 00 02 a1  |................|
00000190  00 00 02 69 00 00 01 95  00 00 01 e8 00 00 01 d4  |...i............|
000001a0  00 00 02 82 00 00 01 a3  00 00 01 bf 00 00 01 f1  |................|
000001b0  00 00 02 96 00 00 01 cc  00 00 01 f8 00 00 01 e7  |................|
000001c0  00 00 01 da 00 00 01 fb  00 00 02 88 00 00 02 6c  |...............l|
000001d0  00 00 01 a3 00 00 01 c3  00 00 01 d3 00 00 01 dc  |................|
000001e0  00 00 02 97 00 00 01 c1  00 00 01 d3 00 00 01 dc  |................|
000001f0  00 00 01 d7 00 00 01 f5  00 00 01 dd 00 00 01 f1  |................|
00000200  00 00 02 69 00 00 02 17  00 00 01 e0 00 00 01 f6  |...i............|
00000210  00 00 01 e7 00 00 01 f6  00 00 01 ec 00 00 01 ec  |................|
00000220  00 00 02 34 00 00 01 f8  00 00 02 67 00 00 01 bf  |...4.......g....|
00000230  00 00 01 de 00 00 01 ef  00 00 02 00 00 00 01 eb  |................|
00000240  00 00 02 05 00 00 01 e1  00 00 01 f9 00 00 01 f9  |................|
00000250  00 00 02 93 00 00 01 f6  00 00 01 da 00 00 01 d7  |................|
00000260  00 00 01 f2 00 00 01 d5  00 00 01 d4 00 00 01 cf  |................|
00000270  00 00 02 67 00 00 01 e5  00 00 01 f9 00 00 01 f9  |...g............|
00000280  00 00 02 0e 00 00 02 0d  00 00 02 02 00 00 01 f5  |................|
00000290  00 00 01 f0 00 00 02 19  00 00 02 03 00 00 02 25  |...............%|
000002a0  00 00 02 10 00 00 02 17  00 00 01 df 00 00 01 ea  |................|
000002b0  00 00 02 a1 00 00 01 b4  00 00 01 e5 00 01 2c 5f  |..............,_|
000002c0  6d 64 61 74 21 4f 6d 41  de ab 69 89 9b 75 c5 9a  |mdat!OmA..i..u..|
000002d0  30 94 db a9 11 99 9b 8d  62 22 28 22 9e 5a 78 30  |0.......b"(".Zx0|
000002e0  b4 a4 e2 36 d7 34 2c 58  c8 dc ab a8 b4 0c 18 16  |...6.4,X........|
000002f0  eb 78 8e 67 88 ff 67 ba  7d 87 bc a4 ac d7 ed 36  |.x.g..g.}......6|
00000300  26 7c a7 97 36 6d b9 dc  7f f1 aa 63 7f e9 c9 7a  |&|..6m.....c...z|
00000310  1f a5 fb dc 37 cb 77 dc  a5 f9 e1 a9 a9 4a 6a 0b  |....7.w......Jj.|
00000320  9f ac ab 2d 61 a8 e2 41  a6 cb 39 f5 83 76 fd fb  |...-a..A..9..v..|
00000330  f2 10 3b e4 90 e5 5b 86  ed 5e 86 91 b9 2a ae 8a  |..;...[..^...*..|
00000340  8b a4 d3 49 38 48 26 10  d4 bb 21 27 22 05 5f 58  |...I8H&...!'"._X|
00000350  00 67 29 98 62 90 28 25  82 36 c9 58 6f 9f e7 56  |.g).b.(%.6.Xo..V|
00000360  f8 1b f4 ce 2c a2 ad 15  04 60 24 b5 37 cb f7 0c  |....,....`$.7...|
00000370  e9 88 48 e9 e7 2b e3 4a  de ee 58 6a ee 80 3c c4  |..H..+.J..Xj..<.|
00000380  a9 7a 2b 44 4c 6f 8c 66  9c b1 94 a1 cd 29 4e bb  |.z+DLo.f.....)N.|
00000390  54 a7 0b 43 28 6e 70 30  b1 89 92 dd 75 9b 93 d0  |T..C(np0....u...|
000003a0  0c 68 a5 c2 92 a6 2f af  a0 d6 65 f8 60 4a ad 4c  |.h..../...e.`J.L|
000003b0  53 98 c1 44 24 4b a2 5c  d1 24 16 b2 c9 4a de c4  |S..D$K.\.$...J..|
000003c0  63 65 24 8e f1 58 18 21  94 4d 08 0c 97 47 1e 13  |ce$..X.!.M...G..|
000003d0  60 fb 6b be 68 1f 0e fc  ea 41 51 22 7a 76 d9 72  |`.k.h....AQ"zv.r|
000003e0  61 73 5f 59 2a f4 15 39  65 b0 52 cf 2b 62 c6 a8  |as_Y*..9e.R.+b..|
000003f0  c7 86 00 d0 60 ad 7a 39  ec b2 cd 49 27 dc 30 8c  |....`.z9...I'.0.|
00000400  a7 49 bf 21 ba 44 86 b8  84 29 8b d8 03 19 f8 b0  |.I.!.D...)......|
00000410  c9 9a 89 a2 44 8a f8 95  dc da dd e8 a2 e9 de e3  |....D...........|
00000420  42 e7 00 a4 42 65 d1 eb  9d b4 88 1e 82 99 03 bc  |B...Be..........|
00000430  30 c4 72 fd b3 4e 9b bd  7d 76 c4 b4 cc 7c df 5e  |0.r..N..}v...|.^|
00000440  1a 36 63 bc 6b a3 27 e3  8c c2 12 9d 1a 78 6b ea  |.6c.k.'......xk.|
00000450  f6 a6 35 49 d6 81 6f 34  aa c0 f0 58 3a ca 26 ba  |..5I..o4...X:.&.|
```

ファイルはffmpegでも認識できずcodecがなんだか分かりません。DRMがかかってるのかもしれません。

そもそもBBCはmp3のストリームも残しているので、MPEG-DASHを頑張る必要はありませんでした。

中学生の頃にBCLでBBCをきいていたのを思い出しました。ビッグベンの鐘の音で始まっていたようなきがします。