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 130 forks source link

MP4 video dynamic playlist RTMP stream #1980

Closed kirillbushev closed 3 years ago

kirillbushev commented 3 years ago

Using 2.0.0-rc1 from deb file (ubuntu focal)

Single file streams fine.

Playlist (in pls format) - no.

Full log:

liquidsoap --debug --verbose asd.liq 2021/09/24 21:54:39 >>> LOG START 2021/09/24 21:54:39 [main:3] Liquidsoap 2.0.0-rc1 2021/09/24 21:54:39 [main:3] Using: bytes=[distributed with OCaml 4.02 or above] posix-time2=2.0.0 pcre=7.4.6 sedlex=2.3 menhirLib=20210419 curl=0.9.1 dtools=0.4.4 duppy=0.9.2 cry=0.6.5 mm=0.7.2 xmlplaylist=0.1.5 lastfm=0.3.3 ogg=0.7.0 ogg.decoder=0.7.0 vorbis=0.8.0 vorbis.decoder=0.8.0 opus=0.2.0 opus.decoder=0.2.0 speex=0.4.0 speex.decoder=0.4.0 mad=0.5.1 flac=0.3.0 flac.ogg=0.3.0 flac.decoder=0.3.0 dynlink=[distributed with Ocaml] lame=0.3.4 shine=0.2.2 frei0r=0.1.2 fdkaac=0.3.2 theora=0.4.0 theora.decoder=0.4.0 ffmpeg-avutil=1.0.1 ffmpeg-avcodec=1.0.1 ffmpeg-avdevice=1.0.1 ffmpeg-av=1.0.1 ffmpeg-avfilter=1.0.1 ffmpeg-swresample=1.0.1 ffmpeg-swscale=1.0.1 bjack=0.1.6 alsa=0.3.0 ao=0.2.3 samplerate=0.1.6 taglib=0.3.7 ssl=0.5.9 magic=0.7.3 camomile=1.0.2 inotify=2.3 yojson=1.7.0 faad=0.5.0 soundtouch=0.1.9 portaudio=0.2.2 pulseaudio=0.1.4 ladspa=0.2.0 dssi=0.1.3 tsdl=v0.9.8 tsdl_ttf=0 tsdl_image=0 camlimages=4.2.6 cohttp-lwt-unix=2.5.5 prometheus-app=1.1 srt.constants=0.2.0 srt.types=0.2.0 srt.stubs=0.2.0 srt.stubs.locked=0.2.0 srt=0.2.0 lo=0.2.0 gd=1.0a5 2021/09/24 21:54:39 [clock:3] Using native (high-precision) implementation for latency control 2021/09/24 21:54:39 [lang:2] WARNING: "set" is deprecated and will be removed in future version. Please use settings.path.to.key.set(value) 2021/09/24 21:54:39 [playlist_0:4] Reloading playlist. 2021/09/24 21:54:39 [request:5] Resolving request [[./playlist.pls]]. 2021/09/24 21:54:39 [request:5] Resolved to [[./playlist.pls]]. 2021/09/24 21:54:39 [playlist parser:4] Trying youtube-dl parser 2021/09/24 21:54:39 [playlist parser:4] Trying application/x-cue parser 2021/09/24 21:54:39 [playlist parser:4] Trying audio/x-scpls parser 2021/09/24 21:54:39 [frame:4] frame.audio.channels set to: 2 2021/09/24 21:54:39 [frame:4] frame.video.default set to: false 2021/09/24 21:54:39 [frame:4] frame.midi.channels set to: 0 2021/09/24 21:54:39 [frame:4] frame.video.width set to: 1280 2021/09/24 21:54:39 [frame:4] frame.video.height set to: 720 2021/09/24 21:54:39 [frame:4] frame.audio.samplerate set to: 44100 2021/09/24 21:54:39 [frame:4] frame.video.framerate set to: 25 2021/09/24 21:54:39 [frame:4] frame.audio.samplerate set to: 44100 2021/09/24 21:54:39 [frame:3] Using 44100Hz audio, 25Hz video, 44100Hz main. 2021/09/24 21:54:39 [frame:3] Video frame size set to: 1280x720 2021/09/24 21:54:39 [frame:3] Frame size must be a multiple of 1764 ticks = 1764 audio samples = 1 video samples. 2021/09/24 21:54:39 [frame:3] Targeting 'frame.duration': 0.04s = 1764 audio samples = 1764 ticks. 2021/09/24 21:54:39 [frame:3] Frames last 0.04s = 1764 audio samples = 1 video samples = 1764 ticks. 2021/09/24 21:54:39 [sandbox:3] Sandboxing disabled 2021/09/24 21:54:39 [video.converter:3] Using preferred video converter: ffmpeg. 2021/09/24 21:54:39 [audio.converter:3] Using samplerate converter: ffmpeg. 2021/09/24 21:54:39 [lifecycle:5] At stage: "Liquidsoap application start" 2021/09/24 21:54:39 [clock:4] Currently 1 clocks allocated. 2021/09/24 21:54:39 [clock.main:4] Starting 1 sources... 2021/09/24 21:54:39 [source:4] Source output.file_0 gets up with content kind: {audio=ffmpeg.audio.copy,video=ffmpeg.video.copy,midi=none}. 2021/09/24 21:54:39 [output.url:5] Clock is main[]. 2021/09/24 21:54:39 [output.url:5] Content kind: {audio=ffmpeg.audio.copy,video=ffmpeg.video.copy,midi=none}, content type: {audio=ffmpeg.audio.copy,video=ffmpeg.video.copy,midi=none} 2021/09/24 21:54:39 [output.url:4] Content type is {audio=ffmpeg.audio.copy,video=ffmpeg.video.copy,midi=none}. 2021/09/24 21:54:39 [source:4] Source playlist_0 gets up with content kind: {audio=ffmpeg.audio.copy,video=ffmpeg.video.copy,midi=none}. 2021/09/24 21:54:39 [playlist_0:5] Clock is main[]. 2021/09/24 21:54:39 [playlist_0:5] Content kind: {audio=ffmpeg.audio.copy,video=ffmpeg.video.copy,midi=none}, content type: {audio=ffmpeg.audio.copy,video=ffmpeg.video.copy,midi=none} 2021/09/24 21:54:39 [playlist_0:4] Content type is {audio=ffmpeg.audio.copy,video=ffmpeg.video.copy,midi=none}. 2021/09/24 21:54:39 [playlist_0:5] Activations changed: static=[output.url:output.url], dynamic=[]. 2021/09/24 21:54:39 [output.url:5] Activations changed: static=[output.url], dynamic=[]. 2021/09/24 21:54:39 [output.url:5] Enabling caching mode: active source. 2021/09/24 21:54:39 [threads:4] Created thread "clock_main" (1 total). 2021/09/24 21:54:39 [clock:4] Main phase starts. 2021/09/24 21:54:39 [clock.main:3] Streaming loop starts in auto-sync mode 2021/09/24 21:54:39 [threads:4] Created thread "generic queue #1" (1 total). 2021/09/24 21:54:39 [clock.main:3] Delegating synchronisation to CPU clock 2021/09/24 21:54:39 [threads:4] Created thread "generic queue #2" (2 total). 2021/09/24 21:54:39 [playlist_0:5] Next song will be "/srv/www/video/news/2021/20210923/pogoda_hqG9HprAgWGupsF1Za.mp4". 2021/09/24 21:54:39 [threads:4] Created thread "non-blocking queue #1" (3 total). 2021/09/24 21:54:39 [request:5] Resolving request [[/srv/www/video/news/2021/20210923/pogoda_hqG9HprAgWGupsF1Za.mp4]]. 2021/09/24 21:54:39 [threads:4] Created thread "non-blocking queue #2" (4 total). 2021/09/24 21:54:39 [request:6] Resolve step /srv/www/video/news/2021/20210923/pogoda_hqG9HprAgWGupsF1Za.mp4 in [[/srv/www/video/news/2021/20210923/pogoda_hqG9HprAgWGupsF1Za.mp4]]. 2021/09/24 21:54:39 [decoder.ogg:4] Unsupported file extension for "/srv/www/video/news/2021/20210923/pogoda_hqG9HprAgWGupsF1Za.mp4"! 2021/09/24 21:54:39 [decoder.ogg:4] Unsupported MIME type for "/srv/www/video/news/2021/20210923/pogoda_hqG9HprAgWGupsF1Za.mp4": video/mp4! 2021/09/24 21:54:39 [decoder:4] Available decoders: FFMPEG (priority: 10) 2021/09/24 21:54:39 [decoder.ffmpeg:4] ffmpeg recognizes /srv/www/video/news/2021/20210923/pogoda_hqG9HprAgWGupsF1Za.mp4 as: audio: {codec: aac, 48000Hz, 2 channel(s)}, video: {codec: h264, 1024x576, yuv420p} and content-type: {audio=ffmpeg.audio.copy(sample_rate=48000,sample_format=fltp,channel_layout="stereo",codec="aac"),video=ffmpeg.video.copy(pixel_format=yuv420p,aspect_ratio=1/1,height=576,width=1024,codec="h264"),midi=none}. 2021/09/24 21:54:39 [decoder:4] Selected decoder FFMPEG for file "/srv/www/video/news/2021/20210923/pogoda_hqG9HprAgWGupsF1Za.mp4" with expected kind {audio=ffmpeg.audio.copy(sample_rate=48000,sample_format=fltp,channel_layout="stereo",codec="aac"),video=ffmpeg.video.copy(pixel_format=yuv420p,aspect_ratio=1/1,height=576,width=1024,codec="h264"),midi=none} and detected content {audio=ffmpeg.audio.copy(sample_rate=48000,sample_format=fltp,channel_layout="stereo",codec="aac"),video=ffmpeg.video.copy(pixel_format=yuv420p,aspect_ratio=1/1,height=576,width=1024,codec="h264"),midi=none} 2021/09/24 21:54:39 [metadata.flac:4] Unsupported file extension for "/srv/www/video/news/2021/20210923/pogoda_hqG9HprAgWGupsF1Za.mp4"! 2021/09/24 21:54:39 [playlist_0:5] Queue is empty! 2021/09/24 21:54:39 [playlist_0:5] Failed to prepare track: no file. 2021/09/24 21:54:39 [metadata.flac:4] Unsupported MIME type for "/srv/www/video/news/2021/20210923/pogoda_hqG9HprAgWGupsF1Za.mp4": video/mp4! 2021/09/24 21:54:39 [playlist_0:5] Queue is empty! 2021/09/24 21:54:39 [playlist_0:5] Failed to prepare track: no file. 2021/09/24 21:54:39 [output.url:3] Source failed (no more tracks) stopping output... 2021/09/24 21:54:39 [metadata.mp4:4] Unsupported MIME type for "/srv/www/video/news/2021/20210923/pogoda_hqG9HprAgWGupsF1Za.mp4": video/mp4! 2021/09/24 21:54:39 [decoder.ogg:4] Unsupported file extension for "/srv/www/video/news/2021/20210923/pogoda_hqG9HprAgWGupsF1Za.mp4"! 2021/09/24 21:54:39 [decoder.ogg:4] Unsupported MIME type for "/srv/www/video/news/2021/20210923/pogoda_hqG9HprAgWGupsF1Za.mp4": video/mp4! 2021/09/24 21:54:39 [decoder.taglib:4] Unsupported file extension for "/srv/www/video/news/2021/20210923/pogoda_hqG9HprAgWGupsF1Za.mp4"! 2021/09/24 21:54:39 [decoder.taglib:4] Unsupported MIME type for "/srv/www/video/news/2021/20210923/pogoda_hqG9HprAgWGupsF1Za.mp4": video/mp4!

@toots lets continue here

kirillbushev commented 3 years ago

ffprobe one of the file (i remind that if "single(..file) it streams ok, so the problem is with playlist only)

ffprobe /srv/www/video/news/2021/20210923/pogoda_hqG9HprAgWGupsF1Za.mp4 ffprobe version 4.2.4-1ubuntu0.1 Copyright (c) 2007-2020 the FFmpeg developers built with gcc 9 (Ubuntu 9.3.0-10ubuntu2) configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared libavutil 56. 31.100 / 56. 31.100 libavcodec 58. 54.100 / 58. 54.100 libavformat 58. 29.100 / 58. 29.100 libavdevice 58. 8.100 / 58. 8.100 libavfilter 7. 57.100 / 7. 57.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 5.100 / 5. 5.100 libswresample 3. 5.100 / 3. 5.100 libpostproc 55. 5.100 / 55. 5.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/srv/www/video/news/2021/20210923/pogoda_hqG9HprAgWGupsF1Za.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: mp42mp41 creation_time : 2021-09-23T04:23:12.000000Z Duration: 00:01:30.45, start: 0.000000, bitrate: 2166 kb/s Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt470bg), 1024x576 [SAR 1:1 DAR 16:9], 2005 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc (default) Metadata: creation_time : 2021-09-23T04:23:12.000000Z handler_name : ?Mainconcept Video Media Handler encoder : AVC Coding Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 157 kb/s (default) Metadata: creation_time : 2021-09-23T04:23:12.000000Z handler_name : #Mainconcept MP4 Sound Media Handler

toots commented 3 years ago

Is that the full log? Nothing happens after it?

kirillbushev commented 3 years ago

Yes. The queue is empty, so..

Strace: image

kirillbushev commented 3 years ago

This is how the log looks like than using single file instead of playlist. image everything is fine

kirillbushev commented 3 years ago

log.level.set(6) set("video.converter.preferred", "ffmpeg")

source = single("videos/1.mp4");

source = playlist("./playlist.pls",reload_mode="watch")

source = playlist("videos/",reload_mode="watch")

enc = %ffmpeg(format="flv",%audio.copy,%video.copy)

output.url(fallible=true,url="rtmp://10.10.0.198/live/segodnya",enc,source)

bofh@ntv-18:~/segodnya_stream$ more playlist.pls [playlist] Title1=Untitled2 File1=/srv/www/video/news/2021/20210923/8_lavrov_hqdC1EK6C13ND8Qmni.mp4 Title2=Untitled3 File2=/srv/www/video/news/2021/20210923/8_tonkih_hqNRXrLs9BuPU3QMXg.mp4

toots commented 3 years ago

This makes me suspect something with NFS. Have you tried with local files instead?

kirillbushev commented 3 years ago

Yes, already have tried with local files.

Also i tried to use just directory in playlist("/dir"); not playlist.pls

It doesn't matter it just don't work :(

toots commented 3 years ago

Ok, last thing. Have you tried with the latest v2.0.0: https://github.com/savonet/liquidsoap/actions/runs/1271263010

Next, I'll try to reproduce locally if you can provide me with the files..

kirillbushev commented 3 years ago

The problem was with audio.copy/video.copy If providing codecs it runs fine.