提交 b3c5ab9e 编写于 作者: N Nicke Manarin

Initial support for v6 of FFmpeg

上级 9b487f6b
namespace ScreenToGif.Domain.Enums;
public enum SupportedFFmpegVersions
{
Version6 = 0,
Version5,
Version4,
}
\ No newline at end of file
......@@ -1544,6 +1544,12 @@ public class UserSettings : INotifyPropertyChanged
set => SetValue(value);
}
public SupportedFFmpegVersions FfmpegVersion
{
get => (SupportedFFmpegVersions)GetValue();
set => SetValue(value);
}
public string GifskiLocation
{
get => (string)GetValue();
......
......@@ -581,6 +581,7 @@
<s:String x:Key="S.Options.Extras.FfmpegLocation.Select">Select the location of the FFmpeg executable</s:String>
<s:String x:Key="S.Options.Extras.FfmpegLocation.File">FFmpeg executable</s:String>
<s:String x:Key="S.Options.Extras.FfmpegLocation.Invalid">The path of FFMpeg executable contains one or more invalid characters. Please, select a valid location for that executable.</s:String>
<s:String x:Key="S.Options.Extras.FfmpegVersion">FFmpeg Version</s:String>
<s:String x:Key="S.Options.Extras.GifskiLocation">Gifski location</s:String>
<s:String x:Key="S.Options.Extras.GifskiLocation.Select">Select the location of the Gifski library</s:String>
<s:String x:Key="S.Options.Extras.GifskiLocation.File">Gifski library</s:String>
......
......@@ -581,6 +581,7 @@
<s:String x:Key="S.Options.Extras.FfmpegLocation.Select">Selecione a pasta de localização do executável do FFmpeg.</s:String>
<s:String x:Key="S.Options.Extras.FfmpegLocation.File">Executável do FFmpeg</s:String>
<s:String x:Key="S.Options.Extras.FfmpegLocation.Invalid">O caminho do executável FFMpeg contém um ou mais caracteres inválidos. Por favor, selecione um caminho válido para o executável.</s:String>
<s:String x:Key="S.Options.Extras.FfmpegVersion">Versão do FFmpeg</s:String>
<s:String x:Key="S.Options.Extras.GifskiLocation">Localização do Gifski</s:String>
<s:String x:Key="S.Options.Extras.GifskiLocation.Select">Selecione a localização da biblioteca Gifski</s:String>
<s:String x:Key="S.Options.Extras.GifskiLocation.File">Biblioteca Gifski</s:String>
......
......@@ -193,6 +193,7 @@
<!--Options • Extras-->
<!--<s:String x:Key="FfmpegLocation"></s:String>-->
<e:SupportedFFmpegVersions x:Key="FfmpegVersion">Version4</e:SupportedFFmpegVersions>
<!--<s:String x:Key="GifskiLocation"></s:String>-->
<!--<s:String x:Key="SharpDxLocationFolder"></s:String>-->
......
......@@ -46,6 +46,7 @@ using Color = System.Windows.Media.Color;
using Encoder = ScreenToGif.Windows.Other.Encoder;
using LegacyGifEncoder = ScreenToGif.Util.Codification.Gif.LegacyEncoder.GifEncoder;
using KGySoftGifEncoder = KGySoft.Drawing.Imaging.GifEncoder;
using ScreenToGif.ViewModel.ExportPresets.AnimatedImage.Bpg;
namespace ScreenToGif.Util;
......@@ -1416,7 +1417,7 @@ internal class EncodingManager
var firstPass = "";
var secondPass = "";
//TODO: Adapt the code to support v4 or v6
switch (preset.Type)
{
case ExportFormats.Gif:
......@@ -1431,10 +1432,6 @@ internal class EncodingManager
firstPass = gifPreset.Parameters.Replace("\n", " ").Replace("\r", "");
else
{
//Vsync
if (gifPreset.Vsync != Vsyncs.Off)
firstPass += $"-vsync {gifPreset.Vsync.ToString().ToLower()} ";
//Input and loop.
firstPass += "{I} ";
firstPass += $"-loop {(gifPreset.Looped ? gifPreset.RepeatForever ? 0 : gifPreset.RepeatCount : -1)} ";
......@@ -1454,7 +1451,18 @@ internal class EncodingManager
firstPass += $"-r {(gifPreset.Framerate == Framerates.Custom ? gifPreset.CustomFramerate.ToString(CultureInfo.InvariantCulture) : gifPreset.Framerate.GetLowerDescription())} ";
//Format and output.
firstPass += "-f gif {O}";
firstPass += "-f gif ";
//Vsync
if (gifPreset.Vsync != Vsyncs.Off)
{
if (UserSettings.All.FfmpegVersion == SupportedFFmpegVersions.Version6)
firstPass += "-fps_mode " + gifPreset.Vsync.GetLowerDescription();
else
firstPass += "-vsync " + gifPreset.Vsync.GetLowerDescription();
}
firstPass += " {O}";
}
break;
......@@ -1473,10 +1481,6 @@ internal class EncodingManager
firstPass = apngPreset.Parameters.Replace("\n", " ").Replace("\r", "");
else
{
//Vsync
if (apngPreset.Vsync != Vsyncs.Off)
firstPass += $"-vsync {apngPreset.Vsync.ToString().ToLower()} ";
//Input and loop.
firstPass += "{I} ";
firstPass += $"-plays {(apngPreset.Looped ? apngPreset.RepeatForever ? 0 : apngPreset.RepeatCount : -1)} ";
......@@ -1494,7 +1498,18 @@ internal class EncodingManager
firstPass += $"-r {(apngPreset.Framerate == Framerates.Custom ? apngPreset.CustomFramerate.ToString(CultureInfo.InvariantCulture) : apngPreset.Framerate.GetLowerDescription())} ";
//Format and output.
firstPass += "-f apng {O}";
firstPass += "-f apng ";
//Vsync
if (apngPreset.Vsync != Vsyncs.Off)
{
if (UserSettings.All.FfmpegVersion == SupportedFFmpegVersions.Version6)
firstPass += "-fps_mode " + apngPreset.Vsync.GetLowerDescription();
else
firstPass += "-vsync " + apngPreset.Vsync.GetLowerDescription();
}
firstPass += " {O}";
}
break;
......@@ -1540,7 +1555,18 @@ internal class EncodingManager
firstPass += $"-r {(webpPreset.Framerate == Framerates.Custom ? webpPreset.CustomFramerate.ToString(CultureInfo.InvariantCulture) : webpPreset.Framerate.GetLowerDescription())} ";
//Format and output.
firstPass += "-f webp {O}";
firstPass += "-f webp ";
//Vsync
if (webpPreset.Vsync != Vsyncs.Off)
{
if (UserSettings.All.FfmpegVersion == SupportedFFmpegVersions.Version6)
firstPass += "-fps_mode " + webpPreset.Vsync.GetLowerDescription();
else
firstPass += "-vsync " + webpPreset.Vsync.GetLowerDescription();
}
firstPass += " {O}";
}
break;
......@@ -1571,10 +1597,6 @@ internal class EncodingManager
}
else
{
//Vsync
if (videoPreset.Vsync != Vsyncs.Off)
firstPass += $"-vsync {videoPreset.Vsync.ToString().ToLower()} ";
//Hardware acceleration.
if (videoPreset.HardwareAcceleration != HardwareAccelerationModes.Off)
firstPass += "-hwaccel auto ";
......@@ -1649,7 +1671,17 @@ internal class EncodingManager
//Format and output.
firstPass += $"-f {preset.Type.ToString().ToLower().Replace("mkv", "matroska")} ";
firstPass += "{O}";
//Vsync
if (videoPreset.Vsync != Vsyncs.Off)
{
if (UserSettings.All.FfmpegVersion == SupportedFFmpegVersions.Version6)
firstPass += "-fps_mode " + videoPreset.Vsync.GetLowerDescription();
else
firstPass += "-vsync " + videoPreset.Vsync.GetLowerDescription();
}
firstPass += " {O}";
//Second pass, using a similar command with some adjustments.
if (videoPreset.Pass > 1)
......
......@@ -1564,8 +1564,16 @@
ToolTip="{DynamicResource S.Options.Storage.Paths.Browse}" ToolTipService.Placement="Top" ToolTipService.HorizontalOffset="-5" Command="{StaticResource Command.BrowseFfmpeg}"/>
</Grid>
<n:LabelSeparator Grid.Row="4" Text="{DynamicResource S.Options.Extras.GifskiLocation}"/>
<Grid Grid.Row="5">
<n:LabelSeparator Grid.Row="4" Text="{DynamicResource S.Options.Extras.FfmpegVersion}"/>
<ComboBox Grid.Row="5" Margin="10,3,0,3" MinWidth="120" VerticalAlignment="Center" HorizontalAlignment="Left"
SelectedIndex="{Binding Path=FfmpegVersion, Converter={StaticResource EnumToInt}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<ComboBoxItem Content="v6"/>
<ComboBoxItem Content="v5"/>
<ComboBoxItem Content="v4"/>
</ComboBox>
<n:LabelSeparator Grid.Row="6" Text="{DynamicResource S.Options.Extras.GifskiLocation}"/>
<Grid Grid.Row="7">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="30"/>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册