NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
1 2 3 4 5 … 93 Next »
IPTV like stream from Sound Card input - FM Radio Project

 
  • 0 Vote(s) - 0 Average
IPTV like stream from Sound Card input - FM Radio Project
NumberFive
Offline

Senior Member

UK/Ireland
Posts: 664
Threads: 153
Joined: Jun 2007
#1
2022-11-20, 02:50 PM
Hello,

I'm wondering if anyone can offer a bit of guidance on this one. I am working on a project to make an FM radio tuner input for NextPVR, but in an effort to keep it simple I'm intending to make it look like an IPTV device. Maybe best if I describe the idea first.

What I'm trying to achieve is something similar to NextPVR's own method of http://nextpvr:8866/live?channel=1 , such that a channel (frequency) can be requested, and the response is an MPEG-TS stream.  I believe that NextPVR is using VLC to create the stream?

I am using a Raspberry Pi with an FM radio tuner IC attached to it (Si4703). The R Pi will listen for http requests formatted in such a way that the URL requested contains the frequency the radio IC should tune to. I have this part largely working as expected. For example, tuning to http://radio-pi:80/freq=878 tunes to 87.8 MHz.

The output of the FM radio IC is line level analogue audio, and I am feeding this into a USB soundcard. I can run FFMPEG to capture this and create an MPEG-TS stream, and listen to this using VLC on another computer.

I'm wondering, can anyone give me guidance on how to respond to the http request with the MPEG-TS stream? At the moment, the URL request just sends back a very basic HTML page. I am familiar enough with starting another program from Python, but how do I redirect the output of FFMPEG back to the client making the tuning request?

I'm programming in Python.  I'm happy to switch to VLC on the server to create the MPEG-TS steam (or any other tool) should there be an easier way to crack this nut! 

Thank you Smile
"It's better than a box!"
mvallevand
Offline

Posting Freak

Ontario Canada
Posts: 52,964
Threads: 956
Joined: May 2006
#2
2022-11-20, 03:01 PM (This post was last modified: 2022-11-20, 03:58 PM by mvallevand.)
VLC streaming with is strictly NEWA (classic mode) in v4 and earlier. What you are looking to do is upgrade to v6 and great an extra which can return data from an executable like ffmpeg to NextPVR.

The easy way is to get a linux device that supports /dev/radio I have a few but you can also do it with some rtl2832u device. You might even be able to get DAB.

Here is my extra script for controlling SDR FM on Linux with rtl_fm

Code:
rtl_fm -M wbfm -f $1 -s 380000 -r 96000 -l -150 - 2> /dev/null | ffmpeg -v panic -ar 48000 -ac 2 -f s16le -i pipe: -vn -acodec aac  -b:a 160000 -f mpegts -

For /dev/radio try something like this (after install fmtools)

Code:
fm -d /dev/radio0 $1
ffmpeg -v panic -i /dev/radio0 -ar 48000 -ac 2 -f s16le  -vn -acodec aac  -b:a 160000 -f mpegts -

Martin
NumberFive
Offline

Senior Member

UK/Ireland
Posts: 664
Threads: 153
Joined: Jun 2007
#3
2022-11-20, 04:14 PM (This post was last modified: 2022-11-20, 04:19 PM by NumberFive.)
Thanks Martin.

I'm not really trying to build a NextPVR specific thing although NEWA is definitely the inspiration. I'm trying to make something which looks like an IPTV server except the source of the media is from a soundcard and not a "digital stream" e.g. DVB, which is what the majority of solutions are interested in. If you Google for this kind of thing there are 100s of results for pirating IPTV channels, but virtually nothing on how to set up an IPTV server. Amongst other things I'd like to be able to add a few FM radio stations which have unreliable web streams (or low quality) to some TVs, but I'd also intend to add it to my NextPVR setup for recording shows.

I looked at rtl_fm on my journey to the solution I'm exploring now, but decided against an SDR approach as they don't seem to give the sensitivity I need for some remote stations and also they have a heavy CPU overhead. In an ideal world I'd get an Si4705 IC which has an ADC onboard, but they seem very difficult to get.

I'll explore /dev/radio and fmtools and see where that leads. Would be good to avoid reinventing the wheel!
"It's better than a box!"
mvallevand
Offline

Posting Freak

Ontario Canada
Posts: 52,964
Threads: 956
Joined: May 2006
#4
2022-11-20, 04:28 PM (This post was last modified: 2022-11-20, 04:29 PM by mvallevand.)
Once it is in NextPVR you can stream using NextPVR and it will be easier then setting up a web server. I know you don't like anything above v4 but v6 installs easily on your RPi so you could still stream to v4 by channel number. My python script for radio via an extra will do those channel numbers as frequencies too.

IPTV is not a protocol so I wouldn't expect much. You might get get better info using html5 for video, but really all you need to do is set up simple http mp3 streamer since all browser support it. Sub likes aac better for some reason which is why my examples are aac.

Instead of fmtools you can also use v4l2-ctl and it provides a bit of control.

Martin
« Next Oldest | Next Newest »

Users browsing this thread: 2 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  API channel.stream.start mvallevand 2 1,367 2023-05-07, 09:40 PM
Last Post: mvallevand
  Windows FM Radio support in v5. mvallevand 125 27,714 2023-01-29, 08:13 PM
Last Post: mvallevand
  Get recording length from stream skogl 46 14,058 2019-08-15, 09:34 PM
Last Post: sub
  IPTV Pretuning and Internet Radio mvallevand 5 3,199 2019-02-04, 12:02 AM
Last Post: mvallevand
  Is the input file for pvrx2.exe -import unique to NextPVR? spinnaker 1 1,784 2013-10-08, 02:25 AM
Last Post: sub
  IPTV trickle download idkpmiller 8 5,415 2009-07-19, 04:21 AM
Last Post: Dave72
  Downgrade a VS2008 project? bgowland 3 3,635 2009-05-07, 09:03 PM
Last Post: bgowland
  embedded metadata stream on recordings made by GB-PVR? reven 7 2,845 2008-12-23, 01:12 PM
Last Post: carpeVideo
  How to get user input? bgowland 3 2,222 2008-11-15, 07:03 PM
Last Post: bgowland
  WEB-Radio Improvment Reddwarf 0 1,593 2008-07-15, 04:33 PM
Last Post: Reddwarf

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode