/// <summary> /// Creates a new <see cref="DecodeContext"/> instance. /// </summary> /// <param name="url">The URL of the video source. If a file system path is provided, make sure it is an absolute path.</param> /// <param name="decodingOptions">Decoding options.</param> internal DecodeContext([NotNull] string url, [NotNull] DecodingOptions decodingOptions) { _decodingOptions = decodingOptions; // 1. Open a format context. var formatContext = ffmpeg.avformat_alloc_context(); FFmpegHelper.Verify(ffmpeg.avformat_open_input(&formatContext, url, null, null), Dispose); _formatContext = formatContext; // 2. Try to read stream information (codec, duration, etc.). FFmpegHelper.Verify(ffmpeg.avformat_find_stream_info(formatContext, null), Dispose); // The rest are initialized lazily. See LazyInitialize(). }
/// <summary> /// Loads a video from a URL using specified decoding options. /// </summary> /// <param name="url">The URL of the video source.</param> /// <param name="decodingOptions">The decoding options to use.</param> /// <returns>Loaded video.</returns> public static Video LoadFromUrl([NotNull] string url, [NotNull] DecodingOptions decodingOptions) { return(new Video(url, decodingOptions)); }
/// <summary> /// Loads a video from file system using specified decoding options. /// </summary> /// <param name="path">The path of the video file.</param> /// <param name="decodingOptions">The decoding options to use.</param> /// <returns>Loaded video.</returns> public static Video LoadFromFile([NotNull] string path, [NotNull] DecodingOptions decodingOptions) { var fullPath = Path.GetFullPath(path); return(LoadFromUrl(fullPath, decodingOptions)); }