• Stars
    star
    205
  • Rank 191,264 (Top 4 %)
  • Language
    C++
  • Created almost 3 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Easily write MP4 videos from a C++ application.

Direct to Video (DTV)

Alt text

What does DTV do?

DTV is a library that provides a simple interface for generating video files from a C++ application. It uses FFmpeg which means that it supports the same encoders and performance that you would get from something like OBS. Unlike OBS, however, it is not dependent on the input being delivered in real-time. This means that regardless of the input frequency to DTV, the output will always be at the frame rate that you select.

How do I use it?

Check out the sample application that is provided with DTV. The interface is extremely minimalistic and is comprised of a handful of intuitive functions. The steps to write an entire video look like this:

  1. Start the encoder by calling the encoder.run(...) method. The encoder runs in its own thread and will wait for you to send video frames to it.
  2. Call encoder.newFrame(...) to get a frame from the buffer to write to. This comes in blocking and non-blocking versions. By calling encoder.newFrame(true), DTV will wait for a frame to become available if the encoder is lagging behind the input. Changing the input to false will cause the encoder to return nullptr if a frame is not available to write to. This can be useful if you'd prefer to miss frames over slowing down your application.
  3. Fill the frame with whatever data you like by populating the atg_dtv::Frame::m_rgb array with 8-bit values.
  4. Commit the frame by calling encoder.submitFrame().
  5. Repeat steps 2-4 until you have no frames left to write.
  6. Call encoder.commit() to inform the encoder that the video stream is over.
  7. Call encoder.stop() which will wait until the encoder finishes encoding buffered frames and then for the encoder thread to exit.

How do I build it?

You will need to have FFmpeg development libraries installed on your computer and the directory listed on your PATH. DTV has only been tested on Windows but in principle should build on other platforms. The cmake script that searches for FFmpeg libraries, however, is Windows/Linux specific and you'll have to modify cmake/FindFFmpeg.cmake to work for other platforms. (If you do this, please create a pull-request!)

For FFmpeg pre-built binaries, see the OBS installation instructions page.

Build Steps

  1. Make sure you have the latest version of CMake installed
  2. Make sure you have FFmpeg binaries installed (see above)
  3. Clone the repository: git clone https://github.com/ange-yaghi/direct-to-video.git
  4. cd direct-to-video
  5. mkdir build
  6. cd build
  7. cmake ..
  8. cmake --build .
  9. For MSVC users, check the build folder for a generated Visual Studio solution. You can use this solution like any other and will contain the DTV library as well as the demo application in separate projects.

More Repositories

1

engine-sim

Combustion engine simulator that generates realistic audio.
C++
8,669
star
2

manta-ray

An open source physically based renderer.
C++
752
star
3

simple-2d-constraint-solver

Simple physics simulator with support for rigid bodies, force generators and constraints.
C++
575
star
4

delta-studio

A game engine currently under development.
C++
347
star
5

piranha

High performance scripting and specification language.
C++
257
star
6

scs-2d-demo

Demo for the Simple 2D Constraint Solver.
C++
86
star
7

cereal-adventure

Platform game concept made with the Delta engine.
C++
52
star
8

delta-template

Template for creating applications that use the Delta Game Engine.
C++
36
star
9

engine-generator

Python engine generator for Engine Simulator
Python
22
star
10

cmake-template

Template for creating C++ projects that use CMake.
CMake
20
star
11

visualcpp_template

Template I use for my Visual C++ projects.
Python
13
star
12

atg-math

C++
12
star
13

piranha-vscode-extension

Visual Studio Code extension for the Piranha language.
9
star
14

csv-io

Simple library for IO using the CSV format.
C++
9
star
15

gradus

Command line utility to teach music composition
C++
6
star
16

ange-yaghi

Just personal information about me.
5
star
17

toccata

A program that monitors real-time input from a MIDI keyboard and tracks mistakes and timing accuracy.
C++
5
star
18

ant-world

Be your own ant in an anthropomorphic ant world!
C++
3
star
19

console_clock

Simple command line clock utility.
C++
2
star
20

tactical-destruction

A strategy and planning game I made in 2013.
C++
1
star
21

personal-finance-tracker

Database application to track personal finances.
C++
1
star
22

urbanity

Experimental project to generate photorealistic cityscapes.
C++
1
star
23

console_lib

CMake
1
star
24

beef-planet

C++
1
star
25

gstreamer-sandbox

Just a sandbox project to learn gstreamer.
C
1
star