Hacker News Re-Imagined

Make an internet radio station with one line of bash

  • 153 points
  • β€’ 7 days ago

  • @qrv3w
  • Created a post

Make an internet radio station with one line of bash


@okl β€’ 7 days

Replying to @qrv3w πŸŽ™

Title is misleading at best.

Reply


@kingosticks β€’ 7 days

Replying to @qrv3w πŸŽ™

Doesn't an icecast server already do what broadcast-server does? You post an audio stream to it and it relays that to clients. What am I missing?

Reply


@slingnow β€’ 7 days

Replying to @qrv3w πŸŽ™

If I write a complex piece of software that does something even marginally interesting, I'm going to post it to HN with a similar title. After all, I'm sure I can execute it with one line of bash, so the title is appropriate, right?

Reply


@bin_bash β€’ 7 days

Replying to @qrv3w πŸŽ™

I mean, you could probably launch nuclear missiles with a line of bash

Reply


@twobitshifter β€’ 7 days

Replying to @qrv3w πŸŽ™

Coincidentally today is the anniversary of the first public radio broadcast in 1910.

https://www.edn.com/1st-public-radio-broadcast-january-13-19...

Reply


@spython β€’ 7 days

Replying to @qrv3w πŸŽ™

Does anyone have experience with https://www.liquidsoap.info/ for simple radio stations? Is it any good?

Reply


@buscoquadnary β€’ 7 days

Replying to @qrv3w πŸŽ™

Next post of this type is "execute any arbitrary binary with one line of bash"

Reply


@charcircuit β€’ 7 days

Replying to @qrv3w πŸŽ™

That's 3 lines of "bash." Not one.

Reply


@rdelpret β€’ 7 days

Replying to @qrv3w πŸŽ™

I did something similar so I could listen to my vinyl records over an in home ip radio station on my Sonos without buying their $500 box that lets you add arbitrary audio input.

Reply


@rini17 β€’ 6 days

Replying to @qrv3w πŸŽ™

Nobody has problems with dropped TCP connections when streaming?

Tried icecast2 on several servers at distinct hosters and audio tag on various browsers and platforms, in maybe tens of minutes it always seized up. I had to add script to client page had to detect it and reconnect, the pauses were annoying, gave up.

Did not dig deeper seems as if routers drop the connection when there are no data transmitted in one direction.

Reply


@technoplato β€’ 7 days

Replying to @qrv3w πŸŽ™

I think the dissenting / mocking comments here are missing the spirit of the post.

Since bash can evoke any Turing complete program, feasibly anything could be done with one line of bash.

The authors intent as I saw was to show what that line was. Would you have known without this article?

Whether or not people are just being sarcastic, I feel we should definitely not mock but rather encourage any open and free attempts at teaching us cool things that are more novel than the β€œhow to get started on Linux” type bs the market is inundated with.

Bravo to author.

Reply


@qwertyuiop12 β€’ 7 days

Replying to @qrv3w πŸŽ™

Do whatever in one line: 1) Open a source code with Sublime 2) Ctrl+J to join the lines 3) Enjoy

Reply


@marcodiego β€’ 7 days

Replying to @qrv3w πŸŽ™

The examples use "broadcast.schollz.com" as a service. How do I do it on a local network?

Reply


@hffftz β€’ 7 days

Replying to @qrv3w πŸŽ™

Record the mic to a remote server:

    ffmpeg -nostdin -f alsa -i pulse -c:a libmp3lame -ar 44100 -b:a 128k -ac 1 -f mp3 - | ssh -C vps "cat - > /var/www/output-$(date '+%s').mp3"

Reply


@darau1 β€’ 7 days

Replying to @qrv3w πŸŽ™

Fascinating. I recall two other interesting uses of ffmpeg: to stream to twitch[1], and to record video[2].

[1] https://stackoverflow.com/questions/54273291/streaming-a-str...

[2] https://www.youtube.com/watch?v=HO6oU5oT6uU

Reply


@junon β€’ 7 days

Replying to @qrv3w πŸŽ™

This is really cool. I have a little node.js script I wrote that generates a funky little beat I call "egypt.js"[0] and outputs the PCM data to stdout, just for weird things like this.

My local WSL1 install of ffmpeg has an issue with the LAME encoder so using a few extra pipes I was able to get this working! Confirmed with a friend they were able to listen across the planet.

    node /tmp/egypt.js | ffmpeg -f f64le -ar 176400 -i pipe: -f wav - | lame - - | curl -s -k -H "Transfer-Encoding: chunked" -X POST -T - "https://broadcast.schollz.com/egypt.mp3?stream=true&advertise=true"

Neat stuff! I love things like this.

[0] https://gist.github.com/Qix-/7c131c6eb83bef7c44ef6faaf1eab10...

Reply


@b215826 β€’ 7 days

Replying to @qrv3w πŸŽ™

Browse the Internet with one line of Bash:

  firefox https://news.ycombinator.com
But seriously, the commands in the article are not Bash commands (they don't even use Bashisms) and are valid in any POSIX-compliant shell.

Reply


@belter β€’ 7 days

Replying to @qrv3w πŸŽ™

If the network is down...Carry on. The music can't stop.

"System Bus Radio" https://github.com/fulldecent/system-bus-radio

Reply


@soheil β€’ 7 days

Replying to @qrv3w πŸŽ™

For osx:

  ffmpeg -f avfoundation -i ":1"

Reply


@Drybones β€’ 7 days

Replying to @qrv3w πŸŽ™

This article isn't very useful for a "one liner radio", but I use icecast2 in a couple of ways

1. I host a VGM radio [1] 2. I use a combination of icecast2 and darkice to have a full home audio networking.

With the home audio network, there's a lot to optimize, but I haven't implemented it much more to experiment with it further.

Basically I have a Ubuntu Desktop VM on my home server. A long range bluetooth receiver [2] is feed from Proxmox host into the VM. The audio from the Bluetooth source (say your phone or your computer) is pulled from Darkice and renders an MP3 file/stream into Icecast2, which then broadcasts it on 10.0.0.10:8000/home I can use devices like Raspberry Pis to continuously listen on that URL for playback and play if it's available. There's CLI audio players like mpg123.

This could be used for whole home audio playback, but there's weird quirks to deal with like the delay between the audio in and when you hear it, as well as it becoming desynced over time.

It can also be setup in reverse where a RPi ingests audio from it's audio jack and sends it to the audio hub VM and the audio hub sends it out to the network.

[1] https://vidya.fm [2] https://www.amazon.com/gp/product/B07KTK8YP3/

Reply


About Us

site design / logo Β© 2022 Box Piper