Beispiel #1
0
        /// <summary>
        /// Saves a 'png' thumbnail from the input video.
        /// </summary>
        /// <param name="source">Source video file.</param>
        /// <param name="output">Output video file</param>
        /// <param name="seek">Seek position where the thumbnail should be taken.</param>
        /// <param name="thumbWidth">Thumbnail width.</param>
        /// <param name="thumbHeight">Thumbnail height.</param>
        /// <returns>Success state.</returns>
        public bool SaveThumbnail(VideoInfo source, string output, TimeSpan?seek = null, int thumbWidth = 300, int thumbHeight = 169)
        {
            _probe.SetVideoInfo(ref source);

            if (seek == null)
            {
                seek = new TimeSpan(0, 0, 7);
            }

            FFMpegHelper.ConversionExceptionCheck(source, output);
            FFMpegHelper.ExtensionExceptionCheck(output, ".png");

            string thumbArgs,
                   thumbSize = thumbWidth.ToString() + "x" + thumbHeight.ToString();

            thumbArgs = String.Format("-i \"{0}\" -vcodec png -vframes 1 -ss {1} -s {2} \"{3}\"", source.Path,
                                      seek.ToString(),
                                      thumbSize,
                                      output);

            return(_RunProcess(thumbArgs));
        }