GithubHelp home page GithubHelp logo

ffmpegargs's Introduction

FFmpegArgs

FFmpegArgs is a cli-wrapper library support generate argument for ffmpeg executable.
The standout feature that many cli-wrapper libraries don't have is the FFmpeg FilterGraph system.

Get it on NuGet Package


  • Support file/url/pipe in/output.
  • Works on most systems - if ffmpeg can execution.
  • 130+ filters, add more in future
  • 380+ filters auto-generate

Example

FFmpegArg ffmpegArg = new FFmpegArg()
    .OverWriteOutput();//global extension

var green_video = ffmpegArg.AddVideoInput(
        new VideoFileInput(@"chromakey.mp4")
            .SsPosition(TimeSpan.FromSeconds(0.5))//input extension ( -ss )
            .AndSet(
                x => x.ImageInputAVStream//input video stream
                    .R(24)//input, video, per-stream extension ( -r )
            )
    );
var background_videoMap = ffmpegArg.AddVideoInput(new VideoFileInput(@"background.mp4")
    .SsPosition(TimeSpan.FromSeconds(1))
    .ToPosition(TimeSpan.FromSeconds(10)));

var image_maps = green_video.ImageMaps.First()
    .ColorKeyFilter()//ColorKey Filter
        .Color(Color.FromArgb(101, 220, 8))
        .Similarity(0.25f)
        .Enable("between(t,0,10)").MapOut//Filter had ITimelineSupport
    .ScaleFilter().W("iw/3").H("ih/3").MapOut//Scale Filter
    .SplitFilter(2).MapsOut;//Split Filter

var overlay_map = image_maps.First()
    //overlay color_key on-center background_video
    .OverlayFilterOn(background_videoMap.ImageMaps.First()).X("(W-w)/2").Y("(H-h)/2").MapOut;

ffmpegArg.AddOutput(
    new VideoFileOutput(@"out.mp4", overlay_map, background_videoMap.AudioMaps.First())
    .T(TimeSpan.FromSeconds(5))//output extension ( -t )
    .AndSet(
        x => x.ImageOutputAVStream//output video stream
            .R(24)//output, video, per-stream extension ( -r )
        )
    );
ffmpegArg.AddOutput(
    new VideoFileOutput(@"out2.mp4", image_maps.Last(), background_videoMap.AudioMaps.First())
    .AndSet(x => x.ImageOutputAVStream.R(30)));

var renderResult = ffmpegArg
    .Render(c => c
        .WithFFmpegBinaryPath("path to ffmpeg")//or default ffmpeg from PATH
        .WithWorkingDirectory("path to working folder")//or default Directory.GetCurrentDirectory()
    )
    .Execute();

For more example, see FFmpegArgs.Test


  • Option/Flag not found?

We can extend for FFmpegArg, Filter, Input, Output, AVStream by extension.

.SetOption("your option","option value")
.SetOptionRange("your option", val, min, max)
.SetFlag("your flag")

  • Filter not found?

We can write new Filter class, so much example in FFmpegArgs.Filters

Pull request or request missing feature are welcome.


Recommend namespace

using FFmpegArgs;
using FFmpegArgs.Cores;
using FFmpegArgs.Cores.Enums;
using FFmpegArgs.Cores.Exceptions;
using FFmpegArgs.Cores.Inputs;
using FFmpegArgs.Cores.Filters;
using FFmpegArgs.Cores.Interfaces;
using FFmpegArgs.Cores.Maps;
using FFmpegArgs.Cores.Streams;

using FFmpegArgs.Filters;
using FFmpegArgs.Filters.Exceptions;
using FFmpegArgs.Filters.Attributes;
using FFmpegArgs.Filters.Expressions;

using FFmpegArgs.Filters.AudioFilters;
using FFmpegArgs.Filters.VideoFilters;
using FFmpegArgs.Filters.MultimediaFilters;
using FFmpegArgs.Filters.VideoSources;
using FFmpegArgs.Filters.AudioSources;
//using FFmpegArgs.Filters.Generated;

using FFmpegArgs.Executes;
using FFmpegArgs.Inputs;
using FFmpegArgs.Outputs;

LICENCE

MIT

ffmpegargs's People

Contributors

tqk2811 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ffmpegargs's Issues

Question: Execution of FFmpeg when binary is not in the project folder

We had a question.

We are planning to deploy a service that will run ffmpeg for video processing in an Alpine Linux Docker container. We don't want to have the FFmpeg.exe binary in the project itself. Rather, the DockerFile will run and install ffmpeg in that Alpine Linux Docker Container. Do we need to set the path to the ffmpeg.exe binary manually in Linux?

We have also set FFMpeg as a PATH variable in Windows 10 so that when we launch the command line console and enter "FFmpeg", it is able to tell us information about the ffmpeg binary. However, when we run the project locally in Windows 10, await ffmpeg.Render().ExecuteAsync(); call fails and says file not found. Do we have to set the path to ffmpeg.exe binary manually here as well?

Request: Allow for conversion from one video (with audio) to another

I'm trying to convert from a mkv file (with audio) to a .webm file. I'm trying to replicate this argument
"ffmpeg -i CombinedOutput.mkv -vcodec libvpx -acodec copy output.webm".
I can take in the .mkv file as a video input but the video output also requires an audio map argument. Is there another way to go about this that i'm not seeing?

Question: Concatenating multiple video files

What filter would i use to concatenate multiple videos files (no horizontal stacking)?
Basically, trying to replicate something like this
"ffmpeg -i opening.mkv -i episode.mkv
-filter_complex "[0:v] [1:v]
concat=n=2v=1:a=0[v]"
-map "[v]" output.mkv"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.