Giter Club home page Giter Club logo

mjpeg-encoder's Introduction

MJPEG Video Encoder

Implementation of MJPEG video encoder in OpenMP and OpenCL.

Requirements

  • GCC 10.0, Clang 11 or above
  • OpenMP 4.5 or above (should included in above compiler)
  • OpenCL 1.2 or above
  • Linux or MinGW

Build

./.build.sh [clean]

Use clean if you want to a clean build.

About configure OpenCL path

If cmake cannot found your OpenCL, you can modify build script, and set following variables

-DOpenCL_INCLUDE_DIR=/usr/local/cuda/include/ \
-DOpenCL_LIBRARY=/usr/local/cuda/lib64/libOpenCL.so.1.1

Usage

Usage: mjpeg_encoder options
Options:
        -i --input <path>	RAW Video Path.
        -s --size <width>x<height>	Video resolution.
        -r --fps <fps>	Video FPS.
        -o --output <path>	Output path.
        -q --quality <number, [0-100]>	JPEG quality.
        -t --threads <number>	Use number threads.
        -k --kind <serial|openmp|opencl>	Select implementation, default is serial.
        -T --temp-dir <path>	Temp dir, default is system temp dir.
        -d --device <cpu|gpu>	default is cpu.
        -m --measure	Show time measure message.
        -h --help	Show usage.

Before run OpenCL version, ensure the folder opencl-kernel in your working directory.

Sample Videos

Filename Resolution FPS Download Link
Clip-720x480-f30.raw 720x480 30 Google Drive
winsat-1280x720-f24.raw 1280x720 24 Google Drive

Example

  • Encode Clip-720x480-f30.raw with 3 threads, quality = 95 via OpenMP, save to abc.avi.

    ./mjpeg_encoder -i Clip-720x480-f30.raw -s 720x480 -r 30 -t 3 -q 95 -k openmp -o abc.avi
    

    Output:

    ...
    Time: 00:00:05.00 / 00:00:05.00
    Video encoded, output file located at abc.avi
    
    RUN TIME: 1118
    
  • Encode winsat-1280x720-f24.raw via GPU, save to xyz.avi

    ./mjpeg_encoder -i winsat-1280x720-f24.raw -s 1280x720 -r 24 -k opencl -d gpu -o xyz.avi
    

    Output:

    Found 1 platforms
    Using device [Intel(R) UHD Graphics 630] on platform [Intel(R) OpenCL HD Graphics].
    Dev Init Time: 1649
    
    PaddingAndTransformColorSpace Time 18
    dctAndQuantization Time 10
    clEncode Time 3524
    GPU TIME: 3562
    DATA READ BACK TIME: 7
    CPU TIME: 6
    
    Time: 00:00:00.54 / 00:00:06.00
    ...
    00:00:06.00 / 00:00:06.00
    
    Video encoded, output file located atxyz.avi
    
    RUN TIME: 39143
    

How to Obtain RAW Format Video

  • Install FFmpeg

  • Convert your video via:

    ffmpeg -i input.mp4 -s 854x480 -r 20 -f rawvideo -pix_fmt bgra output.raw

    854x480 is your video's resolution, 20 is fps, input.mp4 is input video file and output.raw is output file.

mjpeg-encoder's People

Contributors

s911415 avatar ren-hao avatar johnlihello 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.