From 74593461d4cc928ce8474404980c4f7116daba0d Mon Sep 17 00:00:00 2001 From: jianxingwu Date: Fri, 15 May 2020 16:58:56 +0800 Subject: [PATCH 1/3] PrepareSnapshotSize error : ratio=source.PrimaryVideoStream.Width / 0 ratio=source.PrimaryVideoStream.Height / 0 --- FFMpegCore/FFMpeg/FFMpeg.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FFMpegCore/FFMpeg/FFMpeg.cs b/FFMpegCore/FFMpeg/FFMpeg.cs index 8bcdc1f..c9bf3ac 100644 --- a/FFMpegCore/FFMpeg/FFMpeg.cs +++ b/FFMpegCore/FFMpeg/FFMpeg.cs @@ -76,7 +76,7 @@ public static Bitmap Snapshot(MediaAnalysis source, Size? size = null, TimeSpan? { if (size.Value.Width == 0) { - var ratio = source.PrimaryVideoStream.Width / (double) size.Value.Width; + var ratio = source.PrimaryVideoStream.Height / (double) size.Value.Height; size = new Size((int) (source.PrimaryVideoStream.Width * ratio), (int) (source.PrimaryVideoStream.Height * ratio)); @@ -84,7 +84,7 @@ public static Bitmap Snapshot(MediaAnalysis source, Size? size = null, TimeSpan? if (size.Value.Height == 0) { - var ratio = source.PrimaryVideoStream.Height / (double) size.Value.Height; + var ratio = source.PrimaryVideoStream.Width / (double) size.Value.Width; size = new Size((int) (source.PrimaryVideoStream.Width * ratio), (int) (source.PrimaryVideoStream.Height * ratio)); From 738176479dbffd80b619ec3d4dd29c51e93bd5b3 Mon Sep 17 00:00:00 2001 From: jianxingwu Date: Fri, 15 May 2020 17:03:29 +0800 Subject: [PATCH 2/3] FFMpeg.Join error Invalid output file. File extension should be 'mpegts' required. --- FFMpegCore/FFMpeg/Enums/FileExtension.cs | 2 +- FFMpegCore/FFMpeg/FFMpeg.cs | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/FFMpegCore/FFMpeg/Enums/FileExtension.cs b/FFMpegCore/FFMpeg/Enums/FileExtension.cs index d2e4a63..58a8ff3 100644 --- a/FFMpegCore/FFMpeg/Enums/FileExtension.cs +++ b/FFMpegCore/FFMpeg/Enums/FileExtension.cs @@ -18,7 +18,7 @@ public static string Extension(this Codec type) } public static readonly string Mp4 = ".mp4"; public static readonly string Mp3 = ".mp3"; - public static readonly string Ts = ".ts"; + public static readonly string Ts = ".mpegts"; public static readonly string Ogv = ".ogv"; public static readonly string Png = ".png"; public static readonly string WebM = ".webm"; diff --git a/FFMpegCore/FFMpeg/FFMpeg.cs b/FFMpegCore/FFMpeg/FFMpeg.cs index c9bf3ac..725ea70 100644 --- a/FFMpegCore/FFMpeg/FFMpeg.cs +++ b/FFMpegCore/FFMpeg/FFMpeg.cs @@ -1,13 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Drawing.Imaging; -using System.IO; -using System.Linq; -using FFMpegCore.Enums; +using FFMpegCore.Enums; using FFMpegCore.Exceptions; using FFMpegCore.Helpers; using FFMpegCore.Pipes; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.IO; +using System.Linq; namespace FFMpegCore { From 0da0b0c1569e5d8c5810d6aac79bf8b43db13582 Mon Sep 17 00:00:00 2001 From: jianxingwu Date: Fri, 15 May 2020 17:26:34 +0800 Subject: [PATCH 3/3] PrepareSnapshotSize repair --- FFMpegCore/FFMpeg/FFMpeg.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/FFMpegCore/FFMpeg/FFMpeg.cs b/FFMpegCore/FFMpeg/FFMpeg.cs index 725ea70..e2fcfde 100644 --- a/FFMpegCore/FFMpeg/FFMpeg.cs +++ b/FFMpegCore/FFMpeg/FFMpeg.cs @@ -75,18 +75,18 @@ public static Bitmap Snapshot(MediaAnalysis source, Size? size = null, TimeSpan? { if (size.Value.Width == 0) { - var ratio = source.PrimaryVideoStream.Height / (double) size.Value.Height; + var ratio = (double)size.Value.Height / source.PrimaryVideoStream.Height; - size = new Size((int) (source.PrimaryVideoStream.Width * ratio), - (int) (source.PrimaryVideoStream.Height * ratio)); + size = new Size((int)(source.PrimaryVideoStream.Width * ratio), + (int)(source.PrimaryVideoStream.Height * ratio)); } if (size.Value.Height == 0) { - var ratio = source.PrimaryVideoStream.Width / (double) size.Value.Width; + var ratio = (double)size.Value.Width / source.PrimaryVideoStream.Width; - size = new Size((int) (source.PrimaryVideoStream.Width * ratio), - (int) (source.PrimaryVideoStream.Height * ratio)); + size = new Size((int)(source.PrimaryVideoStream.Width * ratio), + (int)(source.PrimaryVideoStream.Height * ratio)); } }