{"id":76,"date":"2014-02-16T19:24:58","date_gmt":"2014-02-17T00:24:58","guid":{"rendered":"http:\/\/dogphilosophy.net\/?p=76"},"modified":"2025-01-23T18:14:24","modified_gmt":"2025-01-23T23:14:24","slug":"subversive-radio-hostraspberry-pi-fm-streaming","status":"publish","type":"post","link":"https:\/\/dogphilosophy.net\/?p=76","title":{"rendered":"&#8220;Subversive Radio Host&#8221;\/Raspberry Pi FM Streaming"},"content":{"rendered":"<p>I&#8217;m working on earning my &#8220;Subversive Radio Host&#8221; merit badge with my RaspberryPi. Once I&#8217;ve got the whole system worked out I&#8217;ll likely be doing a <a title=\"Epicanis' Hacker Public Radio Show Concepts\" href=\"http:\/\/hpr.dogphilosophy.net\/?page_id=2\" target=\"_New\" rel=\"noopener\">Hacker Public Radio episode about it<\/a>. In the meantime, though, for testing purposes I have a feed from the local NOAA Weather Radio which I am feeding as 10kbps opus audio to an instance of icecast2.<\/p>\n<p>I figured I&#8217;d post this since there&#8217;s a piece of information I found today regarding having a continuous stream, and someone else may find it useful.<\/p>\n<p>I was finding that my stream to the icecast server, using the command line suggested by the <a title=\"man page for opusenc hosted at audiophilesoft.ru (last checked 2014-02-16)\" href=\"http:\/\/audiophilesoft.ru\/commandline\/opus\/opusenc.html\" target=\"_New\" rel=\"noopener\">opusenc man page<\/a>, was spontaneously dying at almost precisely 6 hours, 12 minutes, and 50 seconds. For reference, here&#8217;s what the man page says (or at least has for quite some time now and did when I last checked it today) as a suggestion for live-streaming recorded audio in realtime:<br \/>\n<code><br \/>\narecord -c 2 -r 48000 -twav - | opusenc --bitrate 96 - - | oggfwd icecast.somewhere.org 8000 password \/stream.opus<br \/>\n<\/code><br \/>\nI was using the same string of commands, with minor changes (only one channel, &#8211;bitrate 12 [or 10], different address and credentials for oggfwd).<\/p>\n<p>To cut the drama short, the problem turns out to be arecord. I still am not sure whether arecord was hitting a &#8220;maximum number of bytes&#8221; or &#8220;maximum run time&#8221; problem, but either way, it turns out you can just use <a title=\"SOund eXchange audio utility\" href=\"http:\/\/sox.sourceforge.net\/\" target=\"_New\" rel=\"noopener\">sox<\/a> (symlinked as &#8220;rec&#8221;) in its place, which is nice because I had been thinking about playing with having sox apply some filtering to remove noise, etc.<\/p>\n<p>Here&#8217;s a suggested replacement command line for this purpose:<br \/>\n<code>rec -c 1 -t wav - | opusenc --bitrate 10 - - | oggfwd icecast.somewhere.org 8000 password \/stream.opus<\/code><br \/>\n(with the parameters adjusted to your own needs, of course).<\/p>\n<p>It&#8217;s been going for over 7 hours now, so I&#8217;m assuming my problem is resolved. In the long run it won&#8217;t matter so much &#8211; my intended use-case in the end involves playing pre-recorded files (and would work perfectly with <a title=\"ices2 for streaming ogg vorbis audio to icecast servers\" href=\"http:\/\/icecast.org\/ices.php\" target=\"_New\" rel=\"noopener\">ices2<\/a>&#8216;s features if ices2 supported opus&#8230;), but for times when I may want to live-stream something, this may come in handy. With opus at 10-12kbps being still decent quality for voice, one ought to be able to feasibly live-stream audio even over a really slow pre-&#8220;3G&#8221; cellphone data link or dial-up modem in realtime.<\/p>\n<p>Oh, speaking of &#8220;Subversive Radio Host&#8221; &#8211; using the clever <a title=\"Raspberry Pi has a circuit that can be used as an FM transmitter\" href=\"http:\/\/icrobotics.co.uk\/wiki\/index.php\/Turning_the_Raspberry_Pi_Into_an_FM_Transmitter\" target=\"_New\" rel=\"noopener\">pifm<\/a> software turns the Raspberry Pi into a remarkably powerful transmitter. I think I&#8217;ve got my antenna trimmed down enough to make it a legal unlicensed transmitter (my original test was with a 20&#8243; or so piece of alligator-clip wire that happened to be handy, and got the signal out to about three blocks away. Definitely too much power for legal unlicensed use.) I suspect with an ideal-length wire as an antenna you could cover a whole town, if you placed it well, and if you didn&#8217;t mind getting the FCC (or whoever your local regulatory agency is) very annoyed with you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m working on earning my &#8220;Subversive Radio Host&#8221; merit badge with my RaspberryPi. Once I&#8217;ve got the whole system worked out I&#8217;ll likely be doing a Hacker Public Radio episode about it. In the meantime, though, for testing purposes I have a feed from the local NOAA Weather Radio which I am feeding as 10kbps [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/dogphilosophy.net\/index.php?rest_route=\/wp\/v2\/posts\/76"}],"collection":[{"href":"https:\/\/dogphilosophy.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dogphilosophy.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dogphilosophy.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dogphilosophy.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=76"}],"version-history":[{"count":3,"href":"https:\/\/dogphilosophy.net\/index.php?rest_route=\/wp\/v2\/posts\/76\/revisions"}],"predecessor-version":[{"id":159,"href":"https:\/\/dogphilosophy.net\/index.php?rest_route=\/wp\/v2\/posts\/76\/revisions\/159"}],"wp:attachment":[{"href":"https:\/\/dogphilosophy.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=76"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dogphilosophy.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=76"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dogphilosophy.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=76"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}