コード例 #1
0
        public void StartStreamlinkVlc(string vlcExeLocation, string streamUrl, string title)
        {
            var streamIdentifier    = GetStreamIdentifier();
            var streamlinkArguments = $"--player \"{vlcExeLocation} --file-caching=5000 --network-caching=10000\" --title \"{title}\" --hls-audio-select * --hls-segment-attempts 10 --hls-segment-timeout 20 --ringbuffer-size 64M \"{streamUrl}\" {streamIdentifier}";

            _logger.Info($"Starting VLC Streamlink-instance for stream-URL '{streamUrl}' with identifier '{streamIdentifier}'...");

            using var process = ProcessUtils.CreateProcess(StreamlinkBatchLocation, streamlinkArguments, true);
            process.Start();
        }
コード例 #2
0
        public void StartStreamlinkMpv(string mpvExeLocation, string streamUrl, string title)
        {
            var streamIdentifier    = GetStreamIdentifier();
            var streamlinkArguments = $"--player \"{mpvExeLocation}\" --title \"{title}\" --hls-audio-select * \"{streamUrl}\" {streamIdentifier}";

            _logger.Info($"Starting MPV Streamlink-instance for stream-URL '{streamUrl}' with identifier '{streamIdentifier}'...");

            using var process = ProcessUtils.CreateProcess(StreamlinkBatchLocation, streamlinkArguments, true);
            process.Start();
        }
コード例 #3
0
        public Process StartStreamlinkRecording(string streamUrl, string title)
        {
            var streamIdentifier    = GetStreamIdentifier();
            var filename            = GetRecordingFilename(title);
            var streamlinkArguments = $"--output \"{filename}\" --force --hls-audio-select * --hls-segment-attempts 10 --hls-segment-timeout 20 --ringbuffer-size 64M \"{streamUrl}\" {streamIdentifier}";

            _logger.Info($"Starting recording Streamlink-instance for stream-URL '{streamUrl}' with identifier '{streamIdentifier}' to file '{filename}'...");

            var process = ProcessUtils.CreateProcess(StreamlinkBatchLocation, streamlinkArguments, true, true);

            process.OutputDataReceived += (sender, args) => _logger.Info($"[Streamlink] {args.Data}");
            process.Start();
            process.BeginOutputReadLine();

            return(process);
        }
コード例 #4
0
        public async Task <(Process process, string streamlinkUrl)> StartStreamlinkExternalAsync(string streamUrl, int timeout = 30)
        {
            var port                = SocketUtils.GetFreePort();
            var streamIdentifier    = GetStreamIdentifier();
            var streamlinkArguments = $"--player-external-http --player-external-http-port {port} --hls-audio-select * --hls-segment-attempts 10 --hls-segment-timeout 20 --ringbuffer-size 64M \"{streamUrl}\" {streamIdentifier}";

            _logger.Info($"Starting external Streamlink-instance for stream-URL '{streamUrl}' with identifier '{streamIdentifier}' on port '{port}'...");

            var process = ProcessUtils.CreateProcess(StreamlinkBatchLocation, streamlinkArguments, true, true);

            process.OutputDataReceived += (sender, args) => _logger.Info($"[Streamlink] {args.Data}");
            process.Start();
            process.BeginOutputReadLine();

            await SocketUtils.WaitUntilPortInUseAsync(port, timeout);

            return(process, $"http://127.0.0.1:{port}");
        }