UtilFFMediaToolkitFindColorFrameSequences(MediaFile, Color, Size, Single, ActionInt32, Int32) Method
Finds all the sequences of frames that matches the specified colors in the source video file.
This is useful for example to find all fade to black sequences in a video.
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<VideoTimeline> FindColorFrameSequences(
MediaFile videoFile,
Color[] colors,
Size sampleSize,
float similarity,
Action<int, int> callback = null
)
Public Shared Function FindColorFrameSequences (
videoFile As MediaFile,
colors As Color(),
sampleSize As Size,
similarity As Single,
Optional callback As Action(Of Integer, Integer) = Nothing
) As IReadOnlyCollection(Of VideoTimeline)
Dim videoFile As MediaFile
Dim colors As Color()
Dim sampleSize As Size
Dim similarity As Single
Dim callback As Action(Of Integer, Integer)
Dim returnValue As IReadOnlyCollection(Of VideoTimeline)
returnValue = UtilFFMediaToolkit.FindColorFrameSequences(videoFile,
colors, sampleSize, similarity, callback)
public:
static IReadOnlyCollection<VideoTimeline^>^ FindColorFrameSequences(
MediaFile^ videoFile,
array<Color>^ colors,
Size sampleSize,
float similarity,
Action<int, int>^ callback = nullptr
)
static member FindColorFrameSequences :
videoFile : MediaFile *
colors : Color[] *
sampleSize : Size *
similarity : float32 *
?callback : Action<int, int>
(* Defaults:
let _callback = defaultArg callback null
*)
-> IReadOnlyCollection<VideoTimeline>
No code example is currently available or this language may not be supported.
- videoFile MediaFile
-
The video file.
- colors Color
-
The colors 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.
IReadOnlyCollectionVideoTimeline
A
IReadOnlyCollectionT that represents the
sequences of 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()
Using videoFile As MediaFile = MediaFile.Open("C:\File.mkv")
Dim colors As Color() = {Color.Black, Color.FromArgb(255, 13, 14, 16)}
Dim sampleSize As New Size(20, 20)
Dim similarity As Single = 99.99F
Dim timelines As IReadOnlyCollection(Of VideoTimeline) = FindColorFrameSequences(videoFile, colors, sampleSize, similarity)
For Each timeline As VideoTimeline In timelines
Console.WriteLine($"Begin time: {timeline.BeginTime}, End time: {timeline.EndTime}, Frame numbers: {{{String.Join(", ", timeline.FrameNumbers)}}}")
Next timeline
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.