Merge pull request #62 from 3400442579/master

Snapshot ,Join
This commit is contained in:
Malte Rosenbjerg 2020-05-17 01:36:37 +02:00 committed by GitHub
commit 7faeda3094
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 14 deletions

View file

@ -18,7 +18,7 @@ public static string Extension(this Codec type)
} }
public static readonly string Mp4 = ".mp4"; public static readonly string Mp4 = ".mp4";
public static readonly string Mp3 = ".mp3"; 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 Ogv = ".ogv";
public static readonly string Png = ".png"; public static readonly string Png = ".png";
public static readonly string WebM = ".webm"; public static readonly string WebM = ".webm";

View file

@ -1,13 +1,12 @@
using System; using FFMpegCore.Enums;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using FFMpegCore.Enums;
using FFMpegCore.Exceptions; using FFMpegCore.Exceptions;
using FFMpegCore.Helpers; using FFMpegCore.Helpers;
using FFMpegCore.Pipes; using FFMpegCore.Pipes;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
namespace FFMpegCore namespace FFMpegCore
{ {
@ -76,18 +75,18 @@ public static Bitmap Snapshot(MediaAnalysis source, Size? size = null, TimeSpan?
{ {
if (size.Value.Width == 0) if (size.Value.Width == 0)
{ {
var ratio = source.PrimaryVideoStream.Width / (double) size.Value.Width; var ratio = (double)size.Value.Height / source.PrimaryVideoStream.Height;
size = new Size((int) (source.PrimaryVideoStream.Width * ratio), size = new Size((int)(source.PrimaryVideoStream.Width * ratio),
(int) (source.PrimaryVideoStream.Height * ratio)); (int)(source.PrimaryVideoStream.Height * ratio));
} }
if (size.Value.Height == 0) if (size.Value.Height == 0)
{ {
var ratio = source.PrimaryVideoStream.Height / (double) size.Value.Height; var ratio = (double)size.Value.Width / source.PrimaryVideoStream.Width;
size = new Size((int) (source.PrimaryVideoStream.Width * ratio), size = new Size((int)(source.PrimaryVideoStream.Width * ratio),
(int) (source.PrimaryVideoStream.Height * ratio)); (int)(source.PrimaryVideoStream.Height * ratio));
} }
} }