Skip to content

Commit 4e11aec

Browse files
committed
Added Vorbis to audio codecs
1 parent c0bf6ab commit 4e11aec

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

ff-utils-winforms/Data/CodecUtils.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class CodecUtils
2020

2121
public enum Av1anCodec { AomAv1, SvtAv1, Vpx, X265 };
2222
public enum VideoCodec { CopyVideo, StripVideo, Libx264, Libx265, H264Nvenc, H265Nvenc, LibVpx, LibSvtAv1, Gif, Png, Jpg };
23-
public enum AudioCodec { CopyAudio, StripAudio, Aac, Opus, Mp3, Flac };
23+
public enum AudioCodec { CopyAudio, StripAudio, Aac, Opus, Vorbis, Mp3, Flac };
2424
public enum SubtitleCodec { CopySubs, StripSubs, MovText, Srt, WebVtt };
2525

2626
public static IEncoder GetCodec(VideoCodec c)
@@ -54,6 +54,7 @@ public static IEncoder GetCodec(AudioCodec c)
5454
if (c == AudioCodec.CopyAudio) return new CopyAudio();
5555
if (c == AudioCodec.Aac) return new Aac();
5656
if (c == AudioCodec.Opus) return new Opus();
57+
if (c == AudioCodec.Vorbis) return new Vorbis();
5758
if (c == AudioCodec.Mp3) return new Mp3();
5859
if (c == AudioCodec.Flac) return new Flac();
5960
return null;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using Nmkoder.Extensions;
2+
using Nmkoder.IO;
3+
using System;
4+
using System.Collections.Generic;
5+
6+
namespace Nmkoder.Data.Codecs
7+
{
8+
class Vorbis : IEncoder
9+
{
10+
public Streams.Stream.StreamType Type { get; } = Streams.Stream.StreamType.Audio;
11+
public string Name { get { return GetType().Name; } }
12+
public string FriendlyName { get; } = "Vorbis";
13+
public string[] Presets { get; }
14+
public int PresetDefault { get; }
15+
public string[] ColorFormats { get; }
16+
public int ColorFormatDefault { get; }
17+
public int QMin { get; } = 32;
18+
public int QMax { get; } = 640;
19+
public int QDefault { get; } = 192;
20+
public string QInfo { get; }
21+
public string PresetInfo { get; }
22+
23+
public bool SupportsTwoPass { get; } = false;
24+
public bool DoesNotEncode { get; } = false;
25+
public bool IsFixedFormat { get; } = false;
26+
public bool IsSequence { get; } = false;
27+
28+
public CodecArgs GetArgs(Dictionary<string, string> encArgs = null, MediaFile mediaFile = null, Pass pass = Pass.OneOfOne)
29+
{
30+
string bitrate = encArgs.ContainsKey("bitrate") ? encArgs["bitrate"] : "96k";
31+
string channels = encArgs.ContainsKey("ac") ? encArgs["ac"] : "2";
32+
List<string> extraArgs = new List<string>();
33+
return new CodecArgs($"-c:a libvorbis {CodecUtils.GetAudioArgsForEachStream(mediaFile, bitrate.GetInt(), channels.GetInt(), extraArgs)}");
34+
}
35+
}
36+
}

ff-utils-winforms/Data/Containers.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ public static AC[] GetSupportedAudioCodecs(Container c)
3636
return new AC[] { AC.Aac, AC.Mp3 };
3737

3838
if (c == Container.Mkv)
39-
return new AC[] { AC.Aac, AC.Opus, AC.Mp3, AC.Flac };
39+
return new AC[] { AC.Aac, AC.Opus, AC.Vorbis, AC.Mp3, AC.Flac };
4040

4141
if (c == Container.Webm)
42-
return new AC[] { AC.Opus };
42+
return new AC[] { AC.Opus, AC.Vorbis };
4343

4444
if (c == Container.Mov)
4545
return new AC[] { AC.Aac, AC.Mp3 };
@@ -48,7 +48,7 @@ public static AC[] GetSupportedAudioCodecs(Container c)
4848
return new AC[] { AC.Aac };
4949

5050
if (c == Container.Ogg)
51-
return new AC[] { AC.Opus };
51+
return new AC[] { AC.Opus, AC.Vorbis };
5252

5353
return new AC[0];
5454
}

ff-utils-winforms/Nmkoder.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@
259259
<Compile Include="Data\Codecs\Audio\Flac.cs" />
260260
<Compile Include="Data\Codecs\Audio\Mp3.cs" />
261261
<Compile Include="Data\Codecs\Audio\Opus.cs" />
262+
<Compile Include="Data\Codecs\Audio\Vorbis.cs" />
262263
<Compile Include="Data\Codecs\IEncoder.cs" />
263264
<Compile Include="Data\Codecs\Audio\StripAudio.cs" />
264265
<Compile Include="Data\Codecs\Subs\MovText.cs" />

0 commit comments

Comments
 (0)