Skip to content
Open
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
6 changes: 4 additions & 2 deletions Hudl.FFmpeg.Core/Hudl.FFmpeg.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<VersionPrefix>7.0.0</VersionPrefix>
<FileVersion>7.0.0</FileVersion>
<FileVersion>8.0.0</FileVersion>
<!-- The AssemblyVersion should only be updated on a Major version bump -->
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<TargetFramework>netstandard2.0</TargetFramework>
Expand All @@ -18,10 +18,12 @@
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<LangVersion>10</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="log4net" Version="2.0.8" />
<PackageReference Include="log4net" Version="3.0.1" />
</ItemGroup>

</Project>
5 changes: 0 additions & 5 deletions Hudl.FFmpeg.Core/packages.config

This file was deleted.

213 changes: 106 additions & 107 deletions Hudl.FFmpeg/Command/Utility/CommandHelperUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,152 +8,151 @@
using Hudl.FFmpeg.Settings;
using Hudl.FFmpeg.Settings.BaseTypes;

namespace Hudl.FFmpeg.Command.Utility
namespace Hudl.FFmpeg.Command.Utility;

internal class CommandHelperUtility
{
internal class CommandHelperUtility
public static bool ReceiptBelongsToCommand(FFmpegCommand command, StreamIdentifier streamId)
{
public static bool ReceiptBelongsToCommand(FFmpegCommand command, StreamIdentifier streamId)
return command.Owner.Id == streamId.FactoryId
&& command.Id == streamId.CommandId;
}

public static int IndexOfFilterchain(FFmpegCommand command, StreamIdentifier streamId)
{
var matchingFilterchain = FilterchainFromStreamIdentifier(command, streamId);
if (matchingFilterchain == null)
{
return command.Owner.Id == streamId.FactoryId
&& command.Id == streamId.CommandId;
return -1;
}

public static int IndexOfFilterchain(FFmpegCommand command, StreamIdentifier streamId)
{
var matchingFilterchain = FilterchainFromStreamIdentifier(command, streamId);
if (matchingFilterchain == null)
{
return -1;
}
return command.Filtergraph.IndexOf(matchingFilterchain);
}

return command.Filtergraph.IndexOf(matchingFilterchain);
public static int IndexOfResource(FFmpegCommand command, StreamIdentifier streamId)
{
var matchingResource = CommandInputFromStreamIdentifier(command, streamId);
if (matchingResource == null)
{
return -1;
}

public static int IndexOfResource(FFmpegCommand command, StreamIdentifier streamId)
{
var matchingResource = CommandInputFromStreamIdentifier(command, streamId);
if (matchingResource == null)
{
return -1;
}
return command.Inputs.IndexOf(matchingResource);
}

return command.Inputs.IndexOf(matchingResource);
public static int IndexOfOutput(FFmpegCommand command, StreamIdentifier streamId)
{
var matchingOutput = CommandOutputFromStreamIdentifier(command, streamId);
if (matchingOutput == null)
{
return -1;
}

public static int IndexOfOutput(FFmpegCommand command, StreamIdentifier streamId)
{
var matchingOutput = CommandOutputFromStreamIdentifier(command, streamId);
if (matchingOutput == null)
{
return -1;
}
return command.Outputs.IndexOf(matchingOutput);
}

return command.Outputs.IndexOf(matchingOutput);
public static IStream StreamFromStreamIdentifier(FFmpegCommand command, StreamIdentifier streamId)
{
var commandInput = CommandInputFromStreamIdentifier(command, streamId);
if (commandInput != null)
{
return commandInput.Resource.Streams.FirstOrDefault(si => si.Map == streamId.Map);
}

public static IStream StreamFromStreamIdentifier(FFmpegCommand command, StreamIdentifier streamId)
var commandOutput = CommandOutputFromStreamIdentifier(command, streamId);
if (commandOutput != null)
{
var commandInput = CommandInputFromStreamIdentifier(command, streamId);
if (commandInput != null)
{
return commandInput.Resource.Streams.FirstOrDefault(si => si.Map == streamId.Map);
}

var commandOutput = CommandOutputFromStreamIdentifier(command, streamId);
if (commandOutput != null)
{
return commandOutput.Resource.Streams.FirstOrDefault(si => si.Map == streamId.Map);
}

var filterchain = FilterchainFromStreamIdentifier(command, streamId);
if (filterchain != null)
{
var filterchainOutput = filterchain.OutputList.First(si => si.Stream.Map == streamId.Map);

return filterchainOutput.Stream;
}

throw new StreamNotFoundException();
return commandOutput.Resource.Streams.FirstOrDefault(si => si.Map == streamId.Map);
}

public static CommandInput CommandInputFromStreamIdentifier(FFmpegCommand command, StreamIdentifier streamId)
var filterchain = FilterchainFromStreamIdentifier(command, streamId);
if (filterchain != null)
{
if (streamId == null)
{
throw new ArgumentNullException("streamId");
}
var filterchainOutput = filterchain.OutputList.First(si => si.Stream.Map == streamId.Map);

return command.Objects.Inputs.FirstOrDefault(i => i.GetStreamIdentifiers().Any(si => si.Map == streamId.Map));
return filterchainOutput.Stream;
}

public static CommandOutput CommandOutputFromStreamIdentifier(FFmpegCommand command, StreamIdentifier streamId)
{
if (streamId == null)
{
throw new ArgumentNullException("streamId");
}
throw new StreamNotFoundException();
}

return command.Objects.Outputs.FirstOrDefault(i => i.GetStreamIdentifiers().Any(si => si.Map == streamId.Map));
public static CommandInput CommandInputFromStreamIdentifier(FFmpegCommand command, StreamIdentifier streamId)
{
if (streamId == null)
{
throw new ArgumentNullException("streamId");
}

public static Filterchain FilterchainFromStreamIdentifier(FFmpegCommand command, StreamIdentifier streamId)
{
if (streamId == null)
{
throw new ArgumentNullException("streamId");
}
return command.Objects.Inputs.FirstOrDefault(i => i.GetStreamIdentifiers().Any(si => si.Map == streamId.Map));
}

return command.Objects.Filtergraph.FilterchainList.FirstOrDefault(f => f.GetStreamIdentifiers().Any(r => r.Equals(streamId)));
public static CommandOutput CommandOutputFromStreamIdentifier(FFmpegCommand command, StreamIdentifier streamId)
{
if (streamId == null)
{
throw new ArgumentNullException("streamId");
}

public static CommandOutput SetupCommandOutputMaps<TOutputType>(CommandStage stage, SettingsCollection settings, string fileName)
where TOutputType : class, IContainer, new()
{
var settingsCopy = settings.Copy();
var commandOutput = CommandOutput.Create(Resource.CreateOutput<TOutputType>(), settingsCopy);
return command.Objects.Outputs.FirstOrDefault(i => i.GetStreamIdentifiers().Any(si => si.Map == streamId.Map));
}

stage.StreamIdentifiers.ForEach(streamId =>
{
var theStream = StreamFromStreamIdentifier(stage.Command, streamId);
var theResource = CommandInputFromStreamIdentifier(stage.Command, streamId);
public static Filterchain FilterchainFromStreamIdentifier(FFmpegCommand command, StreamIdentifier streamId)
{
if (streamId == null)
{
throw new ArgumentNullException("streamId");
}

if (theResource == null)
{
commandOutput.Settings.Merge(new Map(streamId), FFmpegMergeOptionType.NewWins);
}
else
{
var resourceIndex = IndexOfResource(stage.Command, streamId);
return command.Objects.Filtergraph.FilterchainList.FirstOrDefault(f => f.GetStreamIdentifiers().Any(r => r.Equals(streamId)));
}

commandOutput.Settings.Merge(new Map(string.Format("{0}:{1}", resourceIndex, theStream.ResourceIndicator)),
FFmpegMergeOptionType.NewWins);
}
public static CommandOutput SetupCommandOutputMaps<TOutputType>(CommandStage stage, SettingsCollection settings, string fileName)
where TOutputType : class, IContainer, new()
{
var settingsCopy = settings.Copy();
var commandOutput = CommandOutput.Create(Resource.CreateOutput<TOutputType>(), settingsCopy);

commandOutput.Resource.Streams.Add(theStream.Copy());
});
stage.StreamIdentifiers.ForEach(streamId =>
{
var theStream = StreamFromStreamIdentifier(stage.Command, streamId);
var theResource = CommandInputFromStreamIdentifier(stage.Command, streamId);

if (!string.IsNullOrWhiteSpace(fileName))
if (theResource == null)
{
commandOutput.Resource.Name = fileName;
commandOutput.Settings.Merge(new Map(streamId), FFmpegMergeOptionType.NewWins);
}
else
{
var resourceIndex = IndexOfResource(stage.Command, streamId);

return commandOutput;
}
commandOutput.Settings.Merge(new Map(string.Format("{0}:{1}", resourceIndex, theStream.ResourceIndicator)),
FFmpegMergeOptionType.NewWins);
}

commandOutput.Resource.Streams.Add(theStream.Copy());
});

public static CommandOutput SetupCommandOutput<TOutputType>(FFmpegCommand command, SettingsCollection settings, string fileName)
where TOutputType : class, IContainer, new()
if (!string.IsNullOrWhiteSpace(fileName))
{
var settingsCopy = settings.Copy();
var commandOutput = CommandOutput.Create(Resource.CreateOutput<TOutputType>(), settingsCopy);
commandOutput.Resource.Name = fileName;
}

commandOutput.Resource.Streams.AddRange(command.Inputs.SelectMany(i => i.Resource.Streams.Select(s => s.Copy())));
return commandOutput;
}

if (!string.IsNullOrWhiteSpace(fileName))
{
commandOutput.Resource.Name = fileName;
}
public static CommandOutput SetupCommandOutput<TOutputType>(FFmpegCommand command, SettingsCollection settings, string fileName)
where TOutputType : class, IContainer, new()
{
var settingsCopy = settings.Copy();
var commandOutput = CommandOutput.Create(Resource.CreateOutput<TOutputType>(), settingsCopy);

commandOutput.Resource.Streams.AddRange(command.Inputs.SelectMany(i => i.Resource.Streams.Select(s => s.Copy())));

return commandOutput;
if (!string.IsNullOrWhiteSpace(fileName))
{
commandOutput.Resource.Name = fileName;
}

return commandOutput;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
<iconUrl>https://raw.githubusercontent.com/hudl/HudlFfmpeg/master/hudl.png</iconUrl>
</metadata>
<files>
<file src="bin\Release\$id$.dll" target="lib\net45"/>
<file src="bin\Release\$id$.pdb" target="lib\net45"/>
<file src="bin\Release\Hudl.FFmpeg.Core.dll" target="lib\net45"/>
<file src="bin\Release\Hudl.FFmpeg.Core.pdb" target="lib\net45"/>
<file src="bin\Release\Hudl.FFprobe.dll" target="lib\net45"/>
<file src="bin\Release\Hudl.FFprobe.pdb" target="lib\net45"/>
<file src="bin\Release\$id$.dll" target="lib\netstandard2.0"/>
<file src="bin\Release\$id$.pdb" target="lib\netstandard2.0"/>
<file src="bin\Release\Hudl.FFmpeg.Core.dll" target="lib\netstandard2.0"/>
<file src="bin\Release\Hudl.FFmpeg.Core.pdb" target="lib\netstandard2.0"/>
<file src="bin\Release\Hudl.FFprobe.dll" target="lib\netstandard2.0"/>
<file src="bin\Release\Hudl.FFprobe.pdb" target="lib\netstandard2.0"/>
</files>
</package>
8 changes: 5 additions & 3 deletions Hudl.FFmpeg/Hudl.Ffmpeg.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<VersionPrefix>7.0.0</VersionPrefix>
<FileVersion>7.0.0</FileVersion>
<FileVersion>8.0.0</FileVersion>
<!-- The AssemblyVersion should only be updated on a Major version bump -->
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<TargetFramework>netstandard2.0</TargetFramework>
Expand All @@ -18,11 +18,13 @@
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<LangVersion>10</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="log4net" Version="2.0.8" />
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Include="log4net" Version="3.0.1" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 0 additions & 5 deletions Hudl.FFmpeg/packages.config

This file was deleted.

15 changes: 7 additions & 8 deletions Hudl.FFprobe/CodecTypes.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
namespace Hudl.FFmpeg.Metadata.FFprobe.BaseTypes
namespace Hudl.FFprobe;

internal enum CodecTypes
{
internal enum CodecTypes
{
Video,
Audio,
Data,
}
}
Video,
Audio,
Data,
}
12 changes: 12 additions & 0 deletions Hudl.FFprobe/CodecTypesUtility.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Hudl.FFprobe;

internal static class CodecTypesUtility
{
public static CodecTypes? GetCodecTypeFromMediaType(string? mediaType) => mediaType?.ToLowerInvariant()?.Trim() switch
{
"video" => CodecTypes.Video,
"audio" => CodecTypes.Audio,
"data" => CodecTypes.Data,
_ => null,
};
}
Loading