UtilFFMediaToolkitFindColorFrameTimeSpans(MediaFile, Color, Size, Single, ActionInt32, Int32) Method
Finds all the frames that matches the specified color in the source video file and returns the frame's time positions.
Note: this method can take several minutes to complete depending on the duration and resolution of the source video.
Namespace: DevCase.ThirdParty.FFMediaToolkitAssembly: DevCase.net48.ThirdParty.FFMediaToolkit (in DevCase.net48.ThirdParty.FFMediaToolkit.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
public static IReadOnlyCollection<TimeSpan> FindColorFrameTimeSpans(
MediaFile videoFile,
Color color,
Size sampleSize,
float similarity,
Action<int, int> callback = null
)
Public Shared Function FindColorFrameTimeSpans (
videoFile As MediaFile,
color As Color,
sampleSize As Size,
similarity As Single,
Optional callback As Action(Of Integer, Integer) = Nothing
) As IReadOnlyCollection(Of TimeSpan)
Dim videoFile As MediaFile
Dim color As Color
Dim sampleSize As Size
Dim similarity As Single
Dim callback As Action(Of Integer, Integer)
Dim returnValue As IReadOnlyCollection(Of TimeSpan)
returnValue = UtilFFMediaToolkit.FindColorFrameTimeSpans(videoFile,
color, sampleSize, similarity, callback)
public:
static IReadOnlyCollection<TimeSpan>^ FindColorFrameTimeSpans(
MediaFile^ videoFile,
Color color,
Size sampleSize,
float similarity,
Action<int, int>^ callback = nullptr
)
static member FindColorFrameTimeSpans :
videoFile : MediaFile *
color : Color *
sampleSize : Size *
similarity : float32 *
?callback : Action<int, int>
(* Defaults:
let _callback = defaultArg callback null
*)
-> IReadOnlyCollection<TimeSpan>
No code example is currently available or this language may not be supported.
- videoFile MediaFile
-
The video file.
- color Color
-
The color to match.
- sampleSize Size
-
The size at which each frame will be resized to analyze their pixels.
It is recommended to use a small size, like 20x20, 50x50 or 100x100.
Bigger sizes will take more time to analyze.
- similarity Single
-
The tolerance of the color comparison. Valid range is from 0.01 (minimum) to 100 (maximum).
- callback ActionInt32, Int32 (Optional)
-
An encapsulated method that is invoked with {currentFrameNumber, totalFrames} arguments to report progress.
IReadOnlyCollectionTimeSpan
A
IReadOnlyCollectionT that contains the time position of the
frames that matches the specified color in the source video file.
This is a code example.
No code example is currently available or this language may not be supported.
' FFMpeg binaries (shared build) (download here: https://www.gyan.dev/ffmpeg/builds/)
' See FFMediaToolkit documentation here: https://github.com/radek-k/FFMediaToolkit#setup
FFMediaToolkit.FFmpegLoader.FFmpegPath = "C:\ffmpeg\"
FFMediaToolkit.FFmpegLoader.LoadFFmpeg()
Dim color As Color = Color.Black
Dim sampleSize As New Size(20, 20)
Dim similarity As Single = 99.99F
Using videoFile As MediaFile = MediaFile.Open("C:\File.mkv")
Dim frameTimes As IReadOnlyCollection(Of TimeSpan) = FindColorFrameTimeSpans(videoFile, color, sampleSize, similarity)
Console.WriteLine($"Frame numbers: {{{String.Join(", ", frameTimes)}}}")
End Using
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.