Exemple #1
0
        public override string GenerateThumbnail()
        {
            // Get temp path where thumbnail should be stored
            string outputPath = GetTempFilename("jpg");

            // Get actual video dimensions
            m_Logger.DebugFormat("Video dimensions are: {0}x{1}", m_Width, m_Height);

            // Get dimensions of the thumbnail to be generated
            Size dimensions = GetAspectImageSize(m_Width, m_Height, ThumbnailSize.Width, ThumbnailSize.Height);

            m_Logger.DebugFormat("Thumbnail will be resized to: {0}x{1}", dimensions.Width, dimensions.Height);

            // Get settings
            string ffmpeg = GetSetting("FFmpegExecutablePath");
            string args   = GetSetting("FFmpegThumbnailArgs");

            // Replace keywords
            args = args.Replace("[INPUT]", InputPath.WrapInQuotes());
            args = args.Replace("[OUTPUT]", outputPath.WrapInQuotes());
            args = args.Replace("[WIDTH]", dimensions.Width.ToString());
            args = args.Replace("[HEIGHT]", dimensions.Height.ToString());

            // Execute FFmpeg command line
            CommandLineExecuter.Execute(ffmpeg, args);

            return(outputPath);
        }
Exemple #2
0
        public override string GeneratePreview()
        {
            string extension = (Path.GetExtension(InputPath) ?? string.Empty).ToLower();

            // Get temp path where FLV should be stored
            string outputPath = GetTempFilename(GetExtensionGenerated(extension));

            // Get settings
            string ffmpeg = GetSetting("FFmpegExecutablePath");
            string args   = GetSetting("FFmpegPreviewArgs");

            // Replace keywords
            args = args.Replace("[INPUT]", InputPath.WrapInQuotes());
            args = args.Replace("[OUTPUT]", outputPath.WrapInQuotes());
            args = args.Replace("[WIDTH]", PreviewSize.Width.ToString());
            args = args.Replace("[HEIGHT]", PreviewSize.Height.ToString());

            // Apply watermark
            if (!String.IsNullOrEmpty(WatermarkPath) && File.Exists(WatermarkPath))
            {
                string watermarkArgs = GetSetting("FFmpegWatermarkArgs");

                if (String.IsNullOrEmpty(watermarkArgs))
                {
                    m_Logger.WarnFormat("Unable to apply watermark; no command arguments specified");
                }
                else
                {
                    watermarkArgs = watermarkArgs.Replace("[WATERMARK]", WatermarkPath.WrapInQuotes());
                    args          = args.Replace("[WATERMARK-ARGS]", watermarkArgs);
                }
            }

            // Remove watermark args placeholder, in case no watermark was requested or file not found
            args = args.Replace("[WATERMARK-ARGS]", string.Empty);

            // Execute FFmpeg command line
            CommandLineExecuter.Execute(ffmpeg, args);

            // Update FLV metadata (fixes duration & seek problems)
            string flvtool     = GetSetting("FLVToolExecutablePath");
            string flvtoolargs = string.Format("-U {0}", outputPath);

            CommandLineExecuter.Execute(flvtool, flvtoolargs);

            return(outputPath);
        }