Project

General

Profile

How to add http stream to TVHeadend

Added by GS Hodg over 6 years ago

Hi, thanks to help on this forum I've got TVHeadend working well with two tuners (DVB-S2 and DVB-T).

Now I'd like to understand how to add some other internet streams to it.

For example, here is a ustream link that is broadcasting today and tomorrow that I'm following, and I'd like to use this as an example to learn how to add it:

http://www.ustream.tv/channel/17457117

All help, greatly appreciated.

My setup is:

HTS Tvheadend 3.9.2496~gd386ed0
OpenELEC 5.0.7 / Kodi 14.2


Replies (12)

RE: How to add http stream to TVHeadend - Added by András Frankovics over 6 years ago

I'm very curious about that too!

RE: How to add http stream to TVHeadend - Added by nothing works about 6 years ago

Hello everyone, any update on this? I am curious to know if we could add radio streams, specially from http://www.listenlive.eu/

RE: How to add http stream to TVHeadend - Added by András Frankovics about 6 years ago

Perexg made some improvement about IPTV (port number, etc) but I don't have enough time to give it a try.

RE: How to add http stream to TVHeadend - Added by Hanspeter Müller about 6 years ago

GS Hodg wrote:

Now I'd like to understand how to add some other internet streams to it.

For for http-based video, you have to do it "yourself" with the pipe://-handler. For plain http-links (like mp4/m3u8/hls-streaming), you can add them using avconv/ffmpeg, put something like this in a script

#!/bin/bash
avconv -re -v error -fflags +genpts -i "$1" -c copy -f mpegts pipe:1

For sites like ustream, youtube, vaugnlive etc, it's more complicated, they don't want you to use anything but a browser, so you need a special tool to suck the streams into tvheadend, http://docs.livestreamer.io/ works for a lot of sites. Install this, then use a script like

#!/bin/bash
livestreamer -O "$1" best | avconv -re -v error -fflags +genpts -i pipe:0 -bsf h264_mp4toannexb -vcodec libx264 -acodec ac3 -f mpegts pipe:1

then add this as an iptv-mux and use "pipe:///path/to/script.sh http://streamingurl" in tvheadend, map services as usual.

You may have to tinker with the encoding settings (pass-through like in the first example only works for something "clean" like h264/aac, that's why my livestreamer example reencodes everything), if viewing works, but recordings are blank/broken, you at least have to add new pts timestamps...

But be aware, sites like ustream etc are moving targets, sometimes it works for weeks and months without a hitch, then they start to change stuff and you have to beg the livestreamer guys to update the plugins...

Have fun, and post again if you have problems :)

/hp

RE: How to add http stream to TVHeadend - Added by András Frankovics about 6 years ago

Hanspeter Müller wrote:

Have fun, and post again if you have problems :)

Here I'm! :)

I've created a command that works in command line:

/usr/bin/ffmpeg -i http://195.56.193.129:8100 -acodec libmp3lame -metadata service_provider=Sunshine_Radio -metadata service_name=Sunshine_FM -f mpegts -mpegts_service_type digital_radio -ab 160k -ar 44100 stream.ts

It creates a stream.ts file from the shoutcast radio stream. It works, full of happiness! :)

BUT if I put this in the IPTV options like in the image, it says:

mpegts: SunshineFM in Net_stream - scan no data, failed

(Yes, I deleted the ending stream.ts and replaced it with pipe:1, and yes I tried with the stream address in the URL: option.)

Could you help me what did I wrong?

Thank you for your time!

try.jpg (75.9 KB) try.jpg IPTV option

RE: How to add http stream to TVHeadend - Added by Hanspeter Müller about 6 years ago

András Frankovics wrote::)

Hanspeter Müller wrote:

Have fun, and post again if you have problems :)

Here I'm! :)

[...]

Could you help me what did I wrong?

Yeah, that's an easy one, you have to put the pipe://command into the URL field, not in to the Environment Field :)

Regards,

/hp

RE: How to add http stream to TVHeadend - Added by András Frankovics about 6 years ago

Hanspeter Müller wrote:
[...]

That you for the help, it works!

But not totally. :S

My URL fields config is look like this:
pipe:///usr/bin/ffmpeg -loglevel fatal -i http://195.56.193.129:8100 -vn -acodec libmp3lame -metadata service_provider=Sunshine -metadata service_name=SunshineFM -f mpegts -mpegts_service_type digital_radio pipe:1

When I run the scan, it ends with success.
It creates two service. One is unusable, but the other is working with VLC.
I can map it, and it placed in the radio group. It still accessible with VLC.

But when I go to Kodi's Radio tab, sometimes it freezes, sometimes I can see the radio station. When I go to the station and try to open it, it says No input detected. Here is a log from tvheadend:

subscription: 0080: No input source available for subscription "x.y.z.45 [ tvadmin | Kodi Media Center ]" to channel "SunshineFM"

I tried it with Kodi 14 (old tvheadend plugin) and Kodi 15 (latest tvheadend plugin).

What do I wrong again? Or what can I do in another way?

And again, many thanks for your help!

RE: How to add http stream to TVHeadend - Added by Hanspeter Müller about 6 years ago

Hi,

sorry for the late reply, somehow missed your second post. I'm not really sure why, but i never could get it working stable while putting the commands directly into the url-field, so i put it in a script like

#/bin/bash
/usr/bin/ffmpeg -loglevel fatal -i http://195.56.193.129:8100 -vn -acodec libmp3lame -metadata service_provider=Sunshine -metadata service_name=SunshineFM -f mpegts -mpegts_service_type digital_radio pipe:1

put this into i.e. /home/hts/.hts/tvheadend/scripts/radio-sunshine.sh (or somewhere else the tvheadend-running-user can access), make it executable (chown 755 /home/hts/.hts/tvheadend/scripts/radio-sunshine.sh), put

pipe:///home/hts/.hts/tvheadend/scripts/radio-sunshine.sh

into tvheadend, and i hope it would work. If it does, you could replace the url in the script with "$1" and specify the url after the script in the pipe command, so you don't have to write a script for every channel...

But,

It creates two service. One is unusable, but the other is working with VLC.

I'm seeing that too (for weeks, didn't happen in the beginning when i started pipe://-ing 'bout half a year ago), guess that's a bug, let's see the mighty perex says about it :)

https://tvheadend.org/issues/2897

regards,

/hp

RE: How to add http stream to TVHeadend - Added by Gareth Bradley over 4 years ago

Hanspeter Müller wrote:

GS Hodg wrote:

Now I'd like to understand how to add some other internet streams to it.

For for http-based video, you have to do it "yourself" with the pipe://-handler. For plain http-links (like mp4/m3u8/hls-streaming), you can add them using avconv/ffmpeg, put something like this in a script

[...]

For sites like ustream, youtube, vaugnlive etc, it's more complicated, they don't want you to use anything but a browser, so you need a special tool to suck the streams into tvheadend, http://docs.livestreamer.io/ works for a lot of sites. Install this, then use a script like

[...]

then add this as an iptv-mux and use "pipe:///path/to/script.sh http://streamingurl" in tvheadend, map services as usual.

You may have to tinker with the encoding settings (pass-through like in the first example only works for something "clean" like h264/aac, that's why my livestreamer example reencodes everything), if viewing works, but recordings are blank/broken, you at least have to add new pts timestamps...

But be aware, sites like ustream etc are moving targets, sometimes it works for weeks and months without a hitch, then they start to change stuff and you have to beg the livestreamer guys to update the plugins...

Have fun, and post again if you have problems :)

/hp

Hi, I'd like to add url streams and this is really new to me, but I know I need to do this.

Firstly you mentioned you have to do it "yourself" with the pipe://-handler, What is this? a program or simply just an output with pipe://......
Secondly you mentioned you can add them using avconv/ffmpeg, put something like this in a script. I've got no idea of script writing or exeuting etc.

I've copied the script you wrote in notepad and then saved as a .vbs Do I need to execute this somehow and integrate the url.

this is completly new to me

RE: How to add http stream to TVHeadend - Added by Jonathan Thomson over 4 years ago

Pipe isn't really a "thing" it's a process, "to pipe" is to pass the output of one process to another, so for example, to get flash video into TVHeadend, you would use something like livestreamer (which is a linux command line program for streaming from http/flash video services) and "pipe" the output to avconv/ffmpeg (which are linux command line tools for processing video). livestreamer grabs the video in the format the broadcaster makes it available (i.e. flash, which isn't supported by TVHeadend) then passes it to avconv/ffmpeg which, with the correct parameters, formats it into something which TVHeadend can understand. With all this wrapped up inside a linux bash script, you can add the script as a channel and when TVHeadend "tunes" to the channel (which is actually a script) the whole process works and passes a video stream to TVHeadend which is then displayed on your client (i.e. Kodi).

So, some questions for you;

  • What video are you trying to pass to TVHeadend
  • What operating system are you running TVHeadend on
  • Why Notepad/.VBS, that suggests Windows but TVHeadend doesn't run on Windows?

RE: How to add http stream to TVHeadend - Added by Gareth Bradley over 4 years ago

Thanks Jonathan,

After much looking into the first part you stated I think I understood, Its similar to transcoding as tvheadend can't handle the https stream?

The second part:-

I'm trying to run live IPTV streams on a kodi box and using tvheadend as the backend/frontend. the o/s on the kodi is linux based (Libreelec). I was just adding the http stream into tvheadend but after 20secs the image freezes. This is obviously when I've looked into it.

If I'm understanding this correctly, I need to take the http stream and pass this through avconv/ffmpeg converter for tvheadend to play correctly?

This is the part I'm struggling with. DO I need to install ffmpeg on a PC and somehow direct the tvheadend (kodi) to this and play. Or can I install a addon in kodi (such as ffmepg) which will convert the video. Again I just direct tvheadend to look in kodi somewhere. This is the part I'm struggling with

RE: How to add http stream to TVHeadend - Added by Jonathan Thomson over 4 years ago

I've seen the same behaviour from IPTV streams, I think it's because TVHeadend doesn't support HLS (HTTP Live Streaming) URL's - either properly or at all, so the stream stops.

So the deal with using PIPE is that you do it all on the same box that's hosting TVHeadend, you need to write a bash script which passes the IPTV streams to ffmpeg (also running on your TVHeadend box) and then use the path to the script in your mux settings in TVHeadend. This all sounds very complex, especially if you are not totally familiar with linux.

    (1-12/12)