Chase.FFmpeg.Extra

Adds extra functionality to Chase.FFmpeg


Keywords
License
GPL-3.0
Install
Install-Package Chase.FFmpeg.Extra -Version 0.0.2

Documentation

Chase.FFmpeg

Using Statements

using Chase.FFmpeg.Converters;
using Chase.FFmpeg.Info;
using Chase.FFmpeg.Events;
using Chase.FFmpeg;

Create media info object

FFMediaInfo info = new FFMediaInfo("/path/to/media.mkv");

Create Muxed converter

FFMuxedConverter converter = FFMuxedConverter.SetMedia(info)

Muxed converter options

Changes the video codec

.ChangeVideoCodec("h264_nvenc")

Changes the video bitrate

.ChangeVideoBitrate("2M")

Changes the audio codec

.ChangeAudioCodec("aac")

Changes the audio bitrate

.ChangeAudioBitrate("200K")

Changes the hardware acceleration method

.ChangeHardwareAccelerationMethod()

Changes the pixel format of the video

.ChangePixelFormat("y2k")

Changes the width and height of the video stream

.ChangeResolution(800, 600)

Changes the width of the video while maintaining aspect ratio

.ChangeWidth(800)

Changes the height of the video while maintaining aspect ratio

.ChangeHeight(600)

The position that the video starts at

.ChangeStartPosition("00:00:00")

Changes the duration of the video

.ChangeVideoDuration("00:15:00")

Overwrites output file if one exists

.OverwriteOriginal();

Events

/// The console output of ffmpeg
DataReceivedEventHandler? data_handler = (object s, DataReceivedEventArgs e) => { };

/// Runs when ffmpeg exists
EventHandler exited = (object sender, EventArgs e) => { };

/// Returns ffmpeg update values
EventHandler<FFProcessUpdateEventArgs> updated = (object sender, FFProcessUpdateEventArgs e) =>
{
    /// The bitrate that the video is being processed at
    float bitrate = e.AverageBitrate;

    /// The number of frames already processed
    uint frames = e.FramesProcessed;

    /// The percentage of the video has been processed
    float percentage = e.Percentage;

    /// The speed that the video is processing at
    float speed = e.Speed;
};

Converts the current Muxed Converter

.Convert("/path/to/output.mkv", data_handler, exited, updated);

Builds a ffmpeg argument string

.Build("/path/to/output.mkv")

Example

string argument = FFMuxedConverter
    .SetMedia(info)
    .ChangeVideoCodec("h264_nvenc")
    .ChangeVideoBitrate("2M")
    .ChangeHardwareAccelerationMethod()
    .ChangeResolution(800, 600)
    .OverwriteOriginal()
    .Build("/path/to/output.mkv");
FFProcessHandler.ExecuteFFmpeg(argument, data_handler, exited, updated);

Chase.FFmpeg.Downloader

This downloads the ffmpeg library.

Using Statement

using Chase.FFmpeg.Downloader;

Download Latest Version

/// Downloads the latest version of FFmpeg
FFmpegDownloader.Instance.GetLatest("/path/to/ffmpeg").Wait(); // Async Process

Location of the FFmpeg and FFProbe executable files

/// Path to ffmpeg executable
string ffmpeg = FFmpegDownloader.Instance.FFmpegExecutable;  // path/to/ffmpeg/ffmpeg.exe
/// Path to ffprobe executable
string ffprobe = FFmpegDownloader.Instance.FFprobeExecutable;  // path/to/ffmpeg/ffprobe.exe

The installed version of ffmpeg library

/// The installed ffmpeg version
string version = FFmpegDownloader.Instance.FFmpegVersion; // 4.0.1

Chase.FFmpeg.Extras

Usings

using Chase.FFmpeg.Extras;

Video

Gets all files with video extension in specified directory

/// <param name="path">The starting path</param>
/// <param name="recursive">If the search should look through all subdirectories</param>
FFVideoUtility.GetFiles("path/to/files", true)

An array of all video file extensions

FFVideoUtility.video_extensions

Checks if file has a extension matching the Video Extensions array

FFVideoUtility.HasVideoExtension("/path/to/video.mkv")

Audio

Gets all files with audio extension in specified directory

/// <param name="path">The starting path</param>
/// <param name="recursive">If the search should look through all subdirectories</param>
FFAudioUtility.GetFiles("path/to/files", true)

An array of all audio file extensions

FFAudioUtility.audio_extensions

Checks if file has a extension matching the Audio Extensions array

FFAudioUtility.HasAudioExtension("/path/to/audio.mp3")

Images

Gets all files with images extension in specified directory

/// <param name="path">The starting path</param>
/// <param name="recursive">If the search should look through all subdirectories</param>
FFImagesUtility.GetFiles("path/to/files", true)

An array of all images file extensions

FFImagesUtility.images_extensions

Checks if file has a extension matching the Images Extensions array

FFImagesUtility.HasImagesExtension("/path/to/images.mp3")