Skip to content
Merged

Gpu #11

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SimpleFFmpegGUI.Core/FFmpegLib/AomAV1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SimpleFFmpegGUI.FFmpegLib
{
public class AomAV1 : VideoCodec
public class AomAV1 : SoftwareVideoCodec
{
public override string Name => "AV1 (aom)";
public override string Lib => "libaom-av1";
Expand Down
10 changes: 10 additions & 0 deletions SimpleFFmpegGUI.Core/FFmpegLib/FFmpegEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ public class FFmpegEnums
"veryfast",
"superfast",
"ultrafast",
};

public readonly static string[] N_Presets = new[] {
"p7",
"p6",
"p5",
"p4",
"p3",
"p2",
"p1",
};

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion SimpleFFmpegGUI.Core/FFmpegLib/GeneralVideoCodec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace SimpleFFmpegGUI.FFmpegLib
{
public class GeneralVideoCodec : VideoCodec
public class GeneralVideoCodec : SoftwareVideoCodec
{
public override int DefaultCRF => 5;
public override int DefaultSpeedLevel => 3;
Expand Down
19 changes: 19 additions & 0 deletions SimpleFFmpegGUI.Core/FFmpegLib/HardwareVideoCodec.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using SimpleFFmpegGUI.FFmpegArgument;

namespace SimpleFFmpegGUI.FFmpegLib
{
public abstract class HardwareVideoCodec : VideoCodec
{
public override string CrfLabel => "CQ";

public override FFmpegArgumentItem CRF(int level)
{
if (level < 0 || level > MaxCRF)
{
throw new FFmpegArgumentException("CQ的值超出范围");
}
return new FFmpegArgumentItem("cq", level.ToString());
}
}

}
13 changes: 13 additions & 0 deletions SimpleFFmpegGUI.Core/FFmpegLib/N_AV1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using FFMpegCore.Enums;

namespace SimpleFFmpegGUI.FFmpegLib
{
public class N_AV1 : N_VideoCodec
{
public override int DefaultCRF => 35;
public override int MaxCRF => 63;
public override string Name => "AV1 (Nvdia)";
public override string Lib => "av1_nvenc";
}

}
11 changes: 11 additions & 0 deletions SimpleFFmpegGUI.Core/FFmpegLib/N_H264.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace SimpleFFmpegGUI.FFmpegLib
{
public class N_H264 : N_VideoCodec
{
public override int DefaultCRF => 28;
public override int MaxCRF => 51;
public override string Name => "H264 (Nvdia)";
public override string Lib => "h264_nvenc";
}

}
11 changes: 11 additions & 0 deletions SimpleFFmpegGUI.Core/FFmpegLib/N_H265.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace SimpleFFmpegGUI.FFmpegLib
{
public class N_H265 : N_VideoCodec
{
public override int DefaultCRF => 28;
public override int MaxCRF => 51;
public override string Name => "H265 (Nvdia)";
public override string Lib => "hevc_nvenc";
}

}
10 changes: 10 additions & 0 deletions SimpleFFmpegGUI.Core/FFmpegLib/N_VideoCodec.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace SimpleFFmpegGUI.FFmpegLib
{
public abstract class N_VideoCodec : HardwareVideoCodec
{
public override int MaxSpeedLevel => FFmpegEnums.N_Presets.Length - 1;
public override int DefaultSpeedLevel => 3;
public override double[] SpeedFPSRelationship => throw new System.NotImplementedException();
}

}
2 changes: 1 addition & 1 deletion SimpleFFmpegGUI.Core/FFmpegLib/SVTAV1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace SimpleFFmpegGUI.FFmpegLib
{
public class SVTAV1 : VideoCodec
public class SVTAV1 : SoftwareVideoCodec
{
public override string Name => "AV1 (SVT)";
public override string Lib => "libsvtav1";
Expand Down
19 changes: 19 additions & 0 deletions SimpleFFmpegGUI.Core/FFmpegLib/SoftwareVideoCodec.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using SimpleFFmpegGUI.FFmpegArgument;

namespace SimpleFFmpegGUI.FFmpegLib
{
public abstract class SoftwareVideoCodec : VideoCodec
{
public override string CrfLabel => "CRF";

public override FFmpegArgumentItem CRF(int level)
{
if (level < 0 || level > MaxCRF)
{
throw new FFmpegArgumentException("CRF的值超出范围");
}
return new FFmpegArgumentItem("crf", level.ToString());
}
}

}
24 changes: 14 additions & 10 deletions SimpleFFmpegGUI.Core/FFmpegLib/VideoCodec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,20 @@ public abstract class VideoCodec : CodecBase
public static readonly XVP9 XVP9 = new XVP9();
public static readonly AomAV1 AomAV1 = new AomAV1();
public static readonly SVTAV1 SVTAV1 = new SVTAV1();
public static readonly N_AV1 N_AV1 = new N_AV1();
public static readonly N_H264 N_H264 = new N_H264();
public static readonly N_H265 N_H265 = new N_H265();
public static readonly GeneralVideoCodec General = new GeneralVideoCodec();
public static readonly VideoCodec[] VideoCodecs = new VideoCodec[]
{
X264,
X265,
XVP9,
AomAV1,
SVTAV1
SVTAV1,
N_H264,
N_H265,
N_AV1
};
private static Dictionary<string, VideoCodec> name2codec;

Expand All @@ -40,6 +46,11 @@ public static VideoCodec GetCodec(string name)
/// </summary>
public abstract int DefaultCRF { get; }

/// <summary>
/// CRF的名字,软件编码中为CRF,硬件编码中为CQ
/// </summary>
public abstract string CrfLabel { get; }

/// <summary>
/// 默认速度预设等级
/// </summary>
Expand Down Expand Up @@ -92,15 +103,8 @@ public virtual FFmpegArgumentItem BufferSize(double mb)
return new FFmpegArgumentItem("bufsize", $"{mb}M");
}

public virtual FFmpegArgumentItem CRF(int level)
{
if (level < 0 || level > MaxCRF)
{
throw new FFmpegArgumentException("CRF的值超出范围");
}
return new FFmpegArgumentItem("crf", level.ToString());
}

public abstract FFmpegArgumentItem CRF(int level);

public virtual FFmpegArgumentItem FrameRate(double fps)
{
if (fps < 0)
Expand Down
2 changes: 1 addition & 1 deletion SimpleFFmpegGUI.Core/FFmpegLib/X264.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace SimpleFFmpegGUI.FFmpegLib
{
public class X264 : VideoCodec
public class X264 : SoftwareVideoCodec
{
public readonly static string[] Profiles = new string[]
{
Expand Down
2 changes: 1 addition & 1 deletion SimpleFFmpegGUI.Core/FFmpegLib/X265.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace SimpleFFmpegGUI.FFmpegLib
{
public class X265 : VideoCodec
public class X265 : SoftwareVideoCodec
{
public readonly static string[] Profiles = new string[]
{
Expand Down
2 changes: 1 addition & 1 deletion SimpleFFmpegGUI.Core/FFmpegLib/XVP9.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace SimpleFFmpegGUI.FFmpegLib
{
public class XVP9 : VideoCodec
public class XVP9 : SoftwareVideoCodec
{
public override string Name => "VP9";
public override string Lib => "libvpx-vp9";
Expand Down
24 changes: 24 additions & 0 deletions SimpleFFmpegGUI.Core/TaskEnqueueStrategy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SimpleFFmpegGUI
{
public enum TaskEnqueueStrategy
{
/// <summary>
/// 仅加入队列
/// </summary>
EnqueueOnly,
/// <summary>
/// 加入并开始队列
/// </summary>
EnqueueAndRun,
/// <summary>
/// 加入队列并独立执行
/// </summary>
RunIndependently
}
}
1 change: 1 addition & 0 deletions SimpleFFmpegGUI.WPF/CutWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
<Slider
Grid.Column="2"
VerticalAlignment="Bottom"
AutoToolTipPlacement="None"
IsMoveToPointEnabled="True"
IsSelectionRangeEnabled="True"
Maximum="1"
Expand Down
4 changes: 3 additions & 1 deletion SimpleFFmpegGUI.WPF/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@
Background="Transparent"
SelectionChanged="Tab_SelectionChanged"
Visibility="{Binding TabControlVisibility}">
<TabItem Header="任务状态" />
<TabItem
Header="任务状态"
Tag="status" />
</TabControl>
<ContentControl
x:Name="topTab"
Expand Down
5 changes: 4 additions & 1 deletion SimpleFFmpegGUI.WPF/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
using System.Windows.Shapes;
using CommonDialog = iNKORE.Extension.CommonDialog.CommonDialog;
using Task = System.Threading.Tasks.Task;
using iNKORE.UI.WPF.Modern.Controls.Helpers;

namespace SimpleFFmpegGUI.WPF
{
Expand Down Expand Up @@ -364,7 +365,9 @@ private void RegisterMessages()

private void ResetUI(bool force = false)
{
if (tab.SelectedIndex == 0 && !topTab.HasContent
if (tab.SelectedIndex == 0 //选中了第一个标签页
&& "status".Equals((tab.Items[0] as FrameworkElement).Tag)//第一个标签页没被移除
&& !topTab.HasContent//没有在显示顶部页面
&& (IsUiCompressMode || force)) //左侧和右侧
{
RemoveFromGrid();
Expand Down
12 changes: 10 additions & 2 deletions SimpleFFmpegGUI.WPF/Pages/AddTaskPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
x:Class="SimpleFFmpegGUI.WPF.Pages.AddTaskPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:c="clr-namespace:SimpleFFmpegGUI;assembly=SimpleFFmpegGUI.Core"
xmlns:converters="clr-namespace:SimpleFFmpegGUI.WPF.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SimpleFFmpegGUI.WPF.Pages"
Expand Down Expand Up @@ -151,14 +152,21 @@
Command="{Binding AddToQueueCommand}"
Header="仅创建任务">
<MenuItem.CommandParameter>
<system:Boolean>false</system:Boolean>
<c:TaskEnqueueStrategy>EnqueueOnly</c:TaskEnqueueStrategy>
</MenuItem.CommandParameter>
</MenuItem>
<MenuItem
Command="{Binding AddToQueueCommand}"
Header="创建并启动队列">
<MenuItem.CommandParameter>
<system:Boolean>true</system:Boolean>
<c:TaskEnqueueStrategy>EnqueueAndRun</c:TaskEnqueueStrategy>
</MenuItem.CommandParameter>
</MenuItem>
<MenuItem
Command="{Binding AddToQueueCommand}"
Header="创建并独立执行">
<MenuItem.CommandParameter>
<c:TaskEnqueueStrategy>RunIndependently</c:TaskEnqueueStrategy>
</MenuItem.CommandParameter>
</MenuItem>
</ui:MenuFlyout>
Expand Down
6 changes: 5 additions & 1 deletion SimpleFFmpegGUI.WPF/Panels/CodeArgumentsPanel.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,11 @@
Grid.Row="4"
IsChecked="{Binding Video.EnableCrf}"
ToolTip="{Binding Source={x:Static vm:ArgumentDescriptions.CRF}}">
<TextBlock Text="{Binding Video.Crf, Mode=OneWay, StringFormat=CRF: {0}}" />
<TextBlock>
<Run Text="{Binding Video.CrfLabel, Mode=OneWay}" />
<Run Text=":" />
<Run Text="{Binding Video.Crf, Mode=OneWay}" />
</TextBlock>
</CheckBox>
<Slider
Grid.Row="4"
Expand Down
3 changes: 1 addition & 2 deletions SimpleFFmpegGUI.WPF/Panels/StatusPanel.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,7 @@
Grid.Column="2"
Background="Transparent"
DockPanel.Dock="Bottom">
<ui:AppBarButton
Label="输出">
<ui:AppBarButton Label="输出">
<ui:FlyoutService.Flyout>
<ui:Flyout>
<TextBlock
Expand Down
Loading