streamlink / streamlink

Streamlink is a CLI utility which pipes video streams from various services into a video player
https://streamlink.github.io/
BSD 2-Clause "Simplified" License
10.05k stars 1.11k forks source link

stream.hls: no video stream on some hls stream #5876

Closed toomyzoom closed 8 months ago

toomyzoom commented 8 months ago

Checklist

Streamlink version

6.6.2+12.g0a63b33c

Description

This is related to #5856

The fix included in that pull request only partially fixes the problem. On some video, streamlink was only able to get the audio stream but not video

This is the mpv debug when opening that stream from streamlink http server:

Mar 03 13:05:08 mpv2 mpv[9631]: [streamlink] http://127.0.0.1:44037/
Mar 03 13:05:08 mpv2 mpv[9631]: [streamlink] version: Lua 5.2
Mar 03 13:05:08 mpv2 mpv[9631]: [streamlink] duration: http://127.0.0.1:44037/
Mar 03 13:05:09 mpv2 mpv[9631]: [ffmpeg/video] h264: non-existing PPS 0 referenced
Mar 03 13:05:09 mpv2 mpv[9631]: [ffmpeg] extract_extradata: Invalid NAL unit 0, skipping.
Mar 03 13:05:09 mpv2 mpv[9631]: [ffmpeg/video] h264: Invalid NAL unit 0, skipping.
Mar 03 13:05:09 mpv2 mpv[9631]: [ffmpeg/video] h264: A non-intra slice in an IDR NAL unit.
Mar 03 13:05:09 mpv2 mpv[9631]: [ffmpeg/video] h264: decode_slice_header error
Mar 03 13:05:09 mpv2 mpv[9631]: [ffmpeg/video] h264: no frame!
Mar 03 13:05:09 mpv2 mpv[9631]: [ffmpeg/video] h264: non-existing PPS 4 referenced
Mar 03 13:05:09 mpv2 mpv[9631]: [ffmpeg] extract_extradata: Invalid NAL unit 0, skipping.
Mar 03 13:05:09 mpv2 mpv[9631]: [ffmpeg] extract_extradata: Invalid NAL unit 0, skipping.
Mar 03 13:05:09 mpv2 mpv[9631]: [ffmpeg/video] h264: Invalid NAL unit 0, skipping.
Mar 03 13:05:09 mpv2 mpv[9631]: [ffmpeg/video] h264: Invalid NAL unit 0, skipping.
Mar 03 13:05:09 mpv2 mpv[9631]: [ffmpeg/video] h264: no frame!
Mar 03 13:05:09 mpv2 mpv[9631]: [ffmpeg/demuxer] mpegts: Could not find codec parameters for stream 0 (Video: h264 ([27][0][0][0] / 0x001B), none): unspecified size
Mar 03 13:05:09 mpv2 mpv[9631]: [ffmpeg/demuxer] Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
Mar 03 13:05:09 mpv2 mpv[9631]: Not seekable, but enabling seeking on user request.
Mar 03 13:05:09 mpv2 mpv[9631]:  (+) Video --vid=1 (h264)
Mar 03 13:05:09 mpv2 mpv[9631]:  (+) Audio --aid=1 (aac 2ch 48000Hz)
Mar 03 13:05:09 mpv2 mpv[9631]: [ffmpeg/video] h264: Invalid NAL unit 0, skipping.
Mar 03 13:05:09 mpv2 mpv[9631]: [ffmpeg/video] h264: A non-intra slice in an IDR NAL unit.
Mar 03 13:05:09 mpv2 mpv[9631]: [ffmpeg/video] h264: decode_slice_header error
Mar 03 13:05:09 mpv2 mpv[9631]: [ffmpeg/video] h264: no frame!
Mar 03 13:05:09 mpv2 mpv[9631]: [ffmpeg/video] h264: Invalid NAL unit 0, skipping.
Mar 03 13:05:09 mpv2 mpv[9631]: [ffmpeg/video] h264: Invalid NAL unit 0, skipping.
Mar 03 13:05:09 mpv2 mpv[9631]: [ffmpeg/video] h264: no frame!
Mar 03 13:05:09 mpv2 mpv[9631]: AO: [alsa] 48000Hz stereo 2ch float
Mar 03 13:05:11 mpv2 mpv[9631]: [ffmpeg] http: Stream ends prematurely at 148178592, should be 18446744073709551615
Mar 03 13:05:11 mpv2 mpv[9631]: [ffmpeg/video] h264: Picture timing SEI payload too large
Mar 03 13:05:11 mpv2 mpv[9631]: [ffmpeg/video] h264: missing picture in access unit with size 138296441
Mar 03 13:05:11 mpv2 mpv[9631]: [ffmpeg/video] h264: Invalid NAL unit 0, skipping.
Mar 03 13:05:11 mpv2 mpv[9631]: [ffmpeg/video] h264: Invalid NAL unit 0, skipping.
Mar 03 13:05:11 mpv2 mpv[9631]: [ffmpeg/video] h264: Invalid NAL unit 0, skipping.
Mar 03 13:05:11 mpv2 mpv[9631]: [ffmpeg/video] h264: Invalid NAL unit 0, skipping.
Mar 03 13:05:11 mpv2 mpv[9631]: [ffmpeg/video] h264: Invalid NAL unit 0, skipping.
Mar 03 13:05:11 mpv2 mpv[9631]: [ffmpeg/video] h264: Invalid NAL unit 0, skipping.
Mar 03 13:05:11 mpv2 mpv[9631]: [ffmpeg/video] h264: Invalid NAL unit 0, skipping.
Mar 03 13:05:11 mpv2 mpv[9631]: [ffmpeg/video] h264: Invalid NAL unit 0, skipping.
Mar 03 13:05:11 mpv2 mpv[9631]: [ffmpeg/video] h264: Invalid NAL unit 0, skipping.
Mar 03 13:05:11 mpv2 mpv[9631]: [ffmpeg/video] h264: Invalid NAL unit 0, skipping.
Mar 03 13:05:11 mpv2 mpv[9631]: [ffmpeg/video] h264: no frame!
Mar 03 13:05:11 mpv2 mpv[9631]: Error while decoding frame!
Mar 03 13:05:11 mpv2 mpv[9631]: Error while decoding frame!
Mar 03 13:05:11 mpv2 mpv[9631]: Error while decoding frame!

Debug log

PYTHONWARNINGS="ignore:Unverified HTTPS request" streamlink --loglevel debug --http-no-ssl-verify  --http-cookie "domand_bid=128755907:33da7e6476356e50114d25c768f04098e83219f506bf88c58a2693a07df9872b" --player-external-http --player-external-http-continuous false --stream-segment-threads 10 --default-stream best "https://delivery.domand.nicovideo.jp/hlsbid/65bb415e1a6e6c306f97ef37/playlists/variants/0ea125d10b6c24e3.m3u8?session=1b4bc251ff32937e7f1b5603688092ef0ea125d10b6c24e30000000065e62a7ef25d514e44dec1b7&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9kZWxpdmVyeS5kb21hbmQubmljb3ZpZGVvLmpwL2hsc2JpZC82NWJiNDE1ZTFhNmU2YzMwNmY5N2VmMzcvcGxheWxpc3RzL3ZhcmlhbnRzLzBlYTEyNWQxMGI2YzI0ZTMubTN1OFxcPyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE3MDk1ODI5NzR9fX1dfQ__&Signature=rz1uOhlJb92xUEcfueNIYMnI5DVfLJQmW4SUu4Tcla-B0oMsg1tjSPnv6QfNGHClWdTN3Xq7A6XEM9QxXlIQp2TR0-IWacTa1iqECoo~lO2ogvA2QdTwJqSJZljoG4ivwGOJrQY7if5xI-mDQqxPKe4LFLoJZc2BAdL1rI5agkT1~V6EEAC82dBULI9wJzU1179M~5ine7ibe4Y28LsGVpqrWsDYxqYDnRObYRvUxMu8gtxM5PaXO~wCJiUeG~2CxT52xVLGyXmaGW5ht3DTp5R4iDkdPusFjqr9tDBzbH3MsIgZQ3L58tkNxepbrERD5hn1B8wkvKtYMXMRXKDvxA__&Key-Pair-Id=K11RB80NFXU134"

[session][debug] Loading plugin: hls
[cli][debug] OS:         Linux-6.7.6-zen1-2-zen-x86_64-with-glibc2.39
[cli][debug] Python:     3.11.7
[cli][debug] OpenSSL:    OpenSSL 3.2.1 30 Jan 2024
[cli][debug] Streamlink: 6.6.2+12.g0a63b33c
[cli][debug] Dependencies:
[cli][debug]  certifi: 2024.2.2
[cli][debug]  isodate: 0.6.1
[cli][debug]  lxml: 4.9.2
[cli][debug]  pycountry: 22.3.5
[cli][debug]  pycryptodome: 3.20.0
[cli][debug]  PySocks: 1.7.1
[cli][debug]  requests: 2.31.0
[cli][debug]  trio: 0.24.0
[cli][debug]  trio-websocket: 0.11.1
[cli][debug]  typing-extensions: 4.10.0
[cli][debug]  urllib3: 1.26.18
[cli][debug]  websocket-client: 1.7.0
[cli][debug] Arguments:
[cli][debug]  url=https://delivery.domand.nicovideo.jp/hlsbid/65bb415e1a6e6c306f97ef37/playlists/variants/0ea125d10b6c24e3.m3u8?session=1b4bc251ff32937e7f1b5603688092ef0ea125d10b6c24e30000000065e62a7ef25d514e44dec1b7&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9kZWxpdmVyeS5kb21hbmQubmljb3ZpZGVvLmpwL2hsc2JpZC82NWJiNDE1ZTFhNmU2YzMwNmY5N2VmMzcvcGxheWxpc3RzL3ZhcmlhbnRzLzBlYTEyNWQxMGI2YzI0ZTMubTN1OFxcPyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE3MDk1ODI5NzR9fX1dfQ__&Signature=rz1uOhlJb92xUEcfueNIYMnI5DVfLJQmW4SUu4Tcla-B0oMsg1tjSPnv6QfNGHClWdTN3Xq7A6XEM9QxXlIQp2TR0-IWacTa1iqECoo~lO2ogvA2QdTwJqSJZljoG4ivwGOJrQY7if5xI-mDQqxPKe4LFLoJZc2BAdL1rI5agkT1~V6EEAC82dBULI9wJzU1179M~5ine7ibe4Y28LsGVpqrWsDYxqYDnRObYRvUxMu8gtxM5PaXO~wCJiUeG~2CxT52xVLGyXmaGW5ht3DTp5R4iDkdPusFjqr9tDBzbH3MsIgZQ3L58tkNxepbrERD5hn1B8wkvKtYMXMRXKDvxA__&Key-Pair-Id=K11RB80NFXU134
[cli][debug]  --loglevel=debug
[cli][debug]  --player-external-http=True
[cli][debug]  --player-external-http-continuous=False
[cli][debug]  --default-stream=['best']
[cli][debug]  --stream-segment-threads=10
[cli][debug]  --http-cookie=[('domand_bid', '128755907:33da7e6476356e50114d25c768f04098e83219f506bf88c58a2693a07df9872b')]
[cli][debug]  --http-no-ssl-verify=False
[cli][info] Found matching plugin hls for URL https://delivery.domand.nicovideo.jp/hlsbid/65bb415e1a6e6c306f97ef37/playlists/variants/0ea125d10b6c24e3.m3u8?session=1b4bc251ff32937e7f1b5603688092ef0ea125d10b6c24e30000000065e62a7ef25d514e44dec1b7&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9kZWxpdmVyeS5kb21hbmQubmljb3ZpZGVvLmpwL2hsc2JpZC82NWJiNDE1ZTFhNmU2YzMwNmY5N2VmMzcvcGxheWxpc3RzL3ZhcmlhbnRzLzBlYTEyNWQxMGI2YzI0ZTMubTN1OFxcPyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE3MDk1ODI5NzR9fX1dfQ__&Signature=rz1uOhlJb92xUEcfueNIYMnI5DVfLJQmW4SUu4Tcla-B0oMsg1tjSPnv6QfNGHClWdTN3Xq7A6XEM9QxXlIQp2TR0-IWacTa1iqECoo~lO2ogvA2QdTwJqSJZljoG4ivwGOJrQY7if5xI-mDQqxPKe4LFLoJZc2BAdL1rI5agkT1~V6EEAC82dBULI9wJzU1179M~5ine7ibe4Y28LsGVpqrWsDYxqYDnRObYRvUxMu8gtxM5PaXO~wCJiUeG~2CxT52xVLGyXmaGW5ht3DTp5R4iDkdPusFjqr9tDBzbH3MsIgZQ3L58tkNxepbrERD5hn1B8wkvKtYMXMRXKDvxA__&Key-Pair-Id=K11RB80NFXU134
[plugins.hls][debug] URL=https://delivery.domand.nicovideo.jp/hlsbid/65bb415e1a6e6c306f97ef37/playlists/variants/0ea125d10b6c24e3.m3u8?session=1b4bc251ff32937e7f1b5603688092ef0ea125d10b6c24e30000000065e62a7ef25d514e44dec1b7&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9kZWxpdmVyeS5kb21hbmQubmljb3ZpZGVvLmpwL2hsc2JpZC82NWJiNDE1ZTFhNmU2YzMwNmY5N2VmMzcvcGxheWxpc3RzL3ZhcmlhbnRzLzBlYTEyNWQxMGI2YzI0ZTMubTN1OFxcPyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE3MDk1ODI5NzR9fX1dfQ__&Signature=rz1uOhlJb92xUEcfueNIYMnI5DVfLJQmW4SUu4Tcla-B0oMsg1tjSPnv6QfNGHClWdTN3Xq7A6XEM9QxXlIQp2TR0-IWacTa1iqECoo~lO2ogvA2QdTwJqSJZljoG4ivwGOJrQY7if5xI-mDQqxPKe4LFLoJZc2BAdL1rI5agkT1~V6EEAC82dBULI9wJzU1179M~5ine7ibe4Y28LsGVpqrWsDYxqYDnRObYRvUxMu8gtxM5PaXO~wCJiUeG~2CxT52xVLGyXmaGW5ht3DTp5R4iDkdPusFjqr9tDBzbH3MsIgZQ3L58tkNxepbrERD5hn1B8wkvKtYMXMRXKDvxA__&Key-Pair-Id=K11RB80NFXU134; params={}
[utils.l10n][debug] Language code: en_US
[stream.ffmpegmux][debug] ffmpeg version N-113911-gd25b3497f2 Copyright (c) 2000-2024 the FFmpeg developers
[stream.ffmpegmux][debug]  built with gcc 13.2.1 (GCC) 20230801
[stream.ffmpegmux][debug]  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --disable-htmlpages --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libjxl --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librav1e --enable-librsvg --enable-libsmbclient --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpl --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-nvdec --enable-nvenc --enable-opencl --enable-opengl --enable-shared --enable-version3 --enable-vulkan
[stream.ffmpegmux][debug]  libavutil      58. 40.100 / 58. 40.100
[stream.ffmpegmux][debug]  libavcodec     60. 41.100 / 60. 41.100
[stream.ffmpegmux][debug]  libavformat    60. 23.100 / 60. 23.100
[stream.ffmpegmux][debug]  libavdevice    60.  4.100 / 60.  4.100
[stream.ffmpegmux][debug]  libavfilter     9. 17.100 /  9. 17.100
[stream.ffmpegmux][debug]  libswscale      7.  6.100 /  7.  6.100
[stream.ffmpegmux][debug]  libswresample   4. 14.100 /  4. 14.100
[stream.ffmpegmux][debug]  libpostproc    57.  4.100 / 57.  4.100
[stream.hls][debug] Using external audio tracks for stream 1080p (language=None, name=Main Audio)
[stream.hls][debug] Using external audio tracks for stream 720p (language=None, name=Main Audio)
[stream.hls][debug] Using external audio tracks for stream 360p (language=None, name=Main Audio)
[stream.hls][debug] Using external audio tracks for stream 360p_alt (language=None, name=Main Audio)
[cli][info] Available streams: 360p_alt (worst), 360p, 720p, 1080p (best)
[cli][info] Starting server, access with one of:
[cli][info]  http://127.0.0.1:44037/
[cli][info]  http://172.17.0.1:44037/
[cli][info]  http://192.168.1.169:44037/
[cli][info]  http://192.168.7.1:44037/
[cli][info] Got HTTP request from libmpv
[cli][info] Opening stream: 1080p (hls-multi)
[stream.ffmpegmux][debug] Opening hls substream
[stream.hls][debug] Reloading playlist
[stream.ffmpegmux][debug] Opening hls substream
[stream.hls][debug] Reloading playlist
[utils.named_pipe][info] Creating pipe streamlinkpipe-9529-1-5962
[utils.named_pipe][info] Creating pipe streamlinkpipe-9529-2-4424
[stream.ffmpegmux][debug] ffmpeg command: /usr/bin/ffmpeg -nostats -y -i /tmp/streamlinkpipe-9529-1-5962 -i /tmp/streamlinkpipe-9529-2-4424 -c:v copy -c:a copy -map 0:v? -map 0:a? -map 1:a -f mpegts pipe:1
[stream.ffmpegmux][debug] Starting copy to pipe: /tmp/streamlinkpipe-9529-1-5962
[stream.ffmpegmux][debug] Starting copy to pipe: /tmp/streamlinkpipe-9529-2-4424
[cli][debug] Pre-buffering 8192 bytes
[stream.hls][debug] Segments in this playlist are encrypted
[stream.hls][debug] First Sequence: 1; Last Sequence: 31
[stream.hls][debug] Start offset: 0; Duration: None; Start Sequence: 1; End Sequence: 31
[stream.hls][debug] Adding segment 1 to queue
[stream.hls][debug] Adding segment 2 to queue
[stream.hls][debug] Adding segment 3 to queue
[stream.hls][debug] Adding segment 4 to queue
[stream.hls][debug] Adding segment 5 to queue
[stream.hls][debug] Adding segment 6 to queue
[stream.hls][debug] Adding segment 7 to queue
[stream.hls][debug] Adding segment 8 to queue
[stream.hls][debug] Adding segment 9 to queue
[stream.hls][debug] Adding segment 10 to queue
[stream.hls][debug] Adding segment 11 to queue
[stream.hls][debug] Adding segment 12 to queue
[stream.hls][debug] Adding segment 13 to queue
[stream.hls][debug] Adding segment 14 to queue
[stream.hls][debug] Adding segment 15 to queue
[stream.hls][debug] Adding segment 16 to queue
[stream.hls][debug] Adding segment 17 to queue
[stream.hls][debug] Adding segment 18 to queue
[stream.hls][debug] Adding segment 19 to queue
[stream.hls][debug] Adding segment 20 to queue
[stream.hls][debug] Adding segment 21 to queue
[stream.hls][debug] Writing segment 1 to output
[stream.hls][debug] Segment initialization 1 complete
[stream.hls][debug] Adding segment 22 to queue
[stream.hls][debug] Segments in this playlist are encrypted
[stream.hls][debug] First Sequence: 1; Last Sequence: 31
[stream.hls][debug] Start offset: 0; Duration: None; Start Sequence: 1; End Sequence: 31
[stream.hls][debug] Adding segment 1 to queue
[stream.hls][debug] Adding segment 2 to queue
[stream.hls][debug] Adding segment 3 to queue
[stream.hls][debug] Adding segment 4 to queue
[stream.hls][debug] Adding segment 5 to queue
[stream.hls][debug] Adding segment 6 to queue
[stream.hls][debug] Adding segment 7 to queue
[stream.hls][debug] Adding segment 8 to queue
[stream.hls][debug] Adding segment 9 to queue
[stream.hls][debug] Adding segment 10 to queue
[stream.hls][debug] Adding segment 11 to queue
[stream.hls][debug] Adding segment 12 to queue
[stream.hls][debug] Adding segment 13 to queue
[stream.hls][debug] Adding segment 14 to queue
[stream.hls][debug] Adding segment 15 to queue
[stream.hls][debug] Adding segment 16 to queue
[stream.hls][debug] Adding segment 17 to queue
[stream.hls][debug] Adding segment 18 to queue
[stream.hls][debug] Adding segment 19 to queue
[stream.hls][debug] Adding segment 20 to queue
[stream.hls][debug] Adding segment 21 to queue
[stream.hls][debug] Writing segment 1 to output
[stream.hls][debug] Segment initialization 1 complete
[stream.hls][debug] Adding segment 22 to queue
[stream.hls][debug] Writing segment 1 to output
[stream.hls][debug] Writing segment 1 to output
[stream.hls][debug] Segment 1 complete
[stream.hls][debug] Writing segment 2 to output
[stream.hls][debug] Adding segment 23 to queue
[stream.hls][debug] Segment 2 complete
[stream.hls][debug] Writing segment 3 to output
[stream.hls][debug] Adding segment 24 to queue
[stream.hls][debug] Segment 3 complete
[stream.hls][debug] Writing segment 4 to output
[stream.hls][debug] Adding segment 25 to queue
[stream.hls][debug] Segment 4 complete
[stream.hls][debug] Writing segment 5 to output
[stream.hls][debug] Segment 5 complete
[stream.hls][debug] Writing segment 6 to output
[stream.hls][debug] Adding segment 26 to queue
[stream.hls][debug] Adding segment 27 to queue
[stream.hls][debug] Segment 6 complete
[stream.hls][debug] Writing segment 7 to output
[stream.hls][debug] Adding segment 28 to queue
[stream.hls][debug] Segment 7 complete
[stream.hls][debug] Writing segment 8 to output
[stream.hls][debug] Adding segment 29 to queue
[stream.hls][debug] Segment 8 complete
[stream.hls][debug] Writing segment 9 to output
[stream.hls][debug] Adding segment 30 to queue
[stream.hls][debug] Segment 9 complete
[stream.hls][debug] Writing segment 10 to output
[stream.hls][debug] Adding segment 31 to queue
[stream.hls][debug] Segment 10 complete
[stream.hls][debug] Writing segment 11 to output
[stream.hls][debug] Segment 11 complete
[stream.hls][debug] Writing segment 12 to output
[stream.segmented][debug] Closing worker thread
[stream.hls][debug] Segment 12 complete
[stream.hls][debug] Writing segment 13 to output
[stream.hls][debug] Segment 13 complete
[stream.hls][debug] Writing segment 14 to output
[stream.hls][debug] Segment 14 complete
[stream.hls][debug] Writing segment 15 to output
[stream.hls][debug] Segment 15 complete
[stream.hls][debug] Writing segment 16 to output
[stream.hls][debug] Segment 16 complete
[stream.hls][debug] Writing segment 17 to output
[stream.hls][debug] Segment 17 complete
[stream.hls][debug] Writing segment 18 to output
[stream.hls][debug] Segment 18 complete
[stream.hls][debug] Writing segment 19 to output
[stream.hls][debug] Segment 19 complete
[stream.hls][debug] Writing segment 20 to output
[stream.hls][debug] Segment 20 complete
[stream.hls][debug] Writing segment 21 to output
[stream.hls][debug] Segment 21 complete
[stream.hls][debug] Writing segment 22 to output
[stream.hls][debug] Segment 22 complete
[stream.hls][debug] Writing segment 23 to output
[stream.hls][debug] Segment 23 complete
[stream.hls][debug] Writing segment 24 to output
[stream.hls][debug] Segment 24 complete
[stream.hls][debug] Writing segment 25 to output
[stream.hls][debug] Segment 25 complete
[stream.hls][debug] Writing segment 26 to output
[stream.hls][debug] Segment 26 complete
[stream.hls][debug] Writing segment 27 to output
[stream.hls][debug] Segment 27 complete
[stream.hls][debug] Writing segment 28 to output
[stream.hls][debug] Segment 28 complete
[stream.hls][debug] Writing segment 29 to output
[stream.hls][debug] Segment 29 complete
[stream.hls][debug] Writing segment 30 to output
[stream.hls][debug] Segment 30 complete
[stream.hls][debug] Writing segment 31 to output
[stream.hls][debug] Segment 31 complete
[stream.segmented][debug] Closing writer thread
[stream.hls][debug] Segment 1 complete
[stream.hls][debug] Writing segment 2 to output
[stream.hls][debug] Adding segment 23 to queue
[cli][debug] Writing stream to player
[stream.hls][debug] Segment 2 complete
[stream.hls][debug] Writing segment 3 to output
[stream.hls][debug] Adding segment 24 to queue
[stream.hls][debug] Segment 3 complete
[stream.hls][debug] Writing segment 4 to output
[stream.hls][debug] Adding segment 25 to queue
[stream.hls][debug] Segment 4 complete
[stream.hls][debug] Adding segment 26 to queue
[stream.hls][debug] Writing segment 5 to output
[stream.hls][debug] Segment 5 complete
[stream.hls][debug] Writing segment 6 to output
[stream.hls][debug] Adding segment 27 to queue
[stream.hls][debug] Segment 6 complete
[stream.hls][debug] Writing segment 7 to output
[stream.hls][debug] Adding segment 28 to queue
[stream.hls][debug] Segment 7 complete
[stream.hls][debug] Writing segment 8 to output
[stream.hls][debug] Adding segment 29 to queue
[stream.hls][debug] Segment 8 complete
[stream.hls][debug] Writing segment 9 to output
[stream.hls][debug] Adding segment 30 to queue
[stream.hls][debug] Segment 9 complete
[stream.hls][debug] Writing segment 10 to output
[stream.hls][debug] Adding segment 31 to queue
[stream.hls][debug] Segment 10 complete
[stream.hls][debug] Writing segment 11 to output
[stream.hls][debug] Segment 11 complete
[stream.hls][debug] Writing segment 12 to output
[stream.segmented][debug] Closing worker thread
[stream.hls][debug] Segment 12 complete
[stream.hls][debug] Writing segment 13 to output
[stream.hls][debug] Segment 13 complete
[stream.hls][debug] Writing segment 14 to output
[stream.hls][debug] Segment 14 complete
[stream.hls][debug] Writing segment 15 to output
[stream.hls][debug] Segment 15 complete
[stream.hls][debug] Writing segment 16 to output
[stream.hls][debug] Segment 16 complete
[stream.hls][debug] Writing segment 17 to output
[stream.hls][debug] Segment 17 complete
[stream.hls][debug] Writing segment 18 to output
[stream.hls][debug] Segment 18 complete
[stream.hls][debug] Writing segment 19 to output
[stream.hls][debug] Segment 19 complete
[stream.hls][debug] Writing segment 20 to output
[stream.hls][debug] Segment 20 complete
[stream.hls][debug] Writing segment 21 to output
[stream.hls][debug] Segment 21 complete
[stream.hls][debug] Writing segment 22 to output
[stream.hls][debug] Segment 22 complete
[stream.hls][debug] Writing segment 23 to output
[stream.hls][debug] Segment 23 complete
[stream.hls][debug] Writing segment 24 to output
[stream.hls][debug] Segment 24 complete
[stream.hls][debug] Writing segment 25 to output
[stream.hls][debug] Segment 25 complete
[stream.hls][debug] Writing segment 26 to output
[stream.hls][debug] Segment 26 complete
[stream.hls][debug] Writing segment 27 to output
[stream.hls][debug] Segment 27 complete
[stream.hls][debug] Writing segment 28 to output
[stream.hls][debug] Segment 28 complete
[stream.hls][debug] Writing segment 29 to output
[stream.hls][debug] Segment 29 complete
[stream.hls][debug] Writing segment 30 to output
[stream.hls][debug] Segment 30 complete
[stream.hls][debug] Writing segment 31 to output
[stream.hls][debug] Segment 31 complete
[stream.segmented][debug] Closing writer thread
[stream.ffmpegmux][debug] Pipe copy complete: /tmp/streamlinkpipe-9529-2-4424
[stream.ffmpegmux][debug] Pipe copy complete: /tmp/streamlinkpipe-9529-1-5962
[stream.ffmpegmux][debug] Closing ffmpeg thread
[stream.ffmpegmux][debug] Closed all the substreams
[cli][info] Stream ended
[cli][info] Closing currently open stream...
bastimeyer commented 8 months ago

This is not related to #5856, because #5856 is about something completely different.

Both video and audio streams get muxed and written to the output perfectly fine. This also works using --player-external-http.

streamlink \
  --stdout \
  --loglevel none \
  --http-no-ssl-verify \
  --http-cookie "domand_bid=128755907:33da7e6476356e50114d25c768f04098e83219f506bf88c58a2693a07df9872b" \
   "https://delivery.domand.nicovideo.jp/hlsbid/65bb415e1a6e6c306f97ef37/playlists/variants/0ea125d10b6c24e3.m3u8?session=1b4bc251ff32937e7f1b5603688092ef0ea125d10b6c24e30000000065e62a7ef25d514e44dec1b7&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9kZWxpdmVyeS5kb21hbmQubmljb3ZpZGVvLmpwL2hsc2JpZC82NWJiNDE1ZTFhNmU2YzMwNmY5N2VmMzcvcGxheWxpc3RzL3ZhcmlhbnRzLzBlYTEyNWQxMGI2YzI0ZTMubTN1OFxcPyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE3MDk1ODI5NzR9fX1dfQ__&Signature=rz1uOhlJb92xUEcfueNIYMnI5DVfLJQmW4SUu4Tcla-B0oMsg1tjSPnv6QfNGHClWdTN3Xq7A6XEM9QxXlIQp2TR0-IWacTa1iqECoo~lO2ogvA2QdTwJqSJZljoG4ivwGOJrQY7if5xI-mDQqxPKe4LFLoJZc2BAdL1rI5agkT1~V6EEAC82dBULI9wJzU1179M~5ine7ibe4Y28LsGVpqrWsDYxqYDnRObYRvUxMu8gtxM5PaXO~wCJiUeG~2CxT52xVLGyXmaGW5ht3DTp5R4iDkdPusFjqr9tDBzbH3MsIgZQ3L58tkNxepbrERD5hn1B8wkvKtYMXMRXKDvxA__&Key-Pair-Id=K11RB80NFXU134" \
  best \
  2>/dev/null \
  | ffprobe -v error -of json -show_streams - \
  | jq
{
  "streams": [
    {
      "index": 0,
      "codec_name": "h264",
      "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
      "profile": "High",
      "codec_type": "video",
      "codec_tag_string": "[27][0][0][0]",
      "codec_tag": "0x001b",
      "width": 1920,
      "height": 1080,
      "coded_width": 1920,
      "coded_height": 1080,
      "closed_captions": 0,
      "film_grain": 0,
      "has_b_frames": 2,
      "sample_aspect_ratio": "1:1",
      "display_aspect_ratio": "16:9",
      "pix_fmt": "yuv420p",
      "level": 42,
      "color_range": "tv",
      "color_space": "bt709",
      "color_transfer": "bt709",
      "color_primaries": "bt709",
      "chroma_location": "left",
      "field_order": "progressive",
      "refs": 1,
      "is_avc": "false",
      "nal_length_size": "0",
      "ts_packetsize": "188",
      "id": "0x100",
      "r_frame_rate": "60/1",
      "avg_frame_rate": "60/1",
      "time_base": "1/90000",
      "start_pts": 129840,
      "start_time": "1.442667",
      "bits_per_raw_sample": "8",
      "extradata_size": 43,
      "disposition": {
        "default": 0,
        "dub": 0,
        "original": 0,
        "comment": 0,
        "lyrics": 0,
        "karaoke": 0,
        "forced": 0,
        "hearing_impaired": 0,
        "visual_impaired": 0,
        "clean_effects": 0,
        "attached_pic": 0,
        "timed_thumbnails": 0,
        "non_diegetic": 0,
        "captions": 0,
        "descriptions": 0,
        "metadata": 0,
        "dependent": 0,
        "still_image": 0
      }
    },
    {
      "index": 1,
      "codec_name": "aac",
      "codec_long_name": "AAC (Advanced Audio Coding)",
      "profile": "LC",
      "codec_type": "audio",
      "codec_tag_string": "[15][0][0][0]",
      "codec_tag": "0x000f",
      "sample_fmt": "fltp",
      "sample_rate": "48000",
      "channels": 2,
      "channel_layout": "stereo",
      "bits_per_sample": 0,
      "initial_padding": 0,
      "ts_packetsize": "188",
      "id": "0x101",
      "r_frame_rate": "0/0",
      "avg_frame_rate": "0/0",
      "time_base": "1/90000",
      "start_pts": 126000,
      "start_time": "1.400000",
      "bit_rate": "147462",
      "disposition": {
        "default": 0,
        "dub": 0,
        "original": 0,
        "comment": 0,
        "lyrics": 0,
        "karaoke": 0,
        "forced": 0,
        "hearing_impaired": 0,
        "visual_impaired": 0,
        "clean_effects": 0,
        "attached_pic": 0,
        "timed_thumbnails": 0,
        "non_diegetic": 0,
        "captions": 0,
        "descriptions": 0,
        "metadata": 0,
        "dependent": 0,
        "still_image": 0
      },
      "tags": {
        "language": "und"
      }
    }
  ]
}
toomyzoom commented 8 months ago

This is not related to #5856, because #5856 is about something completely different.

Both video and audio streams get muxed and written to the output perfectly fine. This also works using --player-external-http.

streamlink \
  --stdout \
  --loglevel none \
  --http-no-ssl-verify \
  --http-cookie "domand_bid=128755907:33da7e6476356e50114d25c768f04098e83219f506bf88c58a2693a07df9872b" \
   "https://delivery.domand.nicovideo.jp/hlsbid/65bb415e1a6e6c306f97ef37/playlists/variants/0ea125d10b6c24e3.m3u8?session=1b4bc251ff32937e7f1b5603688092ef0ea125d10b6c24e30000000065e62a7ef25d514e44dec1b7&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9kZWxpdmVyeS5kb21hbmQubmljb3ZpZGVvLmpwL2hsc2JpZC82NWJiNDE1ZTFhNmU2YzMwNmY5N2VmMzcvcGxheWxpc3RzL3ZhcmlhbnRzLzBlYTEyNWQxMGI2YzI0ZTMubTN1OFxcPyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE3MDk1ODI5NzR9fX1dfQ__&Signature=rz1uOhlJb92xUEcfueNIYMnI5DVfLJQmW4SUu4Tcla-B0oMsg1tjSPnv6QfNGHClWdTN3Xq7A6XEM9QxXlIQp2TR0-IWacTa1iqECoo~lO2ogvA2QdTwJqSJZljoG4ivwGOJrQY7if5xI-mDQqxPKe4LFLoJZc2BAdL1rI5agkT1~V6EEAC82dBULI9wJzU1179M~5ine7ibe4Y28LsGVpqrWsDYxqYDnRObYRvUxMu8gtxM5PaXO~wCJiUeG~2CxT52xVLGyXmaGW5ht3DTp5R4iDkdPusFjqr9tDBzbH3MsIgZQ3L58tkNxepbrERD5hn1B8wkvKtYMXMRXKDvxA__&Key-Pair-Id=K11RB80NFXU134" \
  best \
  2>/dev/null \
  | ffprobe -v error -of json -show_streams - \
  | jq
{
  "streams": [
    {
      "index": 0,
      "codec_name": "h264",
      "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
      "profile": "High",
      "codec_type": "video",
      "codec_tag_string": "[27][0][0][0]",
      "codec_tag": "0x001b",
      "width": 1920,
      "height": 1080,
      "coded_width": 1920,
      "coded_height": 1080,
      "closed_captions": 0,
      "film_grain": 0,
      "has_b_frames": 2,
      "sample_aspect_ratio": "1:1",
      "display_aspect_ratio": "16:9",
      "pix_fmt": "yuv420p",
      "level": 42,
      "color_range": "tv",
      "color_space": "bt709",
      "color_transfer": "bt709",
      "color_primaries": "bt709",
      "chroma_location": "left",
      "field_order": "progressive",
      "refs": 1,
      "is_avc": "false",
      "nal_length_size": "0",
      "ts_packetsize": "188",
      "id": "0x100",
      "r_frame_rate": "60/1",
      "avg_frame_rate": "60/1",
      "time_base": "1/90000",
      "start_pts": 129840,
      "start_time": "1.442667",
      "bits_per_raw_sample": "8",
      "extradata_size": 43,
      "disposition": {
        "default": 0,
        "dub": 0,
        "original": 0,
        "comment": 0,
        "lyrics": 0,
        "karaoke": 0,
        "forced": 0,
        "hearing_impaired": 0,
        "visual_impaired": 0,
        "clean_effects": 0,
        "attached_pic": 0,
        "timed_thumbnails": 0,
        "non_diegetic": 0,
        "captions": 0,
        "descriptions": 0,
        "metadata": 0,
        "dependent": 0,
        "still_image": 0
      }
    },
    {
      "index": 1,
      "codec_name": "aac",
      "codec_long_name": "AAC (Advanced Audio Coding)",
      "profile": "LC",
      "codec_type": "audio",
      "codec_tag_string": "[15][0][0][0]",
      "codec_tag": "0x000f",
      "sample_fmt": "fltp",
      "sample_rate": "48000",
      "channels": 2,
      "channel_layout": "stereo",
      "bits_per_sample": 0,
      "initial_padding": 0,
      "ts_packetsize": "188",
      "id": "0x101",
      "r_frame_rate": "0/0",
      "avg_frame_rate": "0/0",
      "time_base": "1/90000",
      "start_pts": 126000,
      "start_time": "1.400000",
      "bit_rate": "147462",
      "disposition": {
        "default": 0,
        "dub": 0,
        "original": 0,
        "comment": 0,
        "lyrics": 0,
        "karaoke": 0,
        "forced": 0,
        "hearing_impaired": 0,
        "visual_impaired": 0,
        "clean_effects": 0,
        "attached_pic": 0,
        "timed_thumbnails": 0,
        "non_diegetic": 0,
        "captions": 0,
        "descriptions": 0,
        "metadata": 0,
        "dependent": 0,
        "still_image": 0
      },
      "tags": {
        "language": "und"
      }
    }
  ]
}

May I ask what ffmpeg version you're using? I run the same command you used but getting error on ffmpeg.

[h264 @ 0x5c00fc123e00] non-existing PPS 0 referenced
[h264 @ 0x5c00fc123e00] A non-intra slice in an IDR NAL unit.
[h264 @ 0x5c00fc123e00] decode_slice_header error
[h264 @ 0x5c00fc123e00] no frame!
[h264 @ 0x5c00fc123e00] non-existing PPS 4 referenced
[h264 @ 0x5c00fc123e00] no frame!
{
  "streams": [
    {
      "index": 0,
      "codec_name": "h264",
      "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
      "codec_type": "video",
      "codec_tag_string": "[27][0][0][0]",
      "codec_tag": "0x001b",
      "width": 0,
      "height": 0,
      "coded_width": 0,
      "coded_height": 0,
      "closed_captions": 0,
      "film_grain": 0,
      "has_b_frames": 1,
      "level": -99,
      "refs": 1,
      "is_avc": "false",
      "nal_length_size": "0",
      "ts_id": "1",
      "ts_packetsize": "188",
      "id": "0x100",
      "r_frame_rate": "90000/1",
      "avg_frame_rate": "0/0",
      "time_base": "1/90000",
      "start_pts": 129840,
      "start_time": "1.442667",
      "disposition": {
        "default": 0,
        "dub": 0,
        "original": 0,
        "comment": 0,
        "lyrics": 0,
        "karaoke": 0,
        "forced": 0,
        "hearing_impaired": 0,
        "visual_impaired": 0,
        "clean_effects": 0,
        "attached_pic": 0,
        "timed_thumbnails": 0,
        "non_diegetic": 0,
        "captions": 0,
        "descriptions": 0,
        "metadata": 0,
        "dependent": 0,
        "still_image": 0
      }
    },
    {
      "index": 1,
      "codec_name": "aac",
      "codec_long_name": "AAC (Advanced Audio Coding)",
      "profile": "LC",
      "codec_type": "audio",
      "codec_tag_string": "[15][0][0][0]",
      "codec_tag": "0x000f",
      "sample_fmt": "fltp",
      "sample_rate": "48000",
      "channels": 2,
      "channel_layout": "stereo",
      "bits_per_sample": 0,
      "initial_padding": 0,
      "ts_id": "1",
      "ts_packetsize": "188",
      "id": "0x101",
      "r_frame_rate": "0/0",
      "avg_frame_rate": "0/0",
      "time_base": "1/90000",
      "start_pts": 126000,
      "start_time": "1.400000",
      "bit_rate": "162649",
      "disposition": {
        "default": 0,
        "dub": 0,
        "original": 0,
        "comment": 0,
        "lyrics": 0,
        "karaoke": 0,
        "forced": 0,
        "hearing_impaired": 0,
        "visual_impaired": 0,
        "clean_effects": 0,
        "attached_pic": 0,
        "timed_thumbnails": 0,
        "non_diegetic": 0,
        "captions": 0,
        "descriptions": 0,
        "metadata": 0,
        "dependent": 0,
        "still_image": 0
      },
      "tags": {
        "language": "und"
      }
    }
  ]
}
bastimeyer commented 8 months ago

https://archlinux.org/packages/extra/x86_64/ffmpeg/

$ ffmpeg
ffmpeg version n6.1.1 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 13.2.1 (GCC) 20230801
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto --enable-fontconfig --enable-frei0r --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libharfbuzz --enable-libiec61883 --enable-libjack --enable-libjxl --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libplacebo --enable-libpulse --enable-librav1e --enable-librsvg --enable-librubberband --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpl --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-nvdec --enable-nvenc --enable-opencl --enable-opengl --enable-shared --enable-vapoursynth --enable-version3 --enable-vulkan
  libavutil      58. 29.100 / 58. 29.100
  libavcodec     60. 31.102 / 60. 31.102
  libavformat    60. 16.100 / 60. 16.100
  libavdevice    60.  3.100 / 60.  3.100
  libavfilter     9. 12.100 /  9. 12.100
  libswscale      7.  5.100 /  7.  5.100
  libswresample   4. 12.100 /  4. 12.100
  libpostproc    57.  3.100 / 57.  3.100
toomyzoom commented 8 months ago

https://archlinux.org/packages/extra/x86_64/ffmpeg/

$ ffmpeg
ffmpeg version n6.1.1 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 13.2.1 (GCC) 20230801
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto --enable-fontconfig --enable-frei0r --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libharfbuzz --enable-libiec61883 --enable-libjack --enable-libjxl --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libplacebo --enable-libpulse --enable-librav1e --enable-librsvg --enable-librubberband --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpl --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-nvdec --enable-nvenc --enable-opencl --enable-opengl --enable-shared --enable-vapoursynth --enable-version3 --enable-vulkan
  libavutil      58. 29.100 / 58. 29.100
  libavcodec     60. 31.102 / 60. 31.102
  libavformat    60. 16.100 / 60. 16.100
  libavdevice    60.  3.100 / 60.  3.100
  libavfilter     9. 12.100 /  9. 12.100
  libswscale      7.  5.100 /  7.  5.100
  libswresample   4. 12.100 /  4. 12.100
  libpostproc    57.  3.100 / 57.  3.100

Thanks. Seem like ffmpeg was broken somewhere after Jan 31st this year. I was able to to narrow down using snapshots between these 2 commits:

-> There was about 5 out of 8 commits between these 2 related to mpegts and mpegtsenc refactor and update.

Your ffmpeg output and version gave me the hint. I looked like an old version from last year.

bastimeyer commented 8 months ago

If there's an unresolved issue in FFmpeg's MPEG-TS muxer on their master branch, then please report the issue upstream, so it can get fixed in their next release. Thanks!

toomyzoom commented 8 months ago

If there's an unresolved issue in FFmpeg's MPEG-TS muxer on their master branch, then please report the issue upstream, so it can get fixed in their next release. Thanks!

I found the commit (8559cce3c37b08e37fd208b8895a87adb8832e77) causing problem and created a patch that can fix it for ffmpeg but I'm not sure how to report it. The hls master stream has unencrypted substreams in it which ffmpeg by itself was able to pick it up without issue. Correct me if I'm wrong here but seem like streamlink feed ffmpeg the master stream as mpegts and it assumes the stream was encrypted which call the buggy function mpegts_check_bitstream() in mpegtsenc.c. I'm not sure how can I generate the same stream for ffmpeg bug report without using streamlink and the expiring link.

bastimeyer commented 8 months ago

Decryption happens on the HLS protocol level and has nothing to do with the resulting bitstream (MPEG-TS or fragmented MPEG-4).

If you want to download (--output=...) the individual video and audio streams separately, then use their respective media playlist URLs as inputs instead of the multivatiant playlist URL. You can list them using the --loglevel=all CLI argument when parsing the multivariant playlist without having selected a particular stream. There's currently no better solution until the planned re-implementation of Streamlink's stream selection has landed.

All that Streamlink does when muxing the HLS substreams is this:

ffmpeg \
  -nostats \
  -y \
  -i namedpipe-of-stream-a \
  -i namedpipe-of-stream-b \
  -c:v copy \
  -c:a copy \
  -map '0:v?' \
  -map '0:a?' \
  -map '1:a' \
  -f mpegts \
  pipe:1

I would be very surprised though if this fundamental stuff broke on FFmpeg's master branch. I haven't built it myself from master yet, but I can have a look when I get the time. I won't be able to access your stream though because it's expired. If it's indeed broken, then this should be applicable to other streams as well and not just your stream example.

bastimeyer commented 8 months ago

I can't see any issues with FFmpeg built from its master branch.

I've tested 97beb63a66 (current HEAD) built from the ffmpeg-git AUR PKGBUILD on Arch and 49707b0590 (HEAD from yesterday) from BtbN/FFmpeg-Builds.

Both muxed HLS and DASH streams worked fine (MPEG-4 video+audio streams remuxed to MPEG-TS).

toomyzoom commented 8 months ago

I can't see any issues with FFmpeg built from its master branch.

I've tested 97beb63a66 (current HEAD) built from the ffmpeg-git AUR PKGBUILD on Arch and 49707b0590 (HEAD from yesterday) from BtbN/FFmpeg-Builds.

Both muxed HLS and DASH streams worked fine (MPEG-4 video+audio streams remuxed to MPEG-TS).

I'm not sure what in the stream from nicovideo that triggers this function when passed through streamlink to ffmpeg.

This is the current patch I have:

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 06e88e9879..b8efc535a7 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -2319,7 +2319,7 @@ static int mpegts_check_bitstream(AVFormatContext *s, AVStream *st,
                 pkt->size >= 5 && AV_RB32(pkt->data) != 0x0000001 &&
                 (AV_RB24(pkt->data) != 0x000001 ||
                     (st->codecpar->extradata_size > 0 &&
-                        (st->codecpar->extradata[0] & e->mask == e->value))))
+                        ((st->codecpar->extradata[0] & e->mask) == e->value))))
             return ff_stream_add_bitstream_filter(st, e->bsf_name, NULL);
     }
     return 1;

From 8559cce3, it was the change in this line:

-                              st->codecpar->extradata[0] == 1)))
+                             (st->codecpar->extradata[0] & e->mask == e->value))))

The commit overlooked the precedence between == and &. It was supposed to be & first before == but without parenthesis, the order evaluated was the other way around. It never looks up the correct entry in the codec id table in that same function which what causes the issue of not return video stream info.

I generated a new link. You can use the command you gave me with the same cookie to test it. I get no video info (width/height=0, etc without this patch)

https://delivery.domand.nicovideo.jp/hlsbid/65bb415e1a6e6c306f97ef37/playlists/variants/0ea125d10b6c24e3.m3u8?session=bee8811336df5b891a6030459316aef60ea125d10b6c24e30000000065ebe379d54a8e49ad54585a&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9kZWxpdmVyeS5kb21hbmQubmljb3ZpZGVvLmpwL2hsc2JpZC82NWJiNDE1ZTFhNmU2YzMwNmY5N2VmMzcvcGxheWxpc3RzL3ZhcmlhbnRzLzBlYTEyNWQxMGI2YzI0ZTMubTN1OFxcPyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE3MDk5NTgwMDl9fX1dfQ__&Signature=cKBnb5Cra4vRXKZSnD7pqfjuHsI0P6YnsLICXg3Kg~FK6eSNfb6SuFDR1U0vYCeOr0tuCCcT4zijzGcnPSrGG1UzeXEXKkmAfDIL~0WOLKRT8O-etPHeAFvNrGIKK68urQjL0X-ThC8nLeSu6Pnc0BIko2tK6ThHjFPw8rowtYQpPs~K4JSEN2BHqJI7pQobi2pGtYPXQTpaaf3TUgu2pOz7CQU-R2m3wwx6IodIKNtYpxRRHBPbPeYXPzbO52NKMtWqBsbwH1pUWNO7eLEcav9l7dfCWPwetmhLxdID3DAeNGmSkyDp75lRbeyuiejdXC7VmFFX5KxIPg-tvsixLg__&Key-Pair-Id=K11RB80NFXU134

bastimeyer commented 8 months ago

Here are the separate video and audio streams (limited to --hls-duration=5) 5876.zip

$ ffprobe -v error -of json -show_format 5876-v.mp4 | jq
{
  "format": {
    "filename": "5876-v.mp4",
    "nb_streams": 1,
    "nb_programs": 0,
    "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
    "format_long_name": "QuickTime / MOV",
    "start_time": "0.033333",
    "duration": "6.000000",
    "size": "3675840",
    "bit_rate": "4901120",
    "probe_score": 100,
    "tags": {
      "major_brand": "iso6",
      "minor_version": "512",
      "compatible_brands": "iso6cmfcmp41",
      "encoder": "Lavf58.76.100"
    }
  }
}

$ ffprobe -v error -of json -show_format 5876-a.mp4 | jq
{
  "format": {
    "filename": "5876-a.mp4",
    "nb_streams": 1,
    "nb_programs": 0,
    "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
    "format_long_name": "QuickTime / MOV",
    "start_time": "0.000000",
    "duration": "6.016000",
    "size": "116752",
    "bit_rate": "155255",
    "probe_score": 100,
    "tags": {
      "major_brand": "iso5",
      "minor_version": "512",
      "compatible_brands": "iso5cmfciso6mp41",
      "encoder": "Lavf58.76.100"
    }
  }
}

Muxing to MPEG-TS fails using FFmpeg built from master (49707b0590)

$ ./ffmpeg-master-latest-linux64-gpl/bin/ffmpeg \
        -i 5876-v.mp4 \
        -i 5876-a.mp4 \
        -c copy \
        -f mpegts \
        -y \
        5876-muxed-master.ts
...
[mpegts @ 0x6392afb61240] h264 bitstream error, startcode missing, size 100902 data 00018A22
[mpegts @ 0x6392afb61240] h264 bitstream error, startcode missing, size 539 data 00000217
[mpegts @ 0x6392afb61240] h264 bitstream error, startcode missing, size 165 data 000000A1
...

Muxing to MPEG-4 works fine.

That is all I can do to help. It's an FFmpeg issue and not a Streamlink issue, even if it affects Streamlink.

Streamlink's muxed output format can be set using --ffmpeg-fout, which defaults to mpegts.

bastimeyer commented 8 months ago

Decided to quickly check your patch and I can confirm that it fixes the issue. You should send it to their mailing list

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 06e88e9879..b8efc535a7 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -2319,7 +2319,7 @@ static int mpegts_check_bitstream(AVFormatContext *s, AVStream *st,
                 pkt->size >= 5 && AV_RB32(pkt->data) != 0x0000001 &&
                 (AV_RB24(pkt->data) != 0x000001 ||
                     (st->codecpar->extradata_size > 0 &&
-                        (st->codecpar->extradata[0] & e->mask == e->value))))
+                        ((st->codecpar->extradata[0] & e->mask) == e->value))))
             return ff_stream_add_bitstream_filter(st, e->bsf_name, NULL);
     }
     return 1;

No idea how such mistakes like using the wrong operator precedence can make it onto their master branch...

toomyzoom commented 8 months ago

Here are the separate video and audio streams (limited to --hls-duration=5) 5876.zip

$ ffprobe -v error -of json -show_format 5876-v.mp4 | jq
{
  "format": {
    "filename": "5876-v.mp4",
    "nb_streams": 1,
    "nb_programs": 0,
    "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
    "format_long_name": "QuickTime / MOV",
    "start_time": "0.033333",
    "duration": "6.000000",
    "size": "3675840",
    "bit_rate": "4901120",
    "probe_score": 100,
    "tags": {
      "major_brand": "iso6",
      "minor_version": "512",
      "compatible_brands": "iso6cmfcmp41",
      "encoder": "Lavf58.76.100"
    }
  }
}

$ ffprobe -v error -of json -show_format 5876-a.mp4 | jq
{
  "format": {
    "filename": "5876-a.mp4",
    "nb_streams": 1,
    "nb_programs": 0,
    "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
    "format_long_name": "QuickTime / MOV",
    "start_time": "0.000000",
    "duration": "6.016000",
    "size": "116752",
    "bit_rate": "155255",
    "probe_score": 100,
    "tags": {
      "major_brand": "iso5",
      "minor_version": "512",
      "compatible_brands": "iso5cmfciso6mp41",
      "encoder": "Lavf58.76.100"
    }
  }
}

Muxing to MPEG-TS fails using FFmpeg built from master (49707b0590)

$ ./ffmpeg-master-latest-linux64-gpl/bin/ffmpeg \
        -i 5876-v.mp4 \
        -i 5876-a.mp4 \
        -c copy \
        -f mpegts \
        -y \
        5876-muxed-master.ts
...
[mpegts @ 0x6392afb61240] h264 bitstream error, startcode missing, size 100902 data 00018A22
[mpegts @ 0x6392afb61240] h264 bitstream error, startcode missing, size 539 data 00000217
[mpegts @ 0x6392afb61240] h264 bitstream error, startcode missing, size 165 data 000000A1
...

Muxing to MPEG-4 works fine.

That is all I can do to help. It's an FFmpeg issue and not a Streamlink issue, even if it affects Streamlink.

Streamlink's muxed output format can be set using --ffmpeg-fout, which defaults to mpegts.

Your help is more than what can be asked for. I appreciated it. Thanks for your patience of working with me through this.

I will try to submit the patch to ffmpeg.

bastimeyer commented 7 months ago

I will try to submit the patch to ffmpeg.

@toomyzoom, did you submit it? I can't see anything on their devel mailing list or commit history

Pointing out the bug on their mailing list could also be enough

bastimeyer commented 7 months ago

I've opened a bug report on their tracker: https://trac.ffmpeg.org/ticket/10908

toomyzoom commented 7 months ago

I've opened a bug report on their tracker: https://trac.ffmpeg.org/ticket/10908

I was busy this week so didn't check the email. I was going to submit the patch but seem like someone already did that.

Thanks for opening the bug report.