savonet / liquidsoap

Liquidsoap is a statically typed scripting general-purpose language with dedicated operators and backend for all thing media, streaming, file generation, automation, HTTP backend and more.
http://liquidsoap.info
GNU General Public License v2.0
1.4k stars 128 forks source link

Native implementation of `input.hls` #927

Open smimram opened 5 years ago

smimram commented 5 years ago

When using input.hls, we can hear blank between segments. You can easily observe it with very short segments, e.g., the server

s = playlist("~/Music/misc")
s = mksafe(s)
output.harbor.hls(segment_duration=0.5, segments=100, [("music", %mp3)], s)

the client

set("decoder.file_extensions.ffmpeg",["mp3","mp4","m4a","wav","flac","ogg","osb"])
set("request.grace_time",10.)
s = input.hls(reload=1.5, "http://localhost:8000/stream.m3u8")
s = mksafe(s)
output.file(%wav, "/tmp/liq.wav", s)
out(s)

and watch the output: screenshot (regular blanks between segments are clearly visible).

smimram commented 5 years ago

and by the way, this script is also a good opportunity to produce segfaults in Liq:

#0  0x00007ffff337a7bb in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff3365535 in __GI_abort () at abort.c:79
#2  0x00007ffff33bc508 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7ffff34c728d "%s\n") at ../sysdeps/posix/libc_fatal.c:181
#3  0x00007ffff33c2c1a in malloc_printerr (str=str@entry=0x7ffff34c8ff8 "double free or corruption (out)") at malloc.c:5341
#4  0x00007ffff33c4730 in _int_free (av=0x7ffff34fec40 <main_arena>, p=0x7fffbc145030, have_lock=<optimized out>) at malloc.c:4306
#5  0x0000555555dd0356 in caml_empty_minor_heap () at minor_gc.c:388
#6  0x0000555555dd07ab in caml_gc_dispatch () at minor_gc.c:446
#7  0x0000555555dcd1eb in caml_garbage_collection () at signals_nat.c:78
#8  0x0000555555de7dc0 in caml_call_gc ()
#9  0x0000555555d4479c in camlStdlib__printf__ksprintf_177 () at printf.ml:37
#10 0x0000555555c277c8 in camlDuppy__f_560 () at duppy.ml:312
#11 0x0000555555c27611 in camlDuppy__queue_inner_2429 () at duppy.ml:356
#12 0x0000555555bcb162 in camlTutils__queue_757 () at tools/tutils.ml:204
#13 0x0000555555bcaab6 in camlTutils__fun_1460 () at tools/tutils.ml:133
#14 0x0000555555d0b3b9 in camlThread__fun_286 () at thread.ml:39
#15 0x0000555555de8004 in caml_start_program ()
#16 0x0000555555dc4238 in caml_thread_start ()
#17 0x00007ffff7a91fa3 in start_thread (arg=<optimized out>) at pthread_create.c:486
#18 0x00007ffff343c4cf in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
smimram commented 5 years ago

and another (seemingly) different:

#0  0x00007ffff33c79bd in __GI___libc_free (mem=0x10060) at malloc.c:3093
#1  0x0000555555dd6566 in caml_finalize_channel (vchan=<optimized out>) at io.c:432
#2  0x0000555555dd0356 in caml_empty_minor_heap () at minor_gc.c:388
#3  0x0000555555dd07ab in caml_gc_dispatch () at minor_gc.c:446
#4  0x0000555555dcd1eb in caml_garbage_collection () at signals_nat.c:78
#5  0x0000555555de7dc0 in caml_call_gc ()
#6  0x0000555555c318b2 in camlDtools__rotate_queue_1287 () at dtools.ml:807
#7  0x0000555555c31900 in camlDtools__flush_queue_1292 () at dtools.ml:819
#8  0x0000555555c31980 in camlDtools__f_1298 () at dtools.ml:823
#9  0x0000555555d0b3b9 in camlThread__fun_286 () at thread.ml:39
#10 0x0000555555de8004 in caml_start_program ()
#11 0x0000555555dc4238 in caml_thread_start ()
#12 0x00007ffff7a91fa3 in start_thread (arg=<optimized out>) at pthread_create.c:486
#13 0x00007ffff343c4cf in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
toots commented 5 years ago

What's the decoder?

smimram commented 5 years ago

FFMPEG

toots commented 5 years ago

Latest release I suppose?

smimram commented 5 years ago

yes

toots commented 5 years ago

Well at least the segault have been fixed now 😅

toots commented 5 years ago

Let's move this one to 1.5, rename to Implement input.hls and remove existing input.hls. Sounds good @smimram ?

smimram commented 5 years ago

Ok for me.

smimram commented 5 years ago

Maybe keep the current implementation as hidden though?

toots commented 5 years ago

Thanks for the changes. Moving this one to 1.5.0.