| | | 1 | | #pragma warning disable CS1591 |
| | | 2 | | |
| | | 3 | | using System; |
| | | 4 | | using System.Collections.Generic; |
| | | 5 | | using System.Globalization; |
| | | 6 | | using System.Linq; |
| | | 7 | | using Jellyfin.Extensions; |
| | | 8 | | using MediaBrowser.Model.MediaInfo; |
| | | 9 | | |
| | | 10 | | namespace MediaBrowser.MediaEncoding.Encoder |
| | | 11 | | { |
| | | 12 | | public static class EncodingUtils |
| | | 13 | | { |
| | | 14 | | public static string GetInputArgument(string inputPrefix, string inputFile, MediaProtocol protocol) |
| | | 15 | | { |
| | 0 | 16 | | if (protocol != MediaProtocol.File) |
| | | 17 | | { |
| | 0 | 18 | | return string.Format(CultureInfo.InvariantCulture, "\"{0}\"", inputFile); |
| | | 19 | | } |
| | | 20 | | |
| | 0 | 21 | | return GetFileInputArgument(inputFile, inputPrefix); |
| | | 22 | | } |
| | | 23 | | |
| | | 24 | | public static string GetInputArgument(string inputPrefix, IReadOnlyList<string> inputFiles, MediaProtocol protoc |
| | | 25 | | { |
| | 0 | 26 | | if (protocol != MediaProtocol.File) |
| | | 27 | | { |
| | 0 | 28 | | return string.Format(CultureInfo.InvariantCulture, "\"{0}\"", inputFiles[0]); |
| | | 29 | | } |
| | | 30 | | |
| | 0 | 31 | | return GetConcatInputArgument(inputFiles, inputPrefix); |
| | | 32 | | } |
| | | 33 | | |
| | | 34 | | /// <summary> |
| | | 35 | | /// Gets the concat input argument. |
| | | 36 | | /// </summary> |
| | | 37 | | /// <param name="inputFiles">The input files.</param> |
| | | 38 | | /// <param name="inputPrefix">The input prefix.</param> |
| | | 39 | | /// <returns>System.String.</returns> |
| | | 40 | | private static string GetConcatInputArgument(IReadOnlyList<string> inputFiles, string inputPrefix) |
| | | 41 | | { |
| | | 42 | | // Get all streams |
| | | 43 | | // If there's more than one we'll need to use the concat command |
| | 0 | 44 | | if (inputFiles.Count > 1) |
| | | 45 | | { |
| | 0 | 46 | | var files = string.Join('|', inputFiles.Select(f => f.EscapeProcessArgument())); |
| | | 47 | | |
| | 0 | 48 | | return string.Format(CultureInfo.InvariantCulture, "concat:\"{0}\"", files); |
| | | 49 | | } |
| | | 50 | | |
| | | 51 | | // Determine the input path for video files |
| | 0 | 52 | | return GetFileInputArgument(inputFiles[0], inputPrefix); |
| | | 53 | | } |
| | | 54 | | |
| | | 55 | | /// <summary> |
| | | 56 | | /// Gets the file input argument. |
| | | 57 | | /// </summary> |
| | | 58 | | /// <param name="path">The path.</param> |
| | | 59 | | /// <param name="inputPrefix">The path prefix.</param> |
| | | 60 | | /// <returns>System.String.</returns> |
| | | 61 | | private static string GetFileInputArgument(string path, string inputPrefix) |
| | | 62 | | { |
| | 0 | 63 | | if (path.Contains("://", StringComparison.Ordinal)) |
| | | 64 | | { |
| | 0 | 65 | | return string.Format(CultureInfo.InvariantCulture, "\"{0}\"", path); |
| | | 66 | | } |
| | | 67 | | |
| | 0 | 68 | | path = path.EscapeProcessArgument(); |
| | | 69 | | |
| | 0 | 70 | | return string.Format(CultureInfo.InvariantCulture, "{1}:\"{0}\"", path, inputPrefix); |
| | | 71 | | } |
| | | 72 | | } |
| | | 73 | | } |