FFMpegCore/FFMpegCore.Test/ArgumentBuilderTest.cs

535 lines
23 KiB
C#
Raw Normal View History

V.5.0.0 (#391) * Move NotifyOnProgress processing to ErrorData * added HighPass filter, LowPass filter, Audiogate and Silencedetection * re-added corresponding AudioFilterOptions * Update LICENSE * Update ci.yml * Fix argument * Bump action versions * Ignore Uri_Duration until root cause found * Use action that can install specific ffmpeg version * Remove ignore * Revert "Remove ignore" This reverts commit d85a4b81abaf4ab7832020cdb2ccfb46758d3bde. * Bump dependencies * Use setup-dotnet@v2 since v3 seems to install .NET 7 * Init * WIP * Add Directory.Build.props * Add SupportedOSPlatform attribute on tests using SDC * Fix using temporarily * Add IgnoreIf attribute to only run SDC tests on Windows * Cleanup pipelines * Cleanup * Cleanup using directives * More cleanup * Simplify attribute * Fix attribute * Add missing test file * Added blackdetect and blackframe arguments * Added log levels * Add missing using directive after rebase * fix extension is not png lost path * Apply fix to methods in new location * Add Uri support for Frame Analysis, skipped Stream support as this cannot support MP4's with moov atom in the end of the file, and input pipes do not support seek. * Add select multiple streams * Add other stream types to Channel (V,s,d,t) * Add negative mapping to select stream (deselect) * Update test * Add pad video filter * Update PipeHelpers.cs * Fix GetPipePath() for MacOS * Add SampleAspectRatio property to VideoStream * Update year * Always use Path.GetTempPath() on linux and macos * Use FedericoCarboni/setup-ffmpeg@v2 * Include macos in ci matrix * AddDeviceInput similar to AddFileInput and FromDeviceInput * fixed hwaccel parameter not working in 5.0 * a hack to unconditionally kill ffmpeg when parent .NET process exits * Remove PInvoke.Kernel32 * Remove unneeded cast * Update test * Added ability to retrieve bit depth from media streams for lossless encodings (#359) * Added ability to retrieve bit depth from media streams for lossless encodings * Shortened sample AIFF file used in tests * Cleanup after splitting into two packages (#386) * Move PosterWithAudio to FFMpegCore * Reduce windows only tests * Update Directory.Build.props * Create .editorconfig * More cleanup * Enable implicit usings * Remove unused method * Apply dotnet format * Fix unused variable in AudioGateArgument * Fix boolean conditions in AudioGateArgument * Merge boolean conditions into pattern * Use target-typed new * Add linting to CI * Add CUDA to HardwareAccelerationDevice enum * Increase timeout for Video_Join_Image_Sequence * Adjust Video_Join_Image_Sequence timeout * Fix expected seconds in Video_Join_Image_Sequence * Increase timeout for Video_TranscodeToMemory due to macos agents * fix: Switch source for rotation property from 'tags/rotate' to 'side_data_list/rotation' (incl. test case) (#388) * Init (#389) * build master branch after merge or push (#390) * Update ci.yml * Add codecov * Remove codecov for now * Add coverlet.collector and codecov --------- Co-authored-by: keg247 <44041557+keg247@users.noreply.github.com> Co-authored-by: Wilbert Bongers <msdnwilbert@muziekweb.nl> Co-authored-by: Artemii Gazizianov <107502822+ArtemiiimetrA@users.noreply.github.com> Co-authored-by: Thodoris Koskinopoulos <me@koskit.me> Co-authored-by: 赵宁 <602726286@qq.com> Co-authored-by: jeroenvanderschoot <jeroen.vanderschoot@kinetiq.tv> Co-authored-by: Sky Z <qe201020335@sina.com> Co-authored-by: Gleb Moskalenko <gleb.moskalenko.general@gmail.com> Co-authored-by: ep1kt3t0s <86835785+ep1kt3t0s@users.noreply.github.com> Co-authored-by: Victor Nova <lostfreeman@gmail.com> Co-authored-by: Tom Bogle <tom_bogle@sil.org> Co-authored-by: pklaes <10601494+pklaes@users.noreply.github.com>
2023-02-05 00:29:37 +01:00
using FFMpegCore.Arguments;
2020-05-09 17:53:03 +02:00
using FFMpegCore.Enums;
V.5.0.0 (#391) * Move NotifyOnProgress processing to ErrorData * added HighPass filter, LowPass filter, Audiogate and Silencedetection * re-added corresponding AudioFilterOptions * Update LICENSE * Update ci.yml * Fix argument * Bump action versions * Ignore Uri_Duration until root cause found * Use action that can install specific ffmpeg version * Remove ignore * Revert "Remove ignore" This reverts commit d85a4b81abaf4ab7832020cdb2ccfb46758d3bde. * Bump dependencies * Use setup-dotnet@v2 since v3 seems to install .NET 7 * Init * WIP * Add Directory.Build.props * Add SupportedOSPlatform attribute on tests using SDC * Fix using temporarily * Add IgnoreIf attribute to only run SDC tests on Windows * Cleanup pipelines * Cleanup * Cleanup using directives * More cleanup * Simplify attribute * Fix attribute * Add missing test file * Added blackdetect and blackframe arguments * Added log levels * Add missing using directive after rebase * fix extension is not png lost path * Apply fix to methods in new location * Add Uri support for Frame Analysis, skipped Stream support as this cannot support MP4's with moov atom in the end of the file, and input pipes do not support seek. * Add select multiple streams * Add other stream types to Channel (V,s,d,t) * Add negative mapping to select stream (deselect) * Update test * Add pad video filter * Update PipeHelpers.cs * Fix GetPipePath() for MacOS * Add SampleAspectRatio property to VideoStream * Update year * Always use Path.GetTempPath() on linux and macos * Use FedericoCarboni/setup-ffmpeg@v2 * Include macos in ci matrix * AddDeviceInput similar to AddFileInput and FromDeviceInput * fixed hwaccel parameter not working in 5.0 * a hack to unconditionally kill ffmpeg when parent .NET process exits * Remove PInvoke.Kernel32 * Remove unneeded cast * Update test * Added ability to retrieve bit depth from media streams for lossless encodings (#359) * Added ability to retrieve bit depth from media streams for lossless encodings * Shortened sample AIFF file used in tests * Cleanup after splitting into two packages (#386) * Move PosterWithAudio to FFMpegCore * Reduce windows only tests * Update Directory.Build.props * Create .editorconfig * More cleanup * Enable implicit usings * Remove unused method * Apply dotnet format * Fix unused variable in AudioGateArgument * Fix boolean conditions in AudioGateArgument * Merge boolean conditions into pattern * Use target-typed new * Add linting to CI * Add CUDA to HardwareAccelerationDevice enum * Increase timeout for Video_Join_Image_Sequence * Adjust Video_Join_Image_Sequence timeout * Fix expected seconds in Video_Join_Image_Sequence * Increase timeout for Video_TranscodeToMemory due to macos agents * fix: Switch source for rotation property from 'tags/rotate' to 'side_data_list/rotation' (incl. test case) (#388) * Init (#389) * build master branch after merge or push (#390) * Update ci.yml * Add codecov * Remove codecov for now * Add coverlet.collector and codecov --------- Co-authored-by: keg247 <44041557+keg247@users.noreply.github.com> Co-authored-by: Wilbert Bongers <msdnwilbert@muziekweb.nl> Co-authored-by: Artemii Gazizianov <107502822+ArtemiiimetrA@users.noreply.github.com> Co-authored-by: Thodoris Koskinopoulos <me@koskit.me> Co-authored-by: 赵宁 <602726286@qq.com> Co-authored-by: jeroenvanderschoot <jeroen.vanderschoot@kinetiq.tv> Co-authored-by: Sky Z <qe201020335@sina.com> Co-authored-by: Gleb Moskalenko <gleb.moskalenko.general@gmail.com> Co-authored-by: ep1kt3t0s <86835785+ep1kt3t0s@users.noreply.github.com> Co-authored-by: Victor Nova <lostfreeman@gmail.com> Co-authored-by: Tom Bogle <tom_bogle@sil.org> Co-authored-by: pklaes <10601494+pklaes@users.noreply.github.com>
2023-02-05 00:29:37 +01:00
using Microsoft.VisualStudio.TestTools.UnitTesting;
2019-02-08 11:19:40 +01:00
2019-03-03 00:33:00 +01:00
namespace FFMpegCore.Test
2019-02-08 11:19:40 +01:00
{
[TestClass]
2020-12-07 00:47:47 +01:00
public class ArgumentBuilderTest
2019-02-08 11:19:40 +01:00
{
2021-03-05 18:06:40 +01:00
private readonly string[] _concatFiles = { "1.mp4", "2.mp4", "3.mp4", "4.mp4" };
2019-02-08 11:19:40 +01:00
[TestMethod]
public void Builder_BuildString_IO_1()
{
2020-10-24 22:31:54 +02:00
var str = FFMpegArguments.FromFileInput("input.mp4").OutputToFile("output.mp4").Arguments;
2020-07-26 02:45:14 +02:00
Assert.AreEqual("-i \"input.mp4\" \"output.mp4\" -y", str);
2019-02-08 11:19:40 +01:00
}
[TestMethod]
public void Builder_BuildString_Scale()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", true, opt => opt
.WithVideoFilters(filterOptions => filterOptions
.Scale(VideoSize.Hd)))
.Arguments;
2021-03-06 21:25:17 +01:00
Assert.AreEqual("-i \"input.mp4\" -vf \"scale=-1:720\" \"output.mp4\" -y", str);
2020-04-30 14:14:10 +02:00
}
2021-03-05 18:06:40 +01:00
2019-02-08 11:19:40 +01:00
[TestMethod]
public void Builder_BuildString_AudioCodec()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", true, opt => opt.WithAudioCodec(AudioCodec.Aac)).Arguments;
2020-07-26 02:45:14 +02:00
Assert.AreEqual("-i \"input.mp4\" -c:a aac \"output.mp4\" -y", str);
2020-05-01 10:07:40 +02:00
}
2021-03-05 18:06:40 +01:00
2020-05-01 10:07:40 +02:00
[TestMethod]
public void Builder_BuildString_AudioBitrate()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", true, opt => opt.WithAudioBitrate(AudioQuality.Normal)).Arguments;
2020-07-26 02:45:14 +02:00
Assert.AreEqual("-i \"input.mp4\" -b:a 128k \"output.mp4\" -y", str);
2020-05-01 10:07:40 +02:00
}
2021-03-05 18:06:40 +01:00
2020-05-01 10:07:40 +02:00
[TestMethod]
public void Builder_BuildString_Quiet()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4").WithGlobalOptions(opt => opt.WithVerbosityLevel())
.OutputToFile("output.mp4", false).Arguments;
2020-10-24 22:31:54 +02:00
Assert.AreEqual("-hide_banner -loglevel error -i \"input.mp4\" \"output.mp4\"", str);
2019-02-08 11:19:40 +01:00
}
2020-04-30 14:14:10 +02:00
[TestMethod]
public void Builder_BuildString_AudioCodec_Fluent()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4").OutputToFile("output.mp4", false,
opt => opt.WithAudioCodec(AudioCodec.Aac).WithAudioBitrate(128)).Arguments;
2020-05-08 11:07:51 +02:00
Assert.AreEqual("-i \"input.mp4\" -c:a aac -b:a 128k \"output.mp4\"", str);
2020-04-30 14:14:10 +02:00
}
2019-02-08 11:19:40 +01:00
[TestMethod]
public void Builder_BuildString_BitStream()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4").OutputToFile("output.mp4", false,
opt => opt.WithBitStreamFilter(Channel.Audio, Filter.H264_Mp4ToAnnexB)).Arguments;
2020-05-08 11:07:51 +02:00
Assert.AreEqual("-i \"input.mp4\" -bsf:a h264_mp4toannexb \"output.mp4\"", str);
2020-04-30 14:14:10 +02:00
}
2021-03-05 18:06:40 +01:00
2020-10-24 23:33:44 +02:00
[TestMethod]
public void Builder_BuildString_HardwareAcceleration_Auto()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt.WithHardwareAcceleration()).Arguments;
V.5.0.0 (#391) * Move NotifyOnProgress processing to ErrorData * added HighPass filter, LowPass filter, Audiogate and Silencedetection * re-added corresponding AudioFilterOptions * Update LICENSE * Update ci.yml * Fix argument * Bump action versions * Ignore Uri_Duration until root cause found * Use action that can install specific ffmpeg version * Remove ignore * Revert "Remove ignore" This reverts commit d85a4b81abaf4ab7832020cdb2ccfb46758d3bde. * Bump dependencies * Use setup-dotnet@v2 since v3 seems to install .NET 7 * Init * WIP * Add Directory.Build.props * Add SupportedOSPlatform attribute on tests using SDC * Fix using temporarily * Add IgnoreIf attribute to only run SDC tests on Windows * Cleanup pipelines * Cleanup * Cleanup using directives * More cleanup * Simplify attribute * Fix attribute * Add missing test file * Added blackdetect and blackframe arguments * Added log levels * Add missing using directive after rebase * fix extension is not png lost path * Apply fix to methods in new location * Add Uri support for Frame Analysis, skipped Stream support as this cannot support MP4's with moov atom in the end of the file, and input pipes do not support seek. * Add select multiple streams * Add other stream types to Channel (V,s,d,t) * Add negative mapping to select stream (deselect) * Update test * Add pad video filter * Update PipeHelpers.cs * Fix GetPipePath() for MacOS * Add SampleAspectRatio property to VideoStream * Update year * Always use Path.GetTempPath() on linux and macos * Use FedericoCarboni/setup-ffmpeg@v2 * Include macos in ci matrix * AddDeviceInput similar to AddFileInput and FromDeviceInput * fixed hwaccel parameter not working in 5.0 * a hack to unconditionally kill ffmpeg when parent .NET process exits * Remove PInvoke.Kernel32 * Remove unneeded cast * Update test * Added ability to retrieve bit depth from media streams for lossless encodings (#359) * Added ability to retrieve bit depth from media streams for lossless encodings * Shortened sample AIFF file used in tests * Cleanup after splitting into two packages (#386) * Move PosterWithAudio to FFMpegCore * Reduce windows only tests * Update Directory.Build.props * Create .editorconfig * More cleanup * Enable implicit usings * Remove unused method * Apply dotnet format * Fix unused variable in AudioGateArgument * Fix boolean conditions in AudioGateArgument * Merge boolean conditions into pattern * Use target-typed new * Add linting to CI * Add CUDA to HardwareAccelerationDevice enum * Increase timeout for Video_Join_Image_Sequence * Adjust Video_Join_Image_Sequence timeout * Fix expected seconds in Video_Join_Image_Sequence * Increase timeout for Video_TranscodeToMemory due to macos agents * fix: Switch source for rotation property from 'tags/rotate' to 'side_data_list/rotation' (incl. test case) (#388) * Init (#389) * build master branch after merge or push (#390) * Update ci.yml * Add codecov * Remove codecov for now * Add coverlet.collector and codecov --------- Co-authored-by: keg247 <44041557+keg247@users.noreply.github.com> Co-authored-by: Wilbert Bongers <msdnwilbert@muziekweb.nl> Co-authored-by: Artemii Gazizianov <107502822+ArtemiiimetrA@users.noreply.github.com> Co-authored-by: Thodoris Koskinopoulos <me@koskit.me> Co-authored-by: 赵宁 <602726286@qq.com> Co-authored-by: jeroenvanderschoot <jeroen.vanderschoot@kinetiq.tv> Co-authored-by: Sky Z <qe201020335@sina.com> Co-authored-by: Gleb Moskalenko <gleb.moskalenko.general@gmail.com> Co-authored-by: ep1kt3t0s <86835785+ep1kt3t0s@users.noreply.github.com> Co-authored-by: Victor Nova <lostfreeman@gmail.com> Co-authored-by: Tom Bogle <tom_bogle@sil.org> Co-authored-by: pklaes <10601494+pklaes@users.noreply.github.com>
2023-02-05 00:29:37 +01:00
Assert.AreEqual("-i \"input.mp4\" -hwaccel auto \"output.mp4\"", str);
2020-10-24 23:33:44 +02:00
}
2021-03-05 18:06:40 +01:00
2020-10-24 23:33:44 +02:00
[TestMethod]
public void Builder_BuildString_HardwareAcceleration_Specific()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4").OutputToFile("output.mp4", false,
opt => opt.WithHardwareAcceleration(HardwareAccelerationDevice.CUVID)).Arguments;
2020-10-24 23:33:44 +02:00
Assert.AreEqual("-i \"input.mp4\" -hwaccel cuvid \"output.mp4\"", str);
}
2020-04-30 14:14:10 +02:00
2019-02-08 11:19:40 +01:00
[TestMethod]
public void Builder_BuildString_Concat()
{
2020-10-24 22:31:54 +02:00
var str = FFMpegArguments.FromConcatInput(_concatFiles).OutputToFile("output.mp4", false).Arguments;
2020-05-08 11:07:51 +02:00
Assert.AreEqual("-i \"concat:1.mp4|2.mp4|3.mp4|4.mp4\" \"output.mp4\"", str);
2020-04-30 14:14:10 +02:00
}
2019-02-08 11:19:40 +01:00
[TestMethod]
public void Builder_BuildString_Copy_Audio()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt.CopyChannel(Channel.Audio)).Arguments;
2020-05-08 11:07:51 +02:00
Assert.AreEqual("-i \"input.mp4\" -c:a copy \"output.mp4\"", str);
2020-04-30 14:14:10 +02:00
}
2019-02-08 11:19:40 +01:00
[TestMethod]
public void Builder_BuildString_Copy_Video()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt.CopyChannel(Channel.Video)).Arguments;
2020-05-08 11:07:51 +02:00
Assert.AreEqual("-i \"input.mp4\" -c:v copy \"output.mp4\"", str);
2020-04-30 14:14:10 +02:00
}
2019-02-08 11:19:40 +01:00
[TestMethod]
public void Builder_BuildString_Copy_Both()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt.CopyChannel()).Arguments;
V.5.0.0 (#391) * Move NotifyOnProgress processing to ErrorData * added HighPass filter, LowPass filter, Audiogate and Silencedetection * re-added corresponding AudioFilterOptions * Update LICENSE * Update ci.yml * Fix argument * Bump action versions * Ignore Uri_Duration until root cause found * Use action that can install specific ffmpeg version * Remove ignore * Revert "Remove ignore" This reverts commit d85a4b81abaf4ab7832020cdb2ccfb46758d3bde. * Bump dependencies * Use setup-dotnet@v2 since v3 seems to install .NET 7 * Init * WIP * Add Directory.Build.props * Add SupportedOSPlatform attribute on tests using SDC * Fix using temporarily * Add IgnoreIf attribute to only run SDC tests on Windows * Cleanup pipelines * Cleanup * Cleanup using directives * More cleanup * Simplify attribute * Fix attribute * Add missing test file * Added blackdetect and blackframe arguments * Added log levels * Add missing using directive after rebase * fix extension is not png lost path * Apply fix to methods in new location * Add Uri support for Frame Analysis, skipped Stream support as this cannot support MP4's with moov atom in the end of the file, and input pipes do not support seek. * Add select multiple streams * Add other stream types to Channel (V,s,d,t) * Add negative mapping to select stream (deselect) * Update test * Add pad video filter * Update PipeHelpers.cs * Fix GetPipePath() for MacOS * Add SampleAspectRatio property to VideoStream * Update year * Always use Path.GetTempPath() on linux and macos * Use FedericoCarboni/setup-ffmpeg@v2 * Include macos in ci matrix * AddDeviceInput similar to AddFileInput and FromDeviceInput * fixed hwaccel parameter not working in 5.0 * a hack to unconditionally kill ffmpeg when parent .NET process exits * Remove PInvoke.Kernel32 * Remove unneeded cast * Update test * Added ability to retrieve bit depth from media streams for lossless encodings (#359) * Added ability to retrieve bit depth from media streams for lossless encodings * Shortened sample AIFF file used in tests * Cleanup after splitting into two packages (#386) * Move PosterWithAudio to FFMpegCore * Reduce windows only tests * Update Directory.Build.props * Create .editorconfig * More cleanup * Enable implicit usings * Remove unused method * Apply dotnet format * Fix unused variable in AudioGateArgument * Fix boolean conditions in AudioGateArgument * Merge boolean conditions into pattern * Use target-typed new * Add linting to CI * Add CUDA to HardwareAccelerationDevice enum * Increase timeout for Video_Join_Image_Sequence * Adjust Video_Join_Image_Sequence timeout * Fix expected seconds in Video_Join_Image_Sequence * Increase timeout for Video_TranscodeToMemory due to macos agents * fix: Switch source for rotation property from 'tags/rotate' to 'side_data_list/rotation' (incl. test case) (#388) * Init (#389) * build master branch after merge or push (#390) * Update ci.yml * Add codecov * Remove codecov for now * Add coverlet.collector and codecov --------- Co-authored-by: keg247 <44041557+keg247@users.noreply.github.com> Co-authored-by: Wilbert Bongers <msdnwilbert@muziekweb.nl> Co-authored-by: Artemii Gazizianov <107502822+ArtemiiimetrA@users.noreply.github.com> Co-authored-by: Thodoris Koskinopoulos <me@koskit.me> Co-authored-by: 赵宁 <602726286@qq.com> Co-authored-by: jeroenvanderschoot <jeroen.vanderschoot@kinetiq.tv> Co-authored-by: Sky Z <qe201020335@sina.com> Co-authored-by: Gleb Moskalenko <gleb.moskalenko.general@gmail.com> Co-authored-by: ep1kt3t0s <86835785+ep1kt3t0s@users.noreply.github.com> Co-authored-by: Victor Nova <lostfreeman@gmail.com> Co-authored-by: Tom Bogle <tom_bogle@sil.org> Co-authored-by: pklaes <10601494+pklaes@users.noreply.github.com>
2023-02-05 00:29:37 +01:00
Assert.AreEqual("-i \"input.mp4\" -c:a copy -c:v copy \"output.mp4\"", str);
2020-04-30 14:14:10 +02:00
}
2020-05-09 17:53:03 +02:00
[TestMethod]
public void Builder_BuildString_DisableChannel_Audio()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt.DisableChannel(Channel.Audio)).Arguments;
2020-05-09 17:53:03 +02:00
Assert.AreEqual("-i \"input.mp4\" -an \"output.mp4\"", str);
}
[TestMethod]
public void Builder_BuildString_DisableChannel_Video()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt.DisableChannel(Channel.Video)).Arguments;
2020-05-09 17:53:03 +02:00
Assert.AreEqual("-i \"input.mp4\" -vn \"output.mp4\"", str);
}
[TestMethod]
public void Builder_BuildString_AudioSamplingRate_Default()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt.WithAudioSamplingRate()).Arguments;
2020-05-09 17:53:03 +02:00
Assert.AreEqual("-i \"input.mp4\" -ar 48000 \"output.mp4\"", str);
}
2021-03-05 18:06:40 +01:00
2020-05-09 17:53:03 +02:00
[TestMethod]
public void Builder_BuildString_AudioSamplingRate()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt.WithAudioSamplingRate(44000)).Arguments;
2020-05-09 17:53:03 +02:00
Assert.AreEqual("-i \"input.mp4\" -ar 44000 \"output.mp4\"", str);
}
2021-03-05 18:06:40 +01:00
2020-05-09 17:53:03 +02:00
[TestMethod]
public void Builder_BuildString_VariableBitrate()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt.WithVariableBitrate(5)).Arguments;
2020-05-09 17:53:03 +02:00
Assert.AreEqual("-i \"input.mp4\" -vbr 5 \"output.mp4\"", str);
}
2021-03-05 18:06:40 +01:00
2020-05-09 17:53:03 +02:00
[TestMethod]
public void Builder_BuildString_Faststart()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt.WithFastStart()).Arguments;
2020-05-09 17:53:03 +02:00
Assert.AreEqual("-i \"input.mp4\" -movflags faststart \"output.mp4\"", str);
}
2021-03-05 18:06:40 +01:00
2020-05-09 17:53:03 +02:00
[TestMethod]
public void Builder_BuildString_Overwrite()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt.OverwriteExisting()).Arguments;
2020-05-09 17:53:03 +02:00
Assert.AreEqual("-i \"input.mp4\" -y \"output.mp4\"", str);
}
2021-03-05 18:06:40 +01:00
2020-05-09 17:53:03 +02:00
[TestMethod]
public void Builder_BuildString_RemoveMetadata()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt.WithoutMetadata()).Arguments;
2020-05-09 17:53:03 +02:00
Assert.AreEqual("-i \"input.mp4\" -map_metadata -1 \"output.mp4\"", str);
}
2021-03-05 18:06:40 +01:00
2020-05-09 17:53:03 +02:00
[TestMethod]
public void Builder_BuildString_Transpose()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt
.WithVideoFilters(filterOptions => filterOptions
.Transpose(Transposition.CounterClockwise90)))
.Arguments;
2020-05-09 17:53:03 +02:00
Assert.AreEqual("-i \"input.mp4\" -vf \"transpose=2\" \"output.mp4\"", str);
}
2021-05-14 01:02:00 +02:00
[TestMethod]
public void Builder_BuildString_Mirroring()
{
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt
.WithVideoFilters(filterOptions => filterOptions
.Mirror(Mirroring.Horizontal)))
.Arguments;
Assert.AreEqual("-i \"input.mp4\" -vf \"hflip\" \"output.mp4\"", str);
}
2021-03-05 18:06:40 +01:00
[TestMethod]
public void Builder_BuildString_TransposeScale()
{
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt
.WithVideoFilters(filterOptions => filterOptions
.Transpose(Transposition.CounterClockwise90)
.Scale(200, 300)))
.Arguments;
Assert.AreEqual("-i \"input.mp4\" -vf \"transpose=2, scale=200:300\" \"output.mp4\"", str);
}
2019-02-08 11:19:40 +01:00
[TestMethod]
public void Builder_BuildString_ForceFormat()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4", false, opt => opt.ForceFormat(VideoType.Mp4))
.OutputToFile("output.mp4", false, opt => opt.ForceFormat(VideoType.Mp4)).Arguments;
2020-10-24 22:31:54 +02:00
Assert.AreEqual("-f mp4 -i \"input.mp4\" -f mp4 \"output.mp4\"", str);
2020-04-30 14:14:10 +02:00
}
2019-02-08 11:19:40 +01:00
[TestMethod]
public void Builder_BuildString_FrameOutputCount()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt.WithFrameOutputCount(50)).Arguments;
2020-05-08 11:07:51 +02:00
Assert.AreEqual("-i \"input.mp4\" -vframes 50 \"output.mp4\"", str);
2020-04-30 14:14:10 +02:00
}
2020-09-17 20:02:33 +02:00
[TestMethod]
public void Builder_BuildString_VideoStreamNumber()
{
2021-08-11 14:54:58 +02:00
var str = FFMpegArguments.FromFileInput("input.mp4").OutputToFile("output.mp4", false, opt => opt.SelectStream(1)).Arguments;
2020-09-17 20:02:33 +02:00
Assert.AreEqual("-i \"input.mp4\" -map 0:1 \"output.mp4\"", str);
}
2019-02-08 11:19:40 +01:00
[TestMethod]
public void Builder_BuildString_FrameRate()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt.WithFramerate(50)).Arguments;
2020-05-08 11:07:51 +02:00
Assert.AreEqual("-i \"input.mp4\" -r 50 \"output.mp4\"", str);
2020-04-30 14:14:10 +02:00
}
2019-02-08 11:19:40 +01:00
[TestMethod]
public void Builder_BuildString_Loop()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4").OutputToFile("output.mp4", false, opt => opt.Loop(50))
.Arguments;
2020-05-08 11:07:51 +02:00
Assert.AreEqual("-i \"input.mp4\" -loop 50 \"output.mp4\"", str);
2020-04-30 14:14:10 +02:00
}
2019-02-08 11:19:40 +01:00
[TestMethod]
public void Builder_BuildString_Seek()
{
2020-10-24 22:31:54 +02:00
var str = FFMpegArguments.FromFileInput("input.mp4", false, opt => opt.Seek(TimeSpan.FromSeconds(10))).OutputToFile("output.mp4", false, opt => opt.Seek(TimeSpan.FromSeconds(10))).Arguments;
Assert.AreEqual("-ss 00:00:10.000 -i \"input.mp4\" -ss 00:00:10.000 \"output.mp4\"", str);
2020-04-30 14:14:10 +02:00
}
2019-02-08 11:19:40 +01:00
[TestMethod]
public void Builder_BuildString_Shortest()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt.UsingShortest()).Arguments;
2020-05-08 11:07:51 +02:00
Assert.AreEqual("-i \"input.mp4\" -shortest \"output.mp4\"", str);
2020-04-30 14:14:10 +02:00
}
2019-02-08 11:19:40 +01:00
[TestMethod]
public void Builder_BuildString_Size()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt.Resize(1920, 1080)).Arguments;
2020-05-08 11:07:51 +02:00
Assert.AreEqual("-i \"input.mp4\" -s 1920x1080 \"output.mp4\"", str);
2020-04-30 14:14:10 +02:00
}
2019-02-08 11:19:40 +01:00
[TestMethod]
public void Builder_BuildString_Speed()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt.WithSpeedPreset(Speed.Fast)).Arguments;
2020-05-08 11:07:51 +02:00
Assert.AreEqual("-i \"input.mp4\" -preset fast \"output.mp4\"", str);
2020-04-30 14:14:10 +02:00
}
2020-02-25 23:19:30 +01:00
[TestMethod]
public void Builder_BuildString_DrawtextFilter()
{
2020-05-08 11:07:51 +02:00
var str = FFMpegArguments
2020-10-24 22:31:54 +02:00
.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt
2021-03-05 18:06:40 +01:00
.WithVideoFilters(filterOptions => filterOptions
.DrawText(DrawTextOptions
.Create("Stack Overflow", "/path/to/font.ttf")
.WithParameter("fontcolor", "white")
.WithParameter("fontsize", "24")
.WithParameter("box", "1")
.WithParameter("boxcolor", "black@0.5")
.WithParameter("boxborderw", "5")
.WithParameter("x", "(w-text_w)/2")
.WithParameter("y", "(h-text_h)/2"))))
2020-10-24 22:31:54 +02:00
.Arguments;
2020-05-08 11:07:51 +02:00
2021-03-05 18:06:40 +01:00
Assert.AreEqual(
2021-03-06 21:25:17 +01:00
"-i \"input.mp4\" -vf \"drawtext=text='Stack Overflow':fontfile=/path/to/font.ttf:fontcolor=white:fontsize=24:box=1:boxcolor=black@0.5:boxborderw=5:x=(w-text_w)/2:y=(h-text_h)/2\" \"output.mp4\"",
2021-03-05 18:06:40 +01:00
str);
2020-02-25 23:19:30 +01:00
}
2020-05-09 17:53:03 +02:00
[TestMethod]
public void Builder_BuildString_DrawtextFilter_Alt()
{
var str = FFMpegArguments
2020-10-24 22:31:54 +02:00
.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt
2021-03-05 18:06:40 +01:00
.WithVideoFilters(filterOptions => filterOptions
.DrawText(DrawTextOptions
.Create("Stack Overflow", "/path/to/font.ttf", ("fontcolor", "white"), ("fontsize", "24")))))
2020-10-24 22:31:54 +02:00
.Arguments;
2020-05-09 17:53:03 +02:00
2021-03-05 18:06:40 +01:00
Assert.AreEqual(
2021-03-06 21:25:17 +01:00
"-i \"input.mp4\" -vf \"drawtext=text='Stack Overflow':fontfile=/path/to/font.ttf:fontcolor=white:fontsize=24\" \"output.mp4\"",
2021-03-05 18:06:40 +01:00
str);
2020-05-09 17:53:03 +02:00
}
2021-03-05 18:06:40 +01:00
2021-08-05 20:37:32 +02:00
[TestMethod]
public void Builder_BuildString_SubtitleHardBurnFilter()
{
var str = FFMpegArguments
.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt
.WithVideoFilters(filterOptions => filterOptions
.HardBurnSubtitle(SubtitleHardBurnOptions
.Create(subtitlePath: "sample.srt")
.SetCharacterEncoding("UTF-8")
2022-01-12 00:34:52 +01:00
.SetOriginalSize(1366, 768)
2021-08-05 20:37:32 +02:00
.SetSubtitleIndex(0)
.WithStyle(StyleOptions.Create()
.WithParameter("FontName", "DejaVu Serif")
.WithParameter("PrimaryColour", "&HAA00FF00")))))
.Arguments;
Assert.AreEqual("-i \"input.mp4\" -vf \"subtitles='sample.srt':charenc=UTF-8:original_size=1366x768:stream_index=0:force_style='FontName=DejaVu Serif\\,PrimaryColour=&HAA00FF00'\" \"output.mp4\"",
str);
}
[TestMethod]
public void Builder_BuildString_SubtitleHardBurnFilterFixedPaths()
{
var str = FFMpegArguments
.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt
.WithVideoFilters(filterOptions => filterOptions
.HardBurnSubtitle(SubtitleHardBurnOptions
.Create(subtitlePath: @"sample( \ : [ ] , ' ).srt"))))
.Arguments;
Assert.AreEqual(@"-i ""input.mp4"" -vf ""subtitles='sample( \\ \: \[ \] \, '\\\'' ).srt'"" ""output.mp4""",
2021-08-05 20:37:32 +02:00
str);
}
2019-02-08 11:19:40 +01:00
[TestMethod]
public void Builder_BuildString_StartNumber()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt.WithStartNumber(50)).Arguments;
2020-05-08 11:07:51 +02:00
Assert.AreEqual("-i \"input.mp4\" -start_number 50 \"output.mp4\"", str);
2020-04-30 14:14:10 +02:00
}
2019-02-08 11:19:40 +01:00
[TestMethod]
public void Builder_BuildString_Threads_1()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt.UsingThreads(50)).Arguments;
2020-05-08 11:07:51 +02:00
Assert.AreEqual("-i \"input.mp4\" -threads 50 \"output.mp4\"", str);
2020-04-30 14:14:10 +02:00
}
2019-02-08 11:19:40 +01:00
[TestMethod]
public void Builder_BuildString_Threads_2()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt.UsingMultithreading(true)).Arguments;
2020-05-08 11:07:51 +02:00
Assert.AreEqual($"-i \"input.mp4\" -threads {Environment.ProcessorCount} \"output.mp4\"", str);
2020-04-30 14:14:10 +02:00
}
2019-02-08 11:19:40 +01:00
[TestMethod]
public void Builder_BuildString_Codec()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt.WithVideoCodec(VideoCodec.LibX264)).Arguments;
Assert.AreEqual("-i \"input.mp4\" -c:v libx264 \"output.mp4\"", str);
2020-04-30 14:14:10 +02:00
}
2019-02-08 11:19:40 +01:00
[TestMethod]
public void Builder_BuildString_Codec_Override()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4").OutputToFile("output.mp4", true,
opt => opt.WithVideoCodec(VideoCodec.LibX264).ForcePixelFormat("yuv420p")).Arguments;
2020-05-08 11:07:51 +02:00
Assert.AreEqual("-i \"input.mp4\" -c:v libx264 -pix_fmt yuv420p \"output.mp4\" -y", str);
2020-04-30 14:14:10 +02:00
}
[TestMethod]
2020-04-28 06:26:42 +02:00
public void Builder_BuildString_Duration()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt.WithDuration(TimeSpan.FromSeconds(20))).Arguments;
2020-05-08 11:07:51 +02:00
Assert.AreEqual("-i \"input.mp4\" -t 00:00:20 \"output.mp4\"", str);
2020-04-30 14:14:10 +02:00
}
2021-03-05 18:06:40 +01:00
2020-04-28 06:26:42 +02:00
[TestMethod]
public void Builder_BuildString_Raw()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4", false, opt => opt.WithCustomArgument(null!))
.OutputToFile("output.mp4", false, opt => opt.WithCustomArgument(null!)).Arguments;
2020-10-24 22:31:54 +02:00
Assert.AreEqual(" -i \"input.mp4\" \"output.mp4\"", str);
2020-04-28 06:26:42 +02:00
2021-03-05 18:06:40 +01:00
str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt.WithCustomArgument("-acodec copy")).Arguments;
2020-05-08 11:07:51 +02:00
Assert.AreEqual("-i \"input.mp4\" -acodec copy \"output.mp4\"", str);
2020-04-28 06:26:42 +02:00
}
[TestMethod]
public void Builder_BuildString_ForcePixelFormat()
{
2021-03-05 18:06:40 +01:00
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt.ForcePixelFormat("yuv444p")).Arguments;
Assert.AreEqual("-i \"input.mp4\" -pix_fmt yuv444p \"output.mp4\"", str);
}
2021-10-04 18:27:24 +02:00
[TestMethod]
public void Builder_BuildString_PanAudioFilterChannelNumber()
{
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false,
opt => opt.WithAudioFilters(filterOptions => filterOptions.Pan(2, "c0=c1", "c1=c1")))
.Arguments;
Assert.AreEqual("-i \"input.mp4\" -af \"pan=2c|c0=c1|c1=c1\" \"output.mp4\"", str);
}
[TestMethod]
public void Builder_BuildString_PanAudioFilterChannelLayout()
{
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false,
opt => opt.WithAudioFilters(filterOptions => filterOptions.Pan("stereo", "c0=c0", "c1=c1")))
.Arguments;
Assert.AreEqual("-i \"input.mp4\" -af \"pan=stereo|c0=c0|c1=c1\" \"output.mp4\"", str);
}
[TestMethod]
public void Builder_BuildString_PanAudioFilterChannelNoOutputDefinition()
{
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false,
opt => opt.WithAudioFilters(filterOptions => filterOptions.Pan("stereo")))
.Arguments;
Assert.AreEqual("-i \"input.mp4\" -af \"pan=stereo\" \"output.mp4\"", str);
}
2021-10-05 01:10:00 +02:00
[TestMethod]
public void Builder_BuildString_DynamicAudioNormalizerDefaultFormat()
{
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false,
opt => opt.WithAudioFilters(filterOptions => filterOptions.DynamicNormalizer()))
.Arguments;
Assert.AreEqual("-i \"input.mp4\" -af \"dynaudnorm=f=500:g=31:p=0.95:m=10.0:r=0.0:n=1:c=0:b=0:s=0.0\" \"output.mp4\"", str);
}
[TestMethod]
public void Builder_BuildString_DynamicAudioNormalizerWithValuesFormat()
{
var str = FFMpegArguments.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false,
2022-01-12 00:34:52 +01:00
opt => opt.WithAudioFilters(filterOptions => filterOptions.DynamicNormalizer(125, 13, 0.9215, 5.124, 0.5458, false, true, true, 0.3333333)))
2021-10-05 01:10:00 +02:00
.Arguments;
Assert.AreEqual("-i \"input.mp4\" -af \"dynaudnorm=f=125:g=13:p=0.92:m=5.1:r=0.5:n=0:c=1:b=1:s=0.3\" \"output.mp4\"", str);
}
2022-01-12 00:34:52 +01:00
[TestMethod]
public void Builder_BuildString_Audible_AAXC_Decryption()
{
var str = FFMpegArguments.FromFileInput("input.aaxc", false, x => x.WithAudibleEncryptionKeys("123", "456"))
.MapMetaData()
.OutputToFile("output.m4b", true, x => x.WithTagVersion(3).DisableChannel(Channel.Video).CopyChannel(Channel.Audio))
.Arguments;
Assert.AreEqual("-audible_key 123 -audible_iv 456 -i \"input.aaxc\" -map_metadata 0 -id3v2_version 3 -vn -c:a copy \"output.m4b\" -y", str);
}
V.5.0.0 (#391) * Move NotifyOnProgress processing to ErrorData * added HighPass filter, LowPass filter, Audiogate and Silencedetection * re-added corresponding AudioFilterOptions * Update LICENSE * Update ci.yml * Fix argument * Bump action versions * Ignore Uri_Duration until root cause found * Use action that can install specific ffmpeg version * Remove ignore * Revert "Remove ignore" This reverts commit d85a4b81abaf4ab7832020cdb2ccfb46758d3bde. * Bump dependencies * Use setup-dotnet@v2 since v3 seems to install .NET 7 * Init * WIP * Add Directory.Build.props * Add SupportedOSPlatform attribute on tests using SDC * Fix using temporarily * Add IgnoreIf attribute to only run SDC tests on Windows * Cleanup pipelines * Cleanup * Cleanup using directives * More cleanup * Simplify attribute * Fix attribute * Add missing test file * Added blackdetect and blackframe arguments * Added log levels * Add missing using directive after rebase * fix extension is not png lost path * Apply fix to methods in new location * Add Uri support for Frame Analysis, skipped Stream support as this cannot support MP4's with moov atom in the end of the file, and input pipes do not support seek. * Add select multiple streams * Add other stream types to Channel (V,s,d,t) * Add negative mapping to select stream (deselect) * Update test * Add pad video filter * Update PipeHelpers.cs * Fix GetPipePath() for MacOS * Add SampleAspectRatio property to VideoStream * Update year * Always use Path.GetTempPath() on linux and macos * Use FedericoCarboni/setup-ffmpeg@v2 * Include macos in ci matrix * AddDeviceInput similar to AddFileInput and FromDeviceInput * fixed hwaccel parameter not working in 5.0 * a hack to unconditionally kill ffmpeg when parent .NET process exits * Remove PInvoke.Kernel32 * Remove unneeded cast * Update test * Added ability to retrieve bit depth from media streams for lossless encodings (#359) * Added ability to retrieve bit depth from media streams for lossless encodings * Shortened sample AIFF file used in tests * Cleanup after splitting into two packages (#386) * Move PosterWithAudio to FFMpegCore * Reduce windows only tests * Update Directory.Build.props * Create .editorconfig * More cleanup * Enable implicit usings * Remove unused method * Apply dotnet format * Fix unused variable in AudioGateArgument * Fix boolean conditions in AudioGateArgument * Merge boolean conditions into pattern * Use target-typed new * Add linting to CI * Add CUDA to HardwareAccelerationDevice enum * Increase timeout for Video_Join_Image_Sequence * Adjust Video_Join_Image_Sequence timeout * Fix expected seconds in Video_Join_Image_Sequence * Increase timeout for Video_TranscodeToMemory due to macos agents * fix: Switch source for rotation property from 'tags/rotate' to 'side_data_list/rotation' (incl. test case) (#388) * Init (#389) * build master branch after merge or push (#390) * Update ci.yml * Add codecov * Remove codecov for now * Add coverlet.collector and codecov --------- Co-authored-by: keg247 <44041557+keg247@users.noreply.github.com> Co-authored-by: Wilbert Bongers <msdnwilbert@muziekweb.nl> Co-authored-by: Artemii Gazizianov <107502822+ArtemiiimetrA@users.noreply.github.com> Co-authored-by: Thodoris Koskinopoulos <me@koskit.me> Co-authored-by: 赵宁 <602726286@qq.com> Co-authored-by: jeroenvanderschoot <jeroen.vanderschoot@kinetiq.tv> Co-authored-by: Sky Z <qe201020335@sina.com> Co-authored-by: Gleb Moskalenko <gleb.moskalenko.general@gmail.com> Co-authored-by: ep1kt3t0s <86835785+ep1kt3t0s@users.noreply.github.com> Co-authored-by: Victor Nova <lostfreeman@gmail.com> Co-authored-by: Tom Bogle <tom_bogle@sil.org> Co-authored-by: pklaes <10601494+pklaes@users.noreply.github.com>
2023-02-05 00:29:37 +01:00
[TestMethod]
public void Builder_BuildString_PadFilter()
{
var str = FFMpegArguments
.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt
.WithVideoFilters(filterOptions => filterOptions
.Pad(PadOptions
.Create("max(iw,ih)", "ow")
.WithParameter("x", "(ow-iw)/2")
.WithParameter("y", "(oh-ih)/2")
.WithParameter("color", "violet")
.WithParameter("eval", "frame"))))
.Arguments;
Assert.AreEqual(
"-i \"input.mp4\" -vf \"pad=width=max(iw\\,ih):height=ow:x=(ow-iw)/2:y=(oh-ih)/2:color=violet:eval=frame\" \"output.mp4\"",
str);
}
[TestMethod]
public void Builder_BuildString_PadFilter_Alt()
{
var str = FFMpegArguments
.FromFileInput("input.mp4")
.OutputToFile("output.mp4", false, opt => opt
.WithVideoFilters(filterOptions => filterOptions
.Pad(PadOptions
.Create("4/3")
.WithParameter("x", "(ow-iw)/2")
.WithParameter("y", "(oh-ih)/2")
.WithParameter("color", "violet")
.WithParameter("eval", "frame"))))
.Arguments;
Assert.AreEqual(
"-i \"input.mp4\" -vf \"pad=aspect=4/3:x=(ow-iw)/2:y=(oh-ih)/2:color=violet:eval=frame\" \"output.mp4\"",
str);
}
2019-02-08 11:19:40 +01:00
}
V.5.0.0 (#391) * Move NotifyOnProgress processing to ErrorData * added HighPass filter, LowPass filter, Audiogate and Silencedetection * re-added corresponding AudioFilterOptions * Update LICENSE * Update ci.yml * Fix argument * Bump action versions * Ignore Uri_Duration until root cause found * Use action that can install specific ffmpeg version * Remove ignore * Revert "Remove ignore" This reverts commit d85a4b81abaf4ab7832020cdb2ccfb46758d3bde. * Bump dependencies * Use setup-dotnet@v2 since v3 seems to install .NET 7 * Init * WIP * Add Directory.Build.props * Add SupportedOSPlatform attribute on tests using SDC * Fix using temporarily * Add IgnoreIf attribute to only run SDC tests on Windows * Cleanup pipelines * Cleanup * Cleanup using directives * More cleanup * Simplify attribute * Fix attribute * Add missing test file * Added blackdetect and blackframe arguments * Added log levels * Add missing using directive after rebase * fix extension is not png lost path * Apply fix to methods in new location * Add Uri support for Frame Analysis, skipped Stream support as this cannot support MP4's with moov atom in the end of the file, and input pipes do not support seek. * Add select multiple streams * Add other stream types to Channel (V,s,d,t) * Add negative mapping to select stream (deselect) * Update test * Add pad video filter * Update PipeHelpers.cs * Fix GetPipePath() for MacOS * Add SampleAspectRatio property to VideoStream * Update year * Always use Path.GetTempPath() on linux and macos * Use FedericoCarboni/setup-ffmpeg@v2 * Include macos in ci matrix * AddDeviceInput similar to AddFileInput and FromDeviceInput * fixed hwaccel parameter not working in 5.0 * a hack to unconditionally kill ffmpeg when parent .NET process exits * Remove PInvoke.Kernel32 * Remove unneeded cast * Update test * Added ability to retrieve bit depth from media streams for lossless encodings (#359) * Added ability to retrieve bit depth from media streams for lossless encodings * Shortened sample AIFF file used in tests * Cleanup after splitting into two packages (#386) * Move PosterWithAudio to FFMpegCore * Reduce windows only tests * Update Directory.Build.props * Create .editorconfig * More cleanup * Enable implicit usings * Remove unused method * Apply dotnet format * Fix unused variable in AudioGateArgument * Fix boolean conditions in AudioGateArgument * Merge boolean conditions into pattern * Use target-typed new * Add linting to CI * Add CUDA to HardwareAccelerationDevice enum * Increase timeout for Video_Join_Image_Sequence * Adjust Video_Join_Image_Sequence timeout * Fix expected seconds in Video_Join_Image_Sequence * Increase timeout for Video_TranscodeToMemory due to macos agents * fix: Switch source for rotation property from 'tags/rotate' to 'side_data_list/rotation' (incl. test case) (#388) * Init (#389) * build master branch after merge or push (#390) * Update ci.yml * Add codecov * Remove codecov for now * Add coverlet.collector and codecov --------- Co-authored-by: keg247 <44041557+keg247@users.noreply.github.com> Co-authored-by: Wilbert Bongers <msdnwilbert@muziekweb.nl> Co-authored-by: Artemii Gazizianov <107502822+ArtemiiimetrA@users.noreply.github.com> Co-authored-by: Thodoris Koskinopoulos <me@koskit.me> Co-authored-by: 赵宁 <602726286@qq.com> Co-authored-by: jeroenvanderschoot <jeroen.vanderschoot@kinetiq.tv> Co-authored-by: Sky Z <qe201020335@sina.com> Co-authored-by: Gleb Moskalenko <gleb.moskalenko.general@gmail.com> Co-authored-by: ep1kt3t0s <86835785+ep1kt3t0s@users.noreply.github.com> Co-authored-by: Victor Nova <lostfreeman@gmail.com> Co-authored-by: Tom Bogle <tom_bogle@sil.org> Co-authored-by: pklaes <10601494+pklaes@users.noreply.github.com>
2023-02-05 00:29:37 +01:00
}