Code Monkey home page Code Monkey logo

overscan's Introduction

Overscan

A study in live video broadcasting with the Racket programming language.

The goal of this project is to learn Racket and to better understand the problems involved in:

  • The Real-Time Messaging Protocol (RTMP) and constructing and streaming unbounded audio and video feeds.
  • The Twitch and Facebook Live API's, for authentication, broadcasting live video streams, and gathering audience data.
  • Video compositing in software.

Originally, the end-goal was to build a toolkit like that found in StreamPro or Streamlabs (née TwitchAlerts) but using a Racket DSL for on-the-fly compositing and graphics.

Now, this project's ambition is to provide a comprehensive live-coding environment for video compositing and broadcasting. This project is inspired by other live-coding environments like Impromptu/Extempore and Overtone.

It is split into three parts:

  1. The ffi/unsafe/introspection module. This module provides dynamic Racket bindings to GObject Introspection, allowing interaction with C GObject libraries using common Racket idioms (i.e. providing racket/class forms such as send and get-field for GObjects).
  2. The gstreamer collection. Using the aforementioned Introspection module, this collection provides Racket bindings for GStreamer, the open source multimedia framework.
  3. The overscan collection and language. This provides a DSL for building a GStreamer pipeline for capturing common video sources (cameras and screens), compositing multiple sources, including generated graphics, and then encoding them and pushing them along to an RTMP server (like Twitch). All of this is designed to happen within a Racket REPL session, allowing the broadcaster full control over the stream by evaluating S-expressions. That's the idea, at least.

You can follow the development along at http://tinyletter.com/wunsch. Read archives of previous weekly devlogs at http://www.markwunsch.com/tinyletter/.

Installation

Overscan has been tested on macOS Sierra with Racket v6.12 and GStreamer v1.14.0. With a working Racket installation you can install with raco:

raco pkg install overscan

For Overscan to do anything meaningful, you also need to install GStreamer and necessary plugins. Using homebrew:

brew install gstreamer

This will install gstreamer along with dependencies glib and gobject-introspection, all of which are required.

You also need to install GStreamer plugins:

brew install gst-plugins-base --with-pango

brew install gst-plugins-good

brew install gst-plugins-bad --with-rtmpdump --with-fdk-aac

brew install gst-plugins-ugly --with-x264

Copyright © 2017 - 2018 Mark Wunsch

This package is distributed under the GNU Lesser General Public License (LGPL). This means that you can link overscan into proprietary applications, provided you follow the rules stated in the LGPL. You can also modify this package; if you distribute a modified version, you must distribute it under the terms of the LGPL, which in particular means that you must release the source code for the modified software. See http://www.gnu.org/copyleft/lesser.html for more information.

overscan's People

Contributors

mwunsch 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

overscan's Issues

error 'couldn't open "libgirepository-1.0.dylib" '

Hi,

Firstly - thank you for making #lang overscan - it is much appreciated and I look forward to twitch streaming some coding sessions using it.

I have found that Overscan fails to find libgirepository-1.0.dylib.

When I run:

#lang overscan
(broadcast (videotestsrc)
           (audiotestsrc)
           (filesink "/dev/null"))

DrRacket returns:

Welcome to DrRacket, version 7.2 [3m].
Language: overscan, with debugging; memory limit: 2048 MB.
. ffi-lib: couldn't open "libgirepository-1.0.dylib" (dlopen(libgirepository-1.0.dylib, 6): image not found)

Interactions disabled: overscan does not support a REPL (no #%top-interaction)

I understand if you have moved on from this project. I'm going to persist in trying to get it working and will submit a PR if I'm successful.

If you can offer any advice it would be appreciated.

Kind regards,

Stephen

My notes:

  • Racket 7.2 installed via brew cask install racket
  • GStreamer installed via brew install gstreamer
  • brew install gst-plugins-base --with-pango fails with error: Error: invalid option: --with-pango
  • brew install gst-plugins-good --with-aalib --with-libvpx fails with error: Error: invalid option: --with-aalib (removing the --with-aalib flag results in the error Error: invalid option: --with-libvpx)
  • brew install gst-plugins-bad --with-rtmpdump --with-fdk-aac fails with error: Error: invalid option: --with-rtmpdump
  • brew install gst-plugins-ugly --with-x264 fails with error: Error: invalid option: --with-x264
  • brew install pango reports: pango 1.42.4_1 is already installed and up-to-date `
  • macOS 10.14.2 (TODO: windows 10)
  • Another language, #lang video (a DSL for editing videos), uses(require ...) to get dependencies via the package https://github.com/videolang/native-pkgs (see https://github.com/videolang/video/blob/testing/info.rkt ) - maybe this is a better approach than brew
  • running without flags seems to succeed:
Miriams-MBP:lib spdegabrielle$ brew install gst-plugins-base
Warning: gst-plugins-base 1.14.4 is already installed and up-to-date
To reinstall 1.14.4, run `brew reinstall gst-plugins-base`
Miriams-MBP:lib spdegabrielle$ brew install gst-plugins-good
Warning: gst-plugins-good 1.14.4_1 is already installed and up-to-date
To reinstall 1.14.4_1, run `brew reinstall gst-plugins-good`
Miriams-MBP:lib spdegabrielle$ brew install gst-plugins-bad
Warning: gst-plugins-bad 1.14.4 is already installed and up-to-date
To reinstall 1.14.4, run `brew reinstall gst-plugins-bad`
Miriams-MBP:lib spdegabrielle$ brew install gst-plugins-ugly
Warning: gst-plugins-ugly 1.14.4_2 is already installed and up-to-date
To reinstall 1.14.4_2, run `brew reinstall gst-plugins-ugly`
Miriams-MBP:lib spdegabrielle$ 

Runs on Linux and Racket 8.0

Not really an issue, just to let folks know that I got it running on Linux, at least the basic videotestsrc example. Specifically, NixOS.

Along with raco pkg install overscan, I needed to make available gstreamer, its plugins (I tried only base and good at first but got a contract error, so added bad and ugly too) and gobject-introspection in my environment, that's it.

Here's a shell.nix that I used:

{ pkgs ? import <nixpkgs> {} }:

pkgs.mkShell {
  buildInputs = with pkgs; [
    gst_all_1.gstreamer
    gst_all_1.gst-plugins-base
    gst_all_1.gst-plugins-good
    gst_all_1.gst-plugins-bad
    gst_all_1.gst-plugins-ugly
    gobject-introspection
  ];

  LD_LIBRARY_PATH = [
    "${pkgs.gobject-introspection}/lib"
  ];

  GST_PLUGIN_PATH_SYSTEM_1_0 = with pkgs.gst_all_1; [
    "${gst-plugins-base}/lib:${gst-plugins-good}/lib:${gst-plugins-bad}/lib:${gst-plugins-ugly}/lib"
  ];
}

Issue with gobject introspection

Hi!

I'm trying to get introspection working in racket and I have an issue.

The following racket code does not work:

#lang racket    
    
(require ffi/unsafe/introspection)    
    
(define gtk (introspection 'Gtk "3.0"))    
(define vte (introspection 'Vte "2.91"))    
(define glib (introspection 'GLib))          
    
((gtk 'init) 0 #f)    
    
(define window ((gtk 'Window) 'new 'toplevel))    
(define terminal ((vte 'Terminal) 'new))    
    
(connect window 'destroy (lambda (a b) ((gtk 'main_quit))))    
      
(gobject-send terminal     
  'spawn_sync    
  'default            
  "/home/pedro"            
  #("/bin/bash")    
  #f    
  'default    
  #f    
  #f    
  #f    
)
    
(gobject-send window 'add terminal)    
(gobject-send window 'show_all)        
((gtk 'main))    

The equivalent python code works:

import gi    
gi.require_version('Gtk', '3.0')    
gi.require_version('Vte', '2.91')    
from gi.repository import Gtk, Vte, GLib    
                                            

window = Gtk.Window()    
terminal = Vte.Terminal()    
    
window.connect("destroy", Gtk.main_quit)    
            
terminal.spawn_sync(    
    Vte.PtyFlags.DEFAULT,    
    "/home/pedro",    
    ["/bin/bash"],    
    None,    
    GLib.SpawnFlags.DEFAULT,    
    None,    
    None,    
)    
     
window.add(terminal)    
window.show_all()       
Gtk.main()              

Do you know what could be the issue?
I'm still getting the hang of racket, but I'll be available to help in debugging/fixing the issue.

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.