Git Product home page Git Product logo

x264net's Introduction

x264net

.NET wrapper for x264, written in C++/CLI and usable from C# and VB.NET

License

x264net is distributed under the GPL 2.0 license

https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html

Introduction

x264net is a very simple .NET wrapper for the x264 video encoder. For convenience, pre-built binaries for libx264 are included in the solution. I followed this guide to build x264 in Visual Studio: http://siliconandlithium.blogspot.com/2014/03/building-x264-on-windows-with-visual.html

Requirements

Windows OS. I don't know how to make this cross-platform.

Use Visual Studio 2017 to open and build the solution. The free version is fine.

This wrapper is written in C++/CLI using Visual Studio 2017, so there are dependencies on msvcp140.dll and vcruntime140.dll. Normally this means you must install a Visual C++ 2017 Redistributable package (or Visual Studio itself) on any machine that is going to use this wrapper. However for convenience, I have included the required dll files in the repository and configured the project build events to copy the dll files to the appropriate output directories. Because of this, it should no longer be necessary to install a Visual C++ 2017 Redistributable package.

32 bit: https://go.microsoft.com/fwlink/?LinkId=746571
64 bit: https://go.microsoft.com/fwlink/?LinkId=746572

Usage

When you encode a frame with H.264, the result is one or more "NAL units" (https://en.wikipedia.org/wiki/Network_Abstraction_Layer)

X264Net provides two methods for encoding frames. One method returns each NAL unit as a separate byte array. The other returns all NAL units that make up the encoded frame together in one array (in case you don't care about the NAL unit boundaries in your application).

The following C# code demonstrates basic usage of the wrapper. A complete example project is included in the solution.

// You should choose image dimensions that are divisible by 16, if you can.
const int width = 1280;
const int height = 720;

// Make sure you call Dispose() on the encoder when finished, or use a "using" block like this
using (x264net.X264Net encoder = new x264net.X264Net(width, height))
{
	// X264Net needs to be fed raw RGB data in the form of a byte array.
	byte[] rgb_data = new byte[width * height * 3];
	
	// ... you could do something here to fill the byte array with image data ...
	
	// Choose one of the encode methods based on your needs:
	
	// If you want to handle each NAL unit separately
	byte[][] NALUnits_Separate = encoder.EncodeFrame(rgb_data);
	
	// If you want just 1 byte array containing 1 or more H.264 NAL units
	byte[] NALUnits_AllTogether = encoder.EncodeFrameAsWholeArray(rgb_data);
}

Advanced Usage

At this time, X264Net is a very simplistic wrapper which provides no encoding options. If (when) you need more control over the encoding parameters, you can easily modify the wrapper to behave differently.

x264net's People

Contributors

bp2008 avatar

Stargazers

Ramesh Kumar K avatar

Watchers

Ramesh Kumar K avatar  avatar

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.