• Stars
    star
    646
  • Rank 69,672 (Top 2 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created about 6 years ago
  • Updated about 1 year ago

Reviews

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

Repository Details

Basic Real-time AV Editor - allowing you to preview, mix, and route live audio and video streams on the cloud

Brave

Python 3.6 license

This project is an open-source prototype. See 'Project status' and 'License' below for more.

Brave is a Basic real-time (remote) audio/video editor. It allows LIVE video (and/or audio) to be received, manipulated, and sent elsewhere. It is API driven and is designed to work remotely, such as on the cloud.

Example usage includes:

  • Forwarding RTMP from one place to another
  • Changing the size of video, and having a holding slate if the input disappears
  • Mixing two or more inputs
  • Adding basic graphics (images, text, etc)
  • Previewing video streams using WebRTC

Brave is based on GStreamer. It is, in one sense, a RESTful API for GStreamer (for live audio/video handling).

To learn more, read below, or see the FAQ, API guide, How-to guide and Config file guide.

Architecture diagram

Architecture diagram

Web interface screenshot

Web interface screenshot

This web interface is optional; Brave can be controlled via the API or startup config file.

Alternatives to consider

Similar open-source projects to this include:

Capabilities

Brave allows you to configure inputs, outputs, mixers and overlays. You can have any number of each (subject to the limitations of your server). They can be created at startup using a config file, or created and changed dynamically via REST API.

Inputs

An input is a source of audio or video. There can be any number of inputs, added or removed at any time, which can then be sent to mixers and outputs. Input types include:

  • Live and non-live streams, through protocols such as RTMP, RTSP, and HLS
  • Files (e.g. mp4 or mp3) - either local or downloaded remotely
  • Images (PNG/SVG/JPEG)
  • MPEG or OGG retrieved via a TCP connection
  • Test audio / video streams

Read more about input types.

Outputs

An output is how the constructed audio/video is then sent, served or saved. There can be any number of outputs, added or removed at any time. Output types include:

  • RTMP - which can then send to Facebook Live and YouTube Live
  • TCP Server - which clients such as VLC can connect to
  • Local file - writing an mp4 file
  • Image - writing a JPEG file of the video periodically
  • WebRTC - for near-realtime previewing of the video (and audio)
  • AWS Kinesis Video Stream
  • Local - for playback on a local machine

Read more about output types.

Overlays

An overlay is something that can overlay the video from an input or mixer. (Overlays do not exist for audio.) There can be any number of overlays.

Supported overlay types:

  • Clock (place a clock over the video)
  • Text (write text over the video)
  • Effects

Read more about overlay types.

Mixers

There can be any number of mixers. They can take any number of inputs (including the output from another mixer). It can send to any number of outputs. Read more about mixers.

Project status

This project is still work in progress, and has not been thoroughly tested or used in any production environments.

Installation

First, install the dependencies, and then clone this repo.

Dependencies

  • Python 3.6 (or higher)
  • GStreamer 1.14.3 or higher (including the good/bad/ugly packages)
  • Multiple Python libraries (installed by pipenv)

Install guides

How to use

To start:

./brave.py

Brave has an API and web interface, which by default is on port 5000. So if running locally, access by pointing your web browser at:

http://localhost:5000/

To change the port, either set the PORT environment variable, or set api_port in the config file.

Configuring inputs, outputs, overlays and mixers

There are three ways to configure Brave:

  1. Web interface
  2. REST API (plus optional websocket)
  3. Config file

Web interface

The web interface is a simple client-side interface. It uses the API to allow the user to view and control Brave's setup.

The web interface can be found at http://localhost:5000/. (If running on a remote server, replacing localhost with the name of your server.)

API

The API allows read/write access of the state of Brave, including being able to create new inputs, outputs, and overlays dynamically. See the API documentation for more.

Config file

Brave can be configured by config file. This includes being able to have certain inputs, mixers, outputs and overlays created when Brave starts.

Provide another config with the -c parameter, e.g.

./brave.py -c config/example_empty.yaml

See the Config File documentation for more.

STUN and TURN servers for WebRTC

A STUN or TURN server is likely required for Brave's WebRTC to work between remote connections. Brave defaults to Google's public STUN server; this can be overridden in the config file, or by setting the STUN_SERVER environment variable. Likewise, a TURN_SERVER environment variable can be set if a TURN server is required. Its value should be in the format <usernane>:<credential>@<host>:<port>.

Tests

Brave has functional black-box tests that ensure the config file and API is working correctly. To run them:

pytest

A few useful pytest options:

  • To see the output, add -s.
  • To see the name of each test being run, add -v.
  • To run only failing tests, add --lf.
  • To filter to tests that match a string: -k <string_to_match>

All tests should pass.

Code quality (linting)

To check code quality, Flake8 is used. To run:

flake8 --count brave

Debugging

Brave is based on GStreamer, which is a complex beast. If you're experiencing errors or reliability issues, here's a guide on how to debug.

Run the tests

Run the test framework.

Logging

Brave outputs log messages, which should include all errors. To see finer grained logging, set LOG_LEVEL=debug, i.e.

LOG_LEVEL=debug ./brave.py

For even more, ask GStreamer to provide much more debug output with:

GST_DEBUG=4 LOG_LEVEL=debug ./brave.py

Analyse the elements

Brave creates multiple GStreamer pipelines, each containing multiple linked elements. Spotting which element has caused an error can help track down the problem.

To see, select 'Debug view' from the web interface. Or, visit the /api/elements API endpoint.

Look out for:

  • Elements not in the PLAYING state
  • Elements with different caps

If there are situations where it work and where it doesn't, try capturing the two /elements responses, and diffing them.

Switch off audio or video

If you're manipulating video that has audio, try disabling audio using enable_audio: false in the config file.

And then similarly, disabling video using enable_video: false.

This will help inform if it's the audio handling or video handling that's at fault.

Divide and conquer

If you repeatably get an error, identify what's causing it by removing inputs/outputs/overlays until the problem goes away. Try and find the minimum required to cause the problem.

License

Brave is licensed under the Apache 2 license.

Brave uses GStreamer which is licensed under the LGPL. GStreamer is dynamically linked, and is not distributed as part of the Brave codebase. Here is the GStreamer license. Here is the GStreamer licensing documentation.

Copyright (c) 2019 BBC

More Repositories

1

wraith

Wraith — A responsive screenshot comparison tool
Ruby
4,813
star
2

Imager.js

Responsive images while we wait for srcset to finish cooking
JavaScript
3,833
star
3

peaks.js

JavaScript UI component for interacting with audio waveforms
JavaScript
2,886
star
4

audiowaveform

C++ program to generate waveform data and render waveform images from audio files
C++
1,658
star
5

sqs-consumer

Build Amazon Simple Queue Service (SQS) based applications without the boilerplate
TypeScript
1,541
star
6

bbplot

R package that helps create and export ggplot2 charts in the style used by the BBC News data team
R
1,434
star
7

simorgh

The BBC's Open Source Web Application. Contributions welcome! Used on some of our biggest websites, e.g.
TypeScript
1,394
star
8

VideoContext

An experimental HTML5 & WebGL video composition and rendering API.
JavaScript
1,318
star
9

waveform-data.js

Audio Waveform Data Manipulation API – resample, offset and segment waveform data in JavaScript.
JavaScript
936
star
10

tal

TV Application Layer
JavaScript
550
star
11

react-transcript-editor

A React component to make correcting automated transcriptions of audio and video easier and faster. By BBC News Labs. - Work in progress
JavaScript
494
star
12

psammead

React component library for BBC World Service and more
JavaScript
320
star
13

newslabs-datastringer

Monitor datasets, gets alerts when something happens
JavaScript
212
star
14

html5-video-compositor

This is the BBC Research & Development UX Team's experimental shader based video composition engine for the browser. For new projects please consider using or new VideoContext library https://github.com/bbc/videocontext .
JavaScript
207
star
15

REST-API-example

Simple REST API example in Sinatra
Ruby
193
star
16

grandstand

BBC Grandstand is a collection of common CSS abstractions and utility helper classes
SCSS
190
star
17

sqs-producer

Simple scaffolding for applications that produce SQS messages
TypeScript
181
star
18

r-audio

A library of React components for building Web Audio graphs.
JavaScript
168
star
19

chaos-lambda

Randomly terminate ASG instances during business hours
Python
163
star
20

turingcodec

Source code for the Turing codec, an HEVC software encoder optimised for fast encoding of large resolution video content
C++
153
star
21

bbc-vamp-plugins

A collection of audio feature extraction algorithms written in the Vamp plugin format.
C++
152
star
22

bbc-a11y

BBC Accessibility Guidelines Checker
Gherkin
134
star
23

rcookbook

Reference manual for creating BBC-style graphics using the BBC's bbplot package built on top of R's ggplot2 library
HTML
127
star
24

gel-grid

A flexible code implementation of the GEL Grid Guidelines
SCSS
126
star
25

audio-offset-finder

Find the offset of an audio file within another audio file
Python
124
star
26

datalab-ml-training

Machine Learning Training
Jupyter Notebook
117
star
27

Similarity

Calculate similarity between documents using TF-IDF weights
Ruby
115
star
28

viewporter

In-browser responsive testing tool.
CSS
114
star
29

flashheart

A fully-featured Node.js REST client built for ease-of-use and resilience
JavaScript
114
star
30

qtff-parameter-editor

QuickTime file parameter editor for modifying transfer function, colour primary and matrix characteristics
C++
114
star
31

gel-typography

A flexible code implementation of the GEL Typography Guidelines
CSS
111
star
32

consumer-contracts

Consumer-driven contracts in JavaScript
JavaScript
105
star
33

color-contrast-checker

An accessibility checker tool for validating the color contrast based on WCAG 2.0 and WCAG 2.1 standards.
JavaScript
81
star
34

slayer

JavaScript time series spike detection for Node.js and the browser; like the Octave findpeaks function.
JavaScript
77
star
35

lrud

Left, Right, Up, Down. A spatial navigation library for devices with input via directional controls.
JavaScript
76
star
36

audio_waveform-ruby

Ruby gem that provides access to audio waveform data files generated by audiowaveform
Ruby
76
star
37

software-engineering-technical-assessments

Technical assessment for hiring
Kotlin
71
star
38

nghq

An implementation of Multicast QUIC https://tools.ietf.org/html/draft-pardue-quic-http-mcast-07
C
67
star
39

bigscreen-player

Simplified media playback for bigscreen devices
JavaScript
65
star
40

speculate

Automatically generates an RPM Spec file for your Node.js project
JavaScript
64
star
41

zeitgeist

Twitter Zeitgeist
Ruby
62
star
42

wally

Cucumber feature viewer and navigator
Ruby
57
star
43

theano-bpr

An implementation of Bayesian Personalised Ranking in Theano
Python
54
star
44

ShouldIT

A language agnostic BDD framework.
JavaScript
53
star
45

news-gem-cloudwatch-sender

Send metrics to InfluxDB from Cloudwatch
Ruby
53
star
46

unicode-bidirectional

A Javascript implementation of the Unicode 9.0.0 Bidirectional Algorithm
JavaScript
45
star
47

subtitles-generator

A node module to generate subtitles by segmenting a list of time-coded text - BBC News Labs
JavaScript
44
star
48

accessibility-news-and-you

We want to be the most accessible news website in the world. This is how.
HTML
44
star
49

codext

VS Code's editor shipped as a browser extension.
JavaScript
42
star
50

talexample

An example TV app written using TAL
JavaScript
40
star
51

rdfspace

RDFSpace constructs a vector space from any RDF dataset which can be used for computing similarities between resources in that dataset.
Python
39
star
52

digital-paper-edit-client

Work in progress - BBC News Labs digital paper edit project - React Client
JavaScript
39
star
53

clientside-recommender

A client-side recommender system implemented in Javascript.
Java
39
star
54

gel

JavaScript
39
star
55

childrens-games-starter-pack

This is the Starter Pack for Children's games, containing everything a games developer might need to start building an HTML5 game for Children's BBC. Every game should be forked into a new repository from this repo.
JavaScript
38
star
56

alephant

The Alephant framework is a collection of isolated Ruby gems, which interconnect to offer powerful message passing functionality built up around the "Broker" pattern.
Ruby
37
star
57

vc2-reference

A reference encoder and decoder for SMPTE ST 2042-1 "VC-2 Video Compression"
C++
34
star
58

ruby-lsh

Locality Sensitive Hashing in Ruby
Ruby
32
star
59

Strophejs-PubSub-Demo

A simple demo of Publish/Subscribe in the browser using Strophe.js
JavaScript
31
star
60

lrud-spatial

Left, Right, Up, Down. A spatial navigation library for devices with input via directional controls.
JavaScript
30
star
61

diarize-jruby

A simple toolkit for speaker segmentation and identification
Ruby
30
star
62

pydvbcss

Python library that implements DVB protocols for companion synchronisation
Python
28
star
63

gel-sass-tools

A collection of Sass Settings & Tools which align to key GEL values
SCSS
27
star
64

a11y-tests-web

Runs automated accessibility tests against configurable lists of webpages
JavaScript
27
star
65

RadioVisDemo

RadioDNS and RadioVIS Slideshow Protocol Demo
Python
27
star
66

device-discovery-pairing

Analysis and background research on discovery and pairing for the MediaScape project
26
star
67

node-canvas-lambda-deps

Node Canvas AWS Lambda dependencies i.e. compiled shared object files for Cairo, Pixman, libpng, libjpeg etc.
JavaScript
26
star
68

clever-thumbnailer

Audio thumbnail generator
C
25
star
69

spassky

Distributed web testing tool
JavaScript
25
star
70

bbc-speech-segmenter

A complete speech segmentation system using Kaldi and x-vectors for voice activity detection (VAD) and speaker diarisation.
Shell
24
star
71

genie

BBC Genie Games Framework
JavaScript
24
star
72

media-sequence

HTML5 media sequenced playback API: play one or multiple sequences of a same audio or video with plain JavaScript.
JavaScript
24
star
73

Chart.Bands.js

Chart.js plugin to allow banding on a chart
JavaScript
23
star
74

newslabs-Text_Analytics

A space for code and projects around analysing news content
Python
23
star
75

curriculum-data

BBC Curriculum Instance Data
23
star
76

cloudflare-queue-consumer

Build Cloudflare Queues based applications without the boilerplate (based on SQS Consumer)
TypeScript
23
star
77

videocontext-devtools

Chrome DevTools extension for easy VideoContext debugging.
JavaScript
22
star
78

bmx

Library and utilities to read and write broadcasting media files. Primarily supports the MXF file format
C++
22
star
79

adaptivepodcasting

A project exploring the potential of media which adapts based on sensors and data
JavaScript
21
star
80

UCMythTV

A full implementation of Universal Control 0.6.0 for use on a computer running Mythbuntu with a slightly modified version of MythTV (patches and configure script included).
Python
20
star
81

rdfsim

Large RDF hierarchies as vector spaces
Python
20
star
82

bug

Started life at BBC News - BUG enables control and monitoring of broadcast kit from a single web interface.
JavaScript
20
star
83

digital-paper-edit-electron

Work in progress - BBC News Labs digital paper edit project - Electron, Cross Platform Desktop app - Mac, Windows, Linux
C++
20
star
84

gst-ttml-subtitles

Library and elements that add support for TTML subtitles to GStreamer.
C
19
star
85

dvbcss-synctiming

Measuring synchronisation timing accuracy for DVB Compainion Screen Synchronisation TVs and Companions
Python
19
star
86

fcpx-xml-composer

Work in progress - Module to Convert a json sequence into an FCPX XML. For BBC News Labs digital paper edit project
JavaScript
18
star
87

bbcrd-brirs

An impulse response dataset for dynamic data-based auralisation of advanced sound systems
Common Lisp
18
star
88

MiD

Make it Digital: the BBC's Digital Creativity initiative
Arduino
17
star
89

device_api-android

DeviceAPI-Android
Ruby
17
star
90

tams

Time Addressable Media Store API
Makefile
17
star
91

gs-sass-tools

A collection of Sass variables, functions and mixins, part of BBC Grandstand
CSS
16
star
92

enzyme-adapter-inferno

Inferno enzyme adapter
JavaScript
16
star
93

get-title

Extract the best title value from within HTML head elements.
JavaScript
16
star
94

morty-docs

Generate a static website from markdown files
JavaScript
16
star
95

storyplayer

BBC Research & Development's Object Based Media Player
TypeScript
15
star
96

dialogger

Text-based media editing interface
JavaScript
15
star
97

bbcat-base

Base library for the BBC Audio Toolbox
C++
15
star
98

origin_simulator

A tool to simulate a (flaky) upstream origin during load and stress tests.
Elixir
15
star
99

catflap-camera

Raspberry Pi based catflap-triggered camera. As seen on TV.
Python
15
star
100

citron

Citron is an experimental quote extraction system created by BBC R&D
Python
15
star