braice / MuMuDVB

A DVB IPTV streaming software
http://mumudvb.braice.net/
GNU General Public License v2.0
216 stars 133 forks source link

HLS output support (file mode) #282

Closed anphsw closed 2 years ago

anphsw commented 2 years ago

This PR adds ability to write streams to HLS storage. Will create playlists and *.ts files, which can be serverd by any web-server. Tested with nginx, apache, VLC and some STBs. "hls=1" can be used with multicast=0 or unicast=0 as only writes files to disk (tmpfs preferred).

Saentist commented 2 years ago

Add options as: Chunk size (MB) or chunk time (second's). Playlist chunk count (number of chunks to keep in playlist/memory).

What about teletext pid problem?

anphsw commented 2 years ago

Just read Readme. Chunk time = hls_rotate_time (default = 10). Chunk count may be a problem here: what we should do, when not all chunks in the playlist ready? How we must form playlist right after start? Serve playlist with one chunk, then two, etc, or delay playlist generation for chunk_time * chunk count? I think this is VOD option, it's not for the live stream.

Can you please describe teletext problem you mention?

Saentist commented 2 years ago

HLS playlist M3U8 solve count by regenerate playlist when new chunk added so when started each playlist can contains from one to maximum chunks

HLS is not a realtime streaming it's a delayed one, there is all time delay from live stream.

From where come Teletext problem or teletext sub's if stream is 10 sec behind live and subs are delayed. Players refuse to show someting from past.

For this case lot of comersial software extract teletext sub's as WEBVTT https://github.com/kanongil/telxcc https://github.com/CCExtractor/ccextractor or similar software

Example in source of page ;) https://developer.apple.com/videos/play/wwdc2017/504/

anphsw commented 2 years ago

Yes, dynamic chunks count is possible, but I cannot see real advantages of for example, 20,10,5 chunks vs 2. It's not priority task for me, but you can add such support by another PR. Regarding subtitles - can we just rewrite time in subtitle pid to match actual stream? I don't find any channels with subtitles on my test box, will try to find them.

Saentist commented 2 years ago

Yes, dynamic chunks count is possible, but I cannot see real advantages of for example, 20,10,5 chunks vs 2. It's not priority task for me, but you can add such support by another PR. Regarding subtitles - can we just rewrite time in subtitle pid to match actual stream? I don't find any channels with subtitles on my test box, will try to find them.

Chunk number will affect memory usage and I/O access, and on not so pontential devices, where IRQ is ignored by default will have problems.

More chunks can make channel start from hour after live stream. with on other side is usefull for CATCHUP channels +1 +6 +12 etc With some players can be used as timeshift. feature ;)

On Astra 19.2E have channels with teletext subtitles.

anphsw commented 2 years ago

Ok, I see you want timeshift. It's not in this PR anyway, but possible.

Saentist commented 2 years ago

Ok, I see you want timeshift. It's not in this PR anyway, but possible.

No I dont want timeshift, but if have 100 channels with average bitrate of 8 Mb/s and have 4GB of memory, with must include TMPFS, how many chunks are possuble before "no space left" message?

In this case user will want to manage size and count of chunks.

This is my point, stable and unproblematic usage no matter hardware ;)

anphsw commented 2 years ago

So if you don't want timeshift, it's ok to have only two fully written chunks (as per default). 100 channels 3 chunks 8mbit / 8bits per byte = 300mb space per 1 second storage. My test box have 60 channels (2-10mbit) from 10 mumudvb processes, 5 sec rotate time, and total consumed space is about 270mb. So I don't see problem here.

anphsw commented 2 years ago

To be clear, you cannot manage size of chunks if channels streamed in VBR, only possible solution is split by time. Or else we must recalculate each chunk time based on its size and place to playlist. It's very hard with VBR.

Saentist commented 2 years ago

To be clear, you cannot manage size of chunks if channels streamed in VBR, only possible solution is split by time. Or else we must recalculate each chunk time based on its size and place to playlist. It's very hard with VBR.

there is already done code for "segmenter" size cut but beter one is IPB cuttig scenario. /cut before I frame RFC8216/ https://github.com/iliya-gr/mediasegmenter https://github.com/xtne6f/tsmemseg https://github.com/SteveCoul/MyBe

anphsw commented 2 years ago

I-frame cut is on the my roadmap, but it's not very useful, since I-frames from DVB is more frequent and chunk start without I-frame leads to only half second of damaged picture (same as in original unicast stream). I think I will never implement size limitation, since you can clearly calculate maximum storage size based on input TP parameters. but you can write your own PR.

Saentist commented 2 years ago

Do not concentrate on imposible "for moment" things. I cannot make PR, but can make suggestions/feature request as user and implementator.

As this one https://github.com/braice/MuMuDVB/issues/262

Now we wait for moment where this will be merged to MASTER

anphsw commented 2 years ago

Yes, I think now it's ready.

trollcop commented 2 years ago

@braice any particular thing blocking this PR? Seems a fair bit of effort was spent on making it, and if it's not merged there's going to be some bitrot and functionality seems to be fairly useful? (Not too familiar with HLS tho).

I'm not sure why it makes changes to ts.h, but the rest of the stuff seems fairly well isolated from the rest of the code. edit: never mind, ts.h changes are needed for hls.c

anphsw commented 2 years ago

Resolved merge conflicts; confirming 3+ month using DVB-S2/T2 input -> HLS output in production.

braice commented 2 years ago

More an overlook than anything else, I will look at it

On Mon, May 9, 2022, 14:24 dongie @.***> wrote:

@braice https://github.com/braice any particular thing blocking this PR? Seems a fair bit of effort was spent on making it, and if it's not merged there's going to be some bitrot and functionality seems to be fairly useful? (Not too familiar with HLS tho).

I'm not sure why it makes changes to ts.h, but the rest of the stuff seems fairly well isolated from the rest of the code.

— Reply to this email directly, view it on GitHub https://github.com/braice/MuMuDVB/pull/282#issuecomment-1121031391, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACRID7ITJWQD74LC36EH5LVJD7XTANCNFSM5MA2S6TA . You are receiving this because you were mentioned.Message ID: @.***>

braice commented 2 years ago

Let's go for it !

Saentist commented 2 years ago

@anphsw Is it posible to add simple example in examples folder?