protected override Matroska.VideoSink CreateVideoSink() { var fileIndex = 0; var fileExtension = "mkv"; var filePathWithoutExtension = ProcessFilePath(Path.Combine(Options.OutputPath, Options.OutputFileName), RemoteConnectionInfo); var filePath = $"{filePathWithoutExtension}-{fileIndex}.{fileExtension}"; while (File.Exists(filePath)) { filePath = $"{filePathWithoutExtension}-{++fileIndex}.{fileExtension}"; } //TODO: should the JSON here follow the media server conventions? var jsonPath = filePath + ".json"; File.WriteAllText(jsonPath, RemoteConnectionInfo.ToJson()); Console.WriteLine(jsonPath); var format = VideoFormat.Clone(); format.IsPacketized = false; return(new Matroska.VideoSink(filePath, format)); }