You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ExtractFrames function pulls all frames for a video. For long videos this is slow. Also for my application the ability to pull selected portions of the video is necessary.
FFMPeg supports efficient from/to second selection
I'd like the existing function ExtractFrames to support optional FromSecond / ToSecond parameters
The text was updated successfully, but these errors were encountered:
The existing code can be updated as follows (assuming new int _videoSettings.FromSecond and _videoSettings.ToSecond params):
/// <summary>
/// Execute command to extract all/some frames from video
/// </summary>
private void ExtractFrames()
{
var (w, h) = (_videoSettings.Width, _videoSettings.Height);
var vfOptions = string.Empty;
// Check if the time range is specified
if ((_videoSettings.FromSecond > 0) && (_videoSettings.ToSecond > 0))
{
// Add the (optional) time selection range using -ss (seek) and -t (duration)
var duration = Math.Max( 1, _videoSettings.ToSecond - _videoSettings.FromSecond + 1 ); // Minimum duration is 1 second
vfOptions = $"-ss {_videoSettings.FromSecond.ToString(CultureInfo.InvariantCulture)} -t {duration.ToString(CultureInfo.InvariantCulture)}";
}
vfOptions += $" -vf fps={FormatedFps},scale={w}:{h}";
Execute($@"-i ""{_videoSettings.VideoFile}"" -vsync vfr {vfOptions} ""{Path.Combine(_videoSettings.TempFolder, $"%d.{FRAME_FORMAT}")}""");
}
PhilipQuirke
changed the title
FromFrame and ToFrame options on ExtractFrames
FromSecond and ToSecond options on ExtractFrames
Oct 11, 2024
The ExtractFrames function pulls all frames for a video. For long videos this is slow. Also for my application the ability to pull selected portions of the video is necessary.
FFMPeg supports efficient from/to second selection
I'd like the existing function ExtractFrames to support optional FromSecond / ToSecond parameters
The text was updated successfully, but these errors were encountered: