经LibVLC与 ASP.NET授权的HLS流

后端开发 2026-07-08

我正在开发一个应用,使用来自ASP.NET服务器的HLS流传输给Avalonia桌面客户端。我的目标是仅向经过身份验证的用户提供HLS流,我的解决方案是生成一个 会话ID,Avalonia客户端可以将其附加到主播放列表的请求中,随后它会被存储为一个Cookie。

然后LibVLC将该Cookie通过在 [VLC命令行参数] 中找到的 --http-forward-cookies 转发到后续请求。

问题

在调试API代码后,主要问题是前端的LibVLC似乎根本没有转发该Cookie。它确实接收到了该Cookie,如LibVLC日志所示,但从未进行转发。

调试日志图片

有没有办法强制转发该Cookie,还是我应该从整体上考虑为授权的HLS流寻找其他方向?

StreamController 代码:

public class StreamController
{
    IStreamingService m_StreamingService;

    [Authorize]
    [HttpGet("{track_id}/session")]
    public IActionResult GetSession(Guid track_id)
    {
        var user_id_s = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;

        if (!Guid.TryParse(user_id_s, out var user_id))
            return Unauthorized();

        var session_id = m_StreamingService.CreateSession(track_id, user_id);
        return Ok(new { session_id });
    }

    [HttpGet("{track_id}/master.m3u8")]
    public IActionResult GetMaster(Guid track_id, [FromQuery] Guid session)
    {
        if (!m_StreamingService.ValidateSession(session, track_id))
            return Unauthorized();

        var masterPath = Path.Combine(m_HlsPath, track_id.ToString(), "master.m3u8");

        if (!VerifyPathSafety(masterPath))
            return BadRequest();

        if (!System.IO.File.Exists(masterPath))
            return NotFound();

        // Set session cookie VLC forwards this on every subsequent segment request
        Response.Cookies.Append("stream_session", session.ToString(), new CookieOptions
        {
            HttpOnly = true,
        });

        return PhysicalFile(masterPath, "application/vnd.apple.mpegurl", enableRangeProcessing: true);
    }

    [HttpGet("{track_id}/{init_audio}.mp4")]
    public IActionResult GetInitAudio([FromRoute] Guid track_id, [FromRoute] string init_audio) 
    {
        if (!TryGetSessionFromCookie(out var sessionId))
            return Unauthorized();

        if (!m_StreamingService.ValidateSession(sessionId, track_id))
            return Unauthorized();

        // Validate and return init audio file
    }

    [HttpGet("{track_id}/{playlist}.m3u8")]
    public IActionResult GetAudio([FromRoute] Guid track_id, [FromRoute] string playlist)
    {
        if (!TryGetSessionFromCookie(out var sessionId))
            return Unauthorized();

        if (!m_StreamingService.ValidateSession(sessionId, track_id))
            return Unauthorized();

        // Validate and return playlist file
    }

    // === Same as above for segments ===

    private bool TryGetSessionFromCookie(out Guid sessionId)
    {
        sessionId = Guid.Empty;

        if (!Request.Cookies.TryGetValue("stream_session", out var value))
            return false;

        return Guid.TryParse(value, out sessionId);
    }
}

前端 LIBVlc:

class VLCMediaPlayer
{
    public VLCMediaPlayer()
    {
        LibVLCSharp.Shared.Core.Initialize();

        m_LibVLC = new LibVLC(
            "--network-caching=1000",
            "--http-forward-cookies",
            "--file-caching=300",
            "--no-video",
            "--verbose=3"
        );
        m_MediaPlayer = new MediaPlayer(m_LibVLC);
    }

    public async Task LoadAsync(Guid track)
    {
        // Get the session id from {track_id}/session endpoint
        var session = await m_StreamService.CreateSession(track);
        var new_media = new Media(m_LibVLC, $"https://my-server/hls/{track}/master.m3u8?session={session}", FromType.FromLocation);

        new_media.AddOption(":network-caching=1000");
        new_media.AddOption(":live-caching=1000");
        new_media.AddOption(":http-reconnect");
        new_media.AddOption(":http-forward-cookies");

        // Set the new media
        m_MediaPlayer.Media = new_media;
    }

    public void Play() { ... }
}

完整的LibVLC日志:

2026-06-20 15:58:12.8619|DEBUG|VLC: creating audio output
2026-06-20 15:58:12.8619|DEBUG|VLC: revision 3.0.23-2-0-g79128878dd
2026-06-20 15:58:12.8619|DEBUG|VLC: VLC media player - 3.0.23 Vetinari
2026-06-20 15:58:12.8619|DEBUG|VLC: looking for audio output module matching "any": 6 candidates
2026-06-20 15:58:12.8619|DEBUG|VLC: Copyright © 1996-2025 the VideoLAN team
2026-06-20 15:58:12.8619|DEBUG|VLC: configured with /builds/videolan/vlc/extras/package/win32/../../../configure  '--enable-update-check' '--enable-lua' '--enable-faad' '--enable-flac' '--enable-theora' '--enable-avcodec' '--enable-merge-ffmpeg' '--enable-mpc' '--enable-libass' '--enable-schroedinger' '--enable-realrtsp' '--enable-live555' '--enable-shout' '--enable-goom' '--enable-sse' '--enable-mmx' '--enable-libcddb' '--enable-zvbi' '--disable-telx' '--enable-nls' '--host=x86_64-w64-mingw32' '--with-contrib=../contrib/x86_64-w64-mingw32' '--with-breakpad=https://win.crashes.videolan.org' '--enable-qt' '--enable-skins2' '--enable-dvdread' '--enable-caca' 'host_alias=x86_64-w64-mingw32' 'CFLAGS= -D__MSVCRT_VERSION__=0x700 -D_WIN32_WINNT=0x0502 -DWINVER=0x0502 ' 'CPPFLAGS= -D__MSVCRT_VERSION__=0x700 -D_WIN32_WINNT=0x0502 -DWINVER=0x0502' 'CXXFLAGS= -D__MSVCRT_VERSION__=0x700 -D_WIN32_WINNT=0x0502 -DWINVER=0x0502 ' 'PKG_CONFIG=pkg-config' 'PKG_CONFIG_LIBDIR=/usr/x86_64-w64-mingw32/lib/pkgconfig:/usr/lib/x86_64-w64-mingw32/pkgconfig'
2026-06-20 15:58:12.9075|DEBUG|VLC: using default device
2026-06-20 15:58:12.9075|DEBUG|VLC: version 2 session control unavailable
2026-06-20 15:58:12.9075|DEBUG|VLC: volume from -64.000000 dB to +0.000000 dB with 1.000000 dB increments
2026-06-20 15:58:12.9075|DEBUG|VLC: using audio output module "mmdevice"
2026-06-20 15:58:12.9075|DEBUG|VLC: keeping audio output
2026-06-20 15:58:16.2350|DEBUG|VLC: removing module "mmdevice"
2026-06-20 15:58:16.2675|DEBUG|VLC: Creating an input for 'master.m3u8?session=8dd048ec-1906-44f3-b615-9c0c820c27ef'
2026-06-20 15:58:16.2675|DEBUG|VLC: using timeshift granularity of 50 MiB
2026-06-20 15:58:16.2675|DEBUG|VLC: using timeshift path: ....\AppData\Local\Temp
2026-06-20 15:58:16.2675|DEBUG|VLC: creating demux: access='https' demux='any' location='localhost:7002/api/stream/8152a53c-750d-4473-85da-f2f99999537e/master.m3u8?session=8dd048ec-1906-44f3-b615-9c0c820c27ef' file='\\localhost:7002\api\stream\8152a53c-750d-4473-85da-f2f99999537e\master.m3u8'
2026-06-20 15:58:16.2675|DEBUG|VLC: looking for access_demux module matching "https": 11 candidates
2026-06-20 15:58:16.2675|DEBUG|VLC: no access_demux modules matched
2026-06-20 15:58:16.2675|DEBUG|VLC:  (path: \\localhost:7002\api\stream\8152a53c-750d-4473-85da-f2f99999537e\master.m3u8)
2026-06-20 15:58:16.2675|DEBUG|VLC: looking for access module matching "https": 25 candidates
2026-06-20 15:58:16.2675|DEBUG|VLC: looking for tls client module matching "any": 1 candidates
2026-06-20 15:58:16.2675|DEBUG|VLC: using GnuTLS version 3.8.10
2026-06-20 15:58:16.2675|DEBUG|VLC: `https://localhost:7002/api/stream/8152a53c-750d-4473-85da-f2f99999537e/master.m3u8?session=8dd048ec-1906-44f3-b615-9c0c820c27ef' gives access `https' demux `any' path `localhost:7002/api/stream/8152a53c-750d-4473-85da-f2f99999537e/master.m3u8?session=8dd048ec-1906-44f3-b615-9c0c820c27ef'
2026-06-20 15:58:16.2675|DEBUG|VLC: creating access: https://localhost:7002/api/stream/8152a53c-750d-4473-85da-f2f99999537e/master.m3u8?session=8dd048ec-1906-44f3-b615-9c0c820c27ef
2026-06-20 15:58:16.2675|DEBUG|VLC: using tls client module "gnutls"
2026-06-20 15:58:16.2675|DEBUG|VLC: loaded 71 trusted CAs from system
2026-06-20 15:58:16.2675|DEBUG|VLC: resolving localhost ...
2026-06-20 15:58:16.2675|DEBUG|VLC: TLS handshake: Resource temporarily unavailable, try again.
2026-06-20 15:58:16.2675|DEBUG|VLC:  - safe renegotiation (RFC5746) enabled
2026-06-20 15:58:16.2675|DEBUG|VLC:  - extended master secret (RFC7627) enabled
2026-06-20 15:58:16.2675|DEBUG|VLC:  - false start (RFC7918) enabled
2026-06-20 15:58:16.2675|DEBUG|VLC: TLS handshake: Success.
2026-06-20 15:58:16.2675|DEBUG|VLC: out SETTINGS (0x04) frame of 30 bytes, flags 0x00, global
2026-06-20 15:58:16.2675|DEBUG|VLC: out HEADERS (0x01) frame of 265 bytes, flags 0x05, stream 1
2026-06-20 15:58:16.2899|DEBUG|VLC: setting: Concurrent streams (0x0003): 100
2026-06-20 15:58:16.2899|DEBUG|VLC: setting: Initial window size (0x0004): 786432
2026-06-20 15:58:16.2899|DEBUG|VLC: setting: Header list size (0x0006): 32768
2026-06-20 15:58:16.2899|DEBUG|VLC: setting: Unknown setting (0x0008): 1
2026-06-20 15:58:16.2899|DEBUG|VLC: in SETTINGS (0x04) frame of 24 bytes, flags 0x00, global
2026-06-20 15:58:16.2899|DEBUG|VLC: out SETTINGS (0x04) frame of 0 bytes, flags 0x01, global
2026-06-20 15:58:16.2899|DEBUG|VLC: in WINDOW_UPDATE (0x08) frame of 4 bytes, flags 0x00, global
2026-06-20 15:58:16.2899|DEBUG|VLC: in SETTINGS (0x04) frame of 0 bytes, flags 0x01, global
2026-06-20 15:58:16.3012|DEBUG|VLC:  :status: "206"
2026-06-20 15:58:16.3012|DEBUG|VLC:  server: "Kestrel"
2026-06-20 15:58:16.3012|DEBUG|VLC:  accept-ranges: "bytes"
2026-06-20 15:58:16.3012|DEBUG|VLC: stream 1 9 headers:
2026-06-20 15:58:16.3012|DEBUG|VLC: in HEADERS (0x01) frame of 219 bytes, flags 0x04, stream 1
2026-06-20 15:58:16.3012|DEBUG|VLC:  date: "Sat, 20 Jun 2026 12:58:15 GMT"
2026-06-20 15:58:16.3012|DEBUG|VLC:  content-type: "application/vnd.apple.mpegurl"
2026-06-20 15:58:16.3012|DEBUG|VLC:  content-range: "bytes 0-594/595"
2026-06-20 15:58:16.3012|DEBUG|VLC:  last-modified: "Tue, 16 Jun 2026 11:35:43 GMT"
2026-06-20 15:58:16.3012|DEBUG|VLC:  set-cookie: "stream_session=8dd048ec-1906-44f3-b615-9c0c820c27ef; path=/; samesite=lax; httponly"
2026-06-20 15:58:16.3012|DEBUG|VLC:  content-length: "595"
2026-06-20 15:58:16.3012|DEBUG|VLC: in DATA (0x00) frame of 595 bytes, flags 0x00, stream 1
2026-06-20 15:58:16.3012|DEBUG|VLC: out (priority) WINDOW_UPDATE (0x08) frame of 4 bytes, flags 0x00, global
2026-06-20 15:58:16.3012|DEBUG|VLC: in DATA (0x00) frame of 0 bytes, flags 0x01, stream 1
2026-06-20 15:58:16.3012|DEBUG|VLC: using access module "access"
2026-06-20 15:58:16.3012|DEBUG|VLC: stream 1 closed by peer
2026-06-20 15:58:16.3012|DEBUG|VLC: looking for stream_filter module matching "prefetch,cache_block": 24 candidates
2026-06-20 15:58:16.3012|DEBUG|VLC: using 595 bytes buffer, 595 bytes read
2026-06-20 15:58:16.3012|DEBUG|VLC: using stream_filter module "prefetch"
2026-06-20 15:58:16.3012|DEBUG|VLC: looking for stream_filter module matching "any": 24 candidates
2026-06-20 15:58:16.3012|DEBUG|VLC: end of stream
2026-06-20 15:58:16.3012|DEBUG|VLC: Trying Lua scripts in ...\AppData\Roaming\vlc\lua\playlist
2026-06-20 15:58:16.3012|DEBUG|VLC: Trying Lua scripts in ...\win-x64\lua\playlist
2026-06-20 15:58:16.3012|DEBUG|VLC: Trying Lua playlist script ...\win-x64\lua\playlist\anevia_streams.luac
2026-06-20 15:58:16.3012|DEBUG|VLC: Trying Lua playlist script ...\win-x64\lua\playlist\anevia_xml.luac
2026-06-20 15:58:16.3012|DEBUG|VLC: Trying Lua playlist script ...\win-x64\lua\playlist\appletrailers.luac
2026-06-20 15:58:16.3012|DEBUG|VLC: Trying Lua playlist script ...\win-x64\lua\playlist\bbc_co_uk.luac
2026-06-20 15:58:16.3012|DEBUG|VLC: Trying Lua playlist script ...\win-x64\lua\playlist\cue.luac
2026-06-20 15:58:16.3012|DEBUG|VLC: Trying Lua playlist script ...\win-x64\lua\playlist\dailymotion.luac
2026-06-20 15:58:16.3012|DEBUG|VLC: Trying Lua playlist script ...\win-x64\lua\playlist\jamendo.luac
2026-06-20 15:58:16.3012|DEBUG|VLC: Trying Lua playlist script ...\win-x64\lua\playlist\koreus.luac
2026-06-20 15:58:16.3012|DEBUG|VLC: Trying Lua playlist script ...\win-x64\lua\playlist\liveleak.luac
2026-06-20 15:58:16.3012|DEBUG|VLC: Trying Lua playlist script ...\win-x64\lua\playlist\newgrounds.luac
2026-06-20 15:58:16.3012|DEBUG|VLC: Trying Lua playlist script ...\win-x64\lua\playlist\rockbox_fm_presets.luac
2026-06-20 15:58:16.3012|DEBUG|VLC: Trying Lua playlist script ...\win-x64\lua\playlist\soundcloud.luac
2026-06-20 15:58:16.3012|DEBUG|VLC: Trying Lua playlist script ...\win-x64\lua\playlist\twitch.luac
2026-06-20 15:58:16.3012|DEBUG|VLC: Trying Lua playlist script ...\win-x64\lua\playlist\vimeo.luac
2026-06-20 15:58:16.3012|DEBUG|VLC: Trying Lua playlist script ...\win-x64\lua\playlist\vocaroo.luac
2026-06-20 15:58:16.3012|DEBUG|VLC: Trying Lua playlist script ...\win-x64\lua\playlist\youtube.luac
2026-06-20 15:58:16.3012|DEBUG|VLC: no stream_filter modules matched
2026-06-20 15:58:16.3012|DEBUG|VLC: looking for stream_directory module matching "any": 1 candidates
2026-06-20 15:58:16.3012|DEBUG|VLC: no stream_directory modules matched
2026-06-20 15:58:16.3012|DEBUG|VLC: attachment of directory-extractor failed for https://localhost:7002/api/stream/8152a53c-750d-4473-85da-f2f99999537e/master.m3u8?session=8dd048ec-1906-44f3-b615-9c0c820c27ef
2026-06-20 15:58:16.3012|DEBUG|VLC: looking for stream_filter module matching "record": 24 candidates
2026-06-20 15:58:16.3012|DEBUG|VLC: using stream_filter module "record"
2026-06-20 15:58:16.3012|DEBUG|VLC: creating demux: access='https' demux='any' location='localhost:7002/api/stream/8152a53c-750d-4473-85da-f2f99999537e/master.m3u8?session=8dd048ec-1906-44f3-b615-9c0c820c27ef' file='\\localhost:7002\api\stream\8152a53c-750d-4473-85da-f2f99999537e\master.m3u8'
2026-06-20 15:58:16.3012|DEBUG|VLC: looking for demux module matching "any": 50 candidates
2026-06-20 15:58:16.3012|DEBUG|VLC:  BaseAdaptationSet default_id#0
2026-06-20 15:58:16.3012|DEBUG|VLC:     (not loaded) Unknown
2026-06-20 15:58:16.3012|DEBUG|VLC:   Representation audio_64k.m3u8 [mp4a.40.2]
2026-06-20 15:58:16.3012|DEBUG|VLC:     (not loaded) Unknown
2026-06-20 15:58:16.3012|DEBUG|VLC: Period
2026-06-20 15:58:16.3012|DEBUG|VLC:   Representation audio_64k.m3u8 [mp4a.40.2]
2026-06-20 15:58:16.3012|DEBUG|VLC:   Representation audio_128k.m3u8 [mp4a.40.2]
2026-06-20 15:58:16.3012|DEBUG|VLC:     (not loaded) Unknown
2026-06-20 15:58:16.3012|DEBUG|VLC:   Representation audio_128k.m3u8 [mp4a.40.2]
2026-06-20 15:58:16.3012|DEBUG|VLC:     (not loaded) Unknown
2026-06-20 15:58:16.3012|DEBUG|VLC:   Representation audio_256k.m3u8 [mp4a.40.2]
2026-06-20 15:58:16.3012|DEBUG|VLC:     (not loaded) Unknown
2026-06-20 15:58:16.3012|DEBUG|VLC:   Representation audio_256k.m3u8 [mp4a.40.2]
2026-06-20 15:58:16.3012|DEBUG|VLC:     (not loaded) Unknown
2026-06-20 15:58:16.3012|DEBUG|VLC: selecting program id=0
2026-06-20 15:58:16.3157|DEBUG|VLC: playlist Start/End 0/0 len 0rap pl/demux (0/0)
2026-06-20 15:58:16.3157|DEBUG|VLC: cached.i_time (0) cur 0 rap start (pl 0/dmx 0) pos 0.000000
2026-06-20 15:58:16.3157|DEBUG|VLC: opening playlist file (localhost:7002/api/stream/8152a53c-750d-4473-85da-f2f99999537e/master.m3u8?session=8dd048ec-1906-44f3-b615-9c0c820c27ef)
2026-06-20 15:58:16.3157|DEBUG|VLC: using demux module "adaptive"
2026-06-20 15:58:16.3157|DEBUG|VLC: looking for audio decoder module matching "any": 18 candidates
2026-06-20 15:58:16.3157|DEBUG|VLC: using ffmpeg Lavc58.134.100
2026-06-20 15:58:16.3157|DEBUG|VLC: CPU flags: 0x000fd3db
2026-06-20 15:58:16.3157|DEBUG|VLC: codec (aac) started
2026-06-20 15:58:16.3157|DEBUG|VLC: using audio decoder module "avcodec"
2026-06-20 15:58:16.3157|DEBUG|VLC: looking for meta reader module matching "any": 2 candidates
2026-06-20 15:58:16.3157|DEBUG|VLC: Trying Lua scripts in ....\AppData\Roaming\vlc\lua\meta\reader
2026-06-20 15:58:16.3157|DEBUG|VLC: Trying Lua scripts in ....\bin\Debug\net10.0-windows10.0.26100.0\libvlc\win-x64\lua\meta\reader
2026-06-20 15:58:16.3157|DEBUG|VLC: Trying Lua playlist script ...\bin\Debug\net10.0-windows10.0.26100.0\libvlc\win-x64\lua\meta\reader\filename.luac
2026-06-20 15:58:16.3157|DEBUG|VLC: no meta reader modules matched
2026-06-20 15:58:16.3157|DEBUG|VLC: `https://localhost:7002/api/stream/8152a53c-750d-4473-85da-f2f99999537e/master.m3u8?session=8dd048ec-1906-44f3-b615-9c0c820c27ef' successfully opened
2026-06-20 15:58:16.3157|DEBUG|VLC: Retrieving https://localhost:7002/api/stream/8152a53c-750d-4473-85da-f2f99999537e/audio_64k.m3u8
2026-06-20 15:58:16.3157|DEBUG|VLC: looking for tls client module matching "any": 1 candidates
2026-06-20 15:58:16.3157|DEBUG|VLC: using GnuTLS version 3.8.10
2026-06-20 15:58:16.3157|DEBUG|VLC: using tls client module "gnutls"
2026-06-20 15:58:16.3157|DEBUG|VLC: resolving localhost ...
2026-06-20 15:58:16.3157|DEBUG|VLC: loaded 71 trusted CAs from system
2026-06-20 15:58:16.3157|DEBUG|VLC: TLS handshake: Resource temporarily unavailable, try again.
2026-06-20 15:58:16.3157|DEBUG|VLC:  - safe renegotiation (RFC5746) enabled
2026-06-20 15:58:16.3157|DEBUG|VLC: TLS handshake: Success.
2026-06-20 15:58:16.3304|DEBUG|VLC: out SETTINGS (0x04) frame of 30 bytes, flags 0x00, global
2026-06-20 15:58:16.3304|DEBUG|VLC:  - false start (RFC7918) enabled
2026-06-20 15:58:16.3304|DEBUG|VLC: out HEADERS (0x01) frame of 262 bytes, flags 0x05, stream 1
2026-06-20 15:58:16.3157|DEBUG|VLC:  - extended master secret (RFC7627) enabled
2026-06-20 15:58:16.3304|DEBUG|VLC: in SETTINGS (0x04) frame of 24 bytes, flags 0x00, global
2026-06-20 15:58:16.3304|DEBUG|VLC: setting: Header list size (0x0006): 32768
2026-06-20 15:58:16.3304|DEBUG|VLC: setting: Initial window size (0x0004): 786432
2026-06-20 15:58:16.3304|DEBUG|VLC: setting: Unknown setting (0x0008): 1
2026-06-20 15:58:16.3304|DEBUG|VLC: out SETTINGS (0x04) frame of 0 bytes, flags 0x01, global
2026-06-20 15:58:16.3304|DEBUG|VLC: in WINDOW_UPDATE (0x08) frame of 4 bytes, flags 0x00, global
2026-06-20 15:58:16.3304|DEBUG|VLC: setting: Concurrent streams (0x0003): 100
2026-06-20 15:58:16.3304|DEBUG|VLC: in SETTINGS (0x04) frame of 0 bytes, flags 0x01, global
2026-06-20 15:58:16.3304|DEBUG|VLC: stream 1 4 headers:
2026-06-20 15:58:16.3304|DEBUG|VLC:  content-type: "application/json; charset=utf-8"
2026-06-20 15:58:16.3304|DEBUG|VLC:  date: "Sat, 20 Jun 2026 12:58:15 GMT"
2026-06-20 15:58:16.3304|DEBUG|VLC: in HEADERS (0x01) frame of 78 bytes, flags 0x04, stream 1
2026-06-20 15:58:16.3304|DEBUG|VLC: in DATA (0x00) frame of 60 bytes, flags 0x01, stream 1
2026-06-20 15:58:16.3304|DEBUG|VLC:  server: "Kestrel"
2026-06-20 15:58:16.3304|DEBUG|VLC:  :status: "401"
2026-06-20 15:58:16.3304|DEBUG|VLC: out (priority) WINDOW_UPDATE (0x08) frame of 4 bytes, flags 0x00, global
2026-06-20 15:58:16.3304|DEBUG|VLC: stream 1 closed by peer
2026-06-20 15:58:16.3304|ERROR|VLC: local stream 1 error: Cancellation (0x8)
2026-06-20 15:58:16.3304|DEBUG|VLC: out RST_STREAM (0x03) frame of 4 bytes, flags 0x00, stream 1
2026-06-20 15:58:16.3304|WARN|VLC: Failed to update 0/3 playlist ID audio_64k.m3u8
2026-06-20 15:58:16.3304|ERROR|VLC: Failed to create demuxer 0000000000000000 Unknown
2026-06-20 15:58:16.3304|DEBUG|VLC: EOF reached
2026-06-20 15:58:16.3304|DEBUG|VLC: killing decoder fourcc `mp4a'
2026-06-20 15:58:16.3304|DEBUG|VLC: removing module "avcodec"
2026-06-20 15:58:16.3304|DEBUG|VLC: removing module "adaptive"
2026-06-20 15:58:16.3304|DEBUG|VLC: Program doesn't contain anymore ES
2026-06-20 15:58:16.3304|DEBUG|VLC: local shutdown
2026-06-20 15:58:16.3456|DEBUG|VLC: out GOAWAY (0x07) frame of 8 bytes, flags 0x00, global
2026-06-20 15:58:16.3456|DEBUG|VLC: removing module "record"
2026-06-20 15:58:16.3456|DEBUG|VLC: removing module "prefetch"
2026-06-20 15:58:16.3456|DEBUG|VLC: removing module "access"
2026-06-20 15:58:16.3456|DEBUG|VLC: out GOAWAY (0x07) frame of 8 bytes, flags 0x00, global
2026-06-20 15:58:16.3456|DEBUG|VLC: local stream 1 shut down
2026-06-20 15:58:16.3456|DEBUG|VLC: local shutdown
2026-06-20 15:58:16.3456|DEBUG|VLC: out RST_STREAM (0x03) frame of 4 bytes, flags 0x00, stream 1

解决方案

我不知道 --http-forward-cookies 应该做什么,但它不会从你的Avalonia端转发任何内容。

你需要的是正确的认证。这可以在服务器端通过HTTP Basic认证或Digest认证来实现。

一旦完成,你就可以把你的URL粘贴到VLC中,看到VLC会显示一个用户名和密码的提示。你需要在你的代码中实现同样的行为,或模拟同样的交互。

在客户端,libvlc将通过对话框回调API暴露登录请求(参见 https://code.videolan.org/videolan/LibVLCSharp/-/blob/master/src/LibVLCSharp/Dialog.cs)。

收到登录对话框事件后,你应在稍后时间通过PostLogin调用来进行回复(就像用户在登录提示中输入用户名和密码一样)。

站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。

相关文章