aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs
blob: de6353c4c1f897b7f181bccba0df089c19d4866c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
#nullable disable

#pragma warning disable CS1591

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Drawing;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.MediaInfo;

namespace MediaBrowser.Controller.MediaEncoding
{
    /// <summary>
    /// Interface IMediaEncoder.
    /// </summary>
    public interface IMediaEncoder : ITranscoderSupport
    {
        /// <summary>
        /// Gets the encoder path.
        /// </summary>
        /// <value>The encoder path.</value>
        string EncoderPath { get; }

        /// <summary>
        /// Gets the probe path.
        /// </summary>
        /// <value>The probe path.</value>
        string ProbePath { get; }

        /// <summary>
        /// Gets the version of encoder.
        /// </summary>
        /// <returns>The version of encoder.</returns>
        Version EncoderVersion { get; }

        /// <summary>
        /// Gets a value indicating whether p key pausing is supported.
        /// </summary>
        /// <value><c>true</c> if p key pausing is supported, <c>false</c> otherwise.</value>
        bool IsPkeyPauseSupported { get; }

        /// <summary>
        /// Gets a value indicating whether the configured Vaapi device is from AMD(radeonsi/r600 Mesa driver).
        /// </summary>
        /// <value><c>true</c> if the Vaapi device is an AMD(radeonsi/r600 Mesa driver) GPU, <c>false</c> otherwise.</value>
        bool IsVaapiDeviceAmd { get; }

        /// <summary>
        /// Gets a value indicating whether the configured Vaapi device is from Intel(iHD driver).
        /// </summary>
        /// <value><c>true</c> if the Vaapi device is an Intel(iHD driver) GPU, <c>false</c> otherwise.</value>
        bool IsVaapiDeviceInteliHD { get; }

        /// <summary>
        /// Gets a value indicating whether the configured Vaapi device is from Intel(legacy i965 driver).
        /// </summary>
        /// <value><c>true</c> if the Vaapi device is an Intel(legacy i965 driver) GPU, <c>false</c> otherwise.</value>
        bool IsVaapiDeviceInteli965 { get; }

        /// <summary>
        /// Gets a value indicating whether the configured Vaapi device supports vulkan drm format modifier.
        /// </summary>
        /// <value><c>true</c> if the Vaapi device supports vulkan drm format modifier, <c>false</c> otherwise.</value>
        bool IsVaapiDeviceSupportVulkanDrmModifier { get; }

        /// <summary>
        /// Gets a value indicating whether the configured Vaapi device supports vulkan drm interop via dma-buf.
        /// </summary>
        /// <value><c>true</c> if the Vaapi device supports vulkan drm interop, <c>false</c> otherwise.</value>
        bool IsVaapiDeviceSupportVulkanDrmInterop { get; }

        /// <summary>
        /// Gets a value indicating whether av1 decoding is available via VideoToolbox.
        /// </summary>
        /// <value><c>true</c> if the av1 is available via VideoToolbox, <c>false</c> otherwise.</value>
        bool IsVideoToolboxAv1DecodeAvailable { get; }

        /// <summary>
        /// Whether given encoder codec is supported.
        /// </summary>
        /// <param name="encoder">The encoder.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        bool SupportsEncoder(string encoder);

        /// <summary>
        /// Whether given decoder codec is supported.
        /// </summary>
        /// <param name="decoder">The decoder.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        bool SupportsDecoder(string decoder);

        /// <summary>
        /// Whether given hardware acceleration type is supported.
        /// </summary>
        /// <param name="hwaccel">The hwaccel.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        bool SupportsHwaccel(string hwaccel);

        /// <summary>
        /// Whether given filter is supported.
        /// </summary>
        /// <param name="filter">The filter.</param>
        /// <returns><c>true</c> if the filter is supported, <c>false</c> otherwise.</returns>
        bool SupportsFilter(string filter);

        /// <summary>
        /// Whether filter is supported with the given option.
        /// </summary>
        /// <param name="option">The option.</param>
        /// <returns><c>true</c> if the filter is supported, <c>false</c> otherwise.</returns>
        bool SupportsFilterWithOption(FilterOptionType option);

        /// <summary>
        /// Whether the bitstream filter is supported with the given option.
        /// </summary>
        /// <param name="option">The option.</param>
        /// <returns><c>true</c> if the bitstream filter is supported, <c>false</c> otherwise.</returns>
        bool SupportsBitStreamFilterWithOption(BitStreamFilterOptionType option);

        /// <summary>
        /// Extracts the audio image.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="imageStreamIndex">Index of the image stream.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task{Stream}.</returns>
        Task<string> ExtractAudioImage(string path, int? imageStreamIndex, CancellationToken cancellationToken);

        /// <summary>
        /// Extracts the video image.
        /// </summary>
        /// <param name="inputFile">Input file.</param>
        /// <param name="container">Video container type.</param>
        /// <param name="mediaSource">Media source information.</param>
        /// <param name="videoStream">Media stream information.</param>
        /// <param name="threedFormat">Video 3D format.</param>
        /// <param name="offset">Time offset.</param>
        /// <param name="cancellationToken">CancellationToken to use for operation.</param>
        /// <returns>Location of video image.</returns>
        Task<string> ExtractVideoImage(string inputFile, string container, MediaSourceInfo mediaSource, MediaStream videoStream, Video3DFormat? threedFormat, TimeSpan? offset, CancellationToken cancellationToken);

        /// <summary>
        /// Extracts the video image.
        /// </summary>
        /// <param name="inputFile">Input file.</param>
        /// <param name="container">Video container type.</param>
        /// <param name="mediaSource">Media source information.</param>
        /// <param name="imageStream">Media stream information.</param>
        /// <param name="imageStreamIndex">Index of the stream to extract from.</param>
        /// <param name="targetFormat">The format of the file to write.</param>
        /// <param name="cancellationToken">CancellationToken to use for operation.</param>
        /// <returns>Location of video image.</returns>
        Task<string> ExtractVideoImage(string inputFile, string container, MediaSourceInfo mediaSource, MediaStream imageStream, int? imageStreamIndex, ImageFormat? targetFormat, CancellationToken cancellationToken);

        /// <summary>
        /// Extracts the video images on interval.
        /// </summary>
        /// <param name="inputFile">Input file.</param>
        /// <param name="container">Video container type.</param>
        /// <param name="mediaSource">Media source information.</param>
        /// <param name="imageStream">Media stream information.</param>
        /// <param name="maxWidth">The maximum width.</param>
        /// <param name="interval">The interval.</param>
        /// <param name="allowHwAccel">Allow for hardware acceleration.</param>
        /// <param name="enableHwEncoding">Use hardware mjpeg encoder.</param>
        /// <param name="threads">The input/output thread count for ffmpeg.</param>
        /// <param name="qualityScale">The qscale value for ffmpeg.</param>
        /// <param name="priority">The process priority for the ffmpeg process.</param>
        /// <param name="enableKeyFrameOnlyExtraction">Whether to only extract key frames.</param>
        /// <param name="encodingHelper">EncodingHelper instance.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Directory where images where extracted. A given image made before another will always be named with a lower number.</returns>
        Task<string> ExtractVideoImagesOnIntervalAccelerated(
            string inputFile,
            string container,
            MediaSourceInfo mediaSource,
            MediaStream imageStream,
            int maxWidth,
            TimeSpan interval,
            bool allowHwAccel,
            bool enableHwEncoding,
            int? threads,
            int? qualityScale,
            ProcessPriorityClass? priority,
            bool enableKeyFrameOnlyExtraction,
            EncodingHelper encodingHelper,
            CancellationToken cancellationToken);

        /// <summary>
        /// Gets the media info.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task.</returns>
        Task<MediaInfo> GetMediaInfo(MediaInfoRequest request, CancellationToken cancellationToken);

        /// <summary>
        /// Gets the input argument.
        /// </summary>
        /// <param name="inputFile">The input file.</param>
        /// <param name="mediaSource">The mediaSource.</param>
        /// <returns>System.String.</returns>
        string GetInputArgument(string inputFile, MediaSourceInfo mediaSource);

        /// <summary>
        /// Gets the input argument.
        /// </summary>
        /// <param name="inputFiles">The input files.</param>
        /// <param name="mediaSource">The mediaSource.</param>
        /// <returns>System.String.</returns>
        string GetInputArgument(IReadOnlyList<string> inputFiles, MediaSourceInfo mediaSource);

        /// <summary>
        /// Gets the input argument for an external subtitle file.
        /// </summary>
        /// <param name="inputFile">The input file.</param>
        /// <returns>System.String.</returns>
        string GetExternalSubtitleInputArgument(string inputFile);

        /// <summary>
        /// Gets the time parameter.
        /// </summary>
        /// <param name="ticks">The ticks.</param>
        /// <returns>System.String.</returns>
        string GetTimeParameter(long ticks);

        Task ConvertImage(string inputPath, string outputPath);

        /// <summary>
        /// Escapes the subtitle filter path.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns>System.String.</returns>
        string EscapeSubtitleFilterPath(string path);

        /// <summary>
        /// Sets the path to find FFmpeg.
        /// </summary>
        /// <returns>bool indicates whether a valid ffmpeg is found.</returns>
        bool SetFFmpegPath();

        /// <summary>
        /// Gets the primary playlist of .vob files.
        /// </summary>
        /// <param name="path">The to the .vob files.</param>
        /// <param name="titleNumber">The title number to start with.</param>
        /// <returns>A playlist.</returns>
        IReadOnlyList<string> GetPrimaryPlaylistVobFiles(string path, uint? titleNumber);

        /// <summary>
        /// Gets the primary playlist of .m2ts files.
        /// </summary>
        /// <param name="path">The to the .m2ts files.</param>
        /// <returns>A playlist.</returns>
        IReadOnlyList<string> GetPrimaryPlaylistM2tsFiles(string path);

        /// <summary>
        /// Gets the input path argument from <see cref="EncodingJobInfo"/>.
        /// </summary>
        /// <param name="state">The <see cref="EncodingJobInfo"/>.</param>
        /// <returns>The input path argument.</returns>
        string GetInputPathArgument(EncodingJobInfo state);

        /// <summary>
        /// Gets the input path argument.
        /// </summary>
        /// <param name="path">The item path.</param>
        /// <param name="mediaSource">The <see cref="MediaSourceInfo"/>.</param>
        /// <returns>The input path argument.</returns>
        string GetInputPathArgument(string path, MediaSourceInfo mediaSource);

        /// <summary>
        /// Generates a FFmpeg concat config for the source.
        /// </summary>
        /// <param name="source">The <see cref="MediaSourceInfo"/>.</param>
        /// <param name="concatFilePath">The path the config should be written to.</param>
        void GenerateConcatConfig(MediaSourceInfo source, string concatFilePath);
    }
}