Monday, December 10, 2012

Internet radio with nginx-rtmp

With nginx-rtmp it's easy to set up internet radio channel. Here's a simple bash script for that.

while true; do
ffmpeg -re -i "`find /var/music -type f -name '*.mp3'|sort -R|head -n 1`" -vn -c:a libfaac -ar 44100 -ac 2 -f flv rtmp://localhost/myapp/radio;
done

The script takes random mp3 files from /var/music hierarchy and publishes them to nginx-rtmp.

Server-side configuration is simple.

application myapp {
live on;
}


On client side you can use any flash player.

9 comments:

  1. Установил сегодня самый актуальный ffmpeg, но при выполнении выдает:
    "unknown encoder libfaac"

    ReplyDelete
  2. Используйте libmp3lame вместо него или nellymoser. Если вы его собираете руками надо явно указывать libfaac/libmp3lame при конфигурации.

    ReplyDelete
  3. Спасибо, уже разобрался и установил libfaac.
    Дополненный конфиг для ffmpeg будет такой:
    ./configure --prefix=/opt/ffmpeg --disable-yasm --enable-shared --enable-libx264 --enable-libfaac --enable-gpl --enable-nonfree

    ReplyDelete
  4. По логу все нормально. А в чем, собственно, проблема? Не играет? Попробуйте ffplay для начала. Кстати сайт аналогичный вашему есть у JWPlayer, попробуйте там.

    ReplyDelete
  5. С этим разобрался, спасибо.

    Теперь буду разбираться, как брать сторонний rtmp поток с CDN сервиса и транслировать его на iOS в HLS.

    ReplyDelete
  6. Hi,
    The problem with looping through ffmpeg command is that rtmp service "ends" the transmission upon completion of first song. And the flash player stops there thinking the broadcast has ended. The next published stream can be played after pressing the play button on flash player. However, this issue doesn't happen always

    Thanks

    ReplyDelete
  7. what's your player? Jw doesn't stop.

    ReplyDelete
  8. Ringtones are the trend most for everyone. So your ringtone is satisfied? Ringtones have the best quality and unique? We will give you the new and trendy ringtone of 2018. You can refer and search for other ringtones on your homepage: https://ringtonesmobile.net/

    This is the most installed ringtone in 2018, you can leave some reviews for my ringtone:

    - https://ringtonesmobile.net/pilla-ra-ringtone-download.html
    - https://ringtonesmobile.net/rx100-ringtone-download.html
    - https://ringtonesmobile.net/shape-of-you-ringtone-download.html
    - https://ringtonesmobile.net/despacito-ringtone-download.html
    - https://ringtonesmobile.net/dilbar-dilbar-ringtone-download.html

    Free ringtones for you and everyone. Get together, install and share with your friends. Hope my ringtone will bring a new look to the ringtone world. Thank you!

    ReplyDelete
  9. It was great to experience ringtones at RingtonesCloud.com

    ReplyDelete