• Stars
    star
    156
  • Rank 239,589 (Top 5 %)
  • Language
    Python
  • Created about 12 years ago
  • Updated over 7 years ago

Reviews

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

Repository Details

Live video streaming server using animated GIFs, Python and Node.js

Live Video streaming using Animated GIFs

Preview

Sample

This sample video is just a fragment of a live video served by gifstreaming.

Warning

This is a toy project and it's not production ready. If you are seriously considering live video streaming using images, take a look at live_thumb. It uses much less bandwidth because the images are encoded as JPEG and it is more stable, since it uses nginx-push-stream to serve the images instead of this poorly tested node.js app.

Browser Support

All modern browsers since IE 5, that display the animation while download is in progress.

Usage

You need to have a stream of gif images (one per frame) at the input directory.

If you have ffmpeg and a input video, you can do it like this, to loop it continuously:

$ mkdir input
$ ffmpeg -i video.mp4 -loop 1 -pix_fmt pal8 -s 159x97 -r 10 input/in%d.gif

If you have a live RTMP stream handy:

$ ffmpeg -re -i rtmp://server/app/stream -pix_fmt pal8 -s 159x97 -r 10 input/in%d.gif

After that, run the Python script that will extract the gif frames and prepare then to be served:

$ mkdir parts
$ python transform.py

The server is a simple node.js script:

$ node server.js

With your browser, visit http://localhost:8080/

How it works

When a HTTP request is received, the node.js server delivers the Animated GIF Header, and frames for the first 10 seconds of video, but does not close the connection. After that, it watches the local directory for new frames and pushes then to all connected users. Since the GIF file format does not specify the number of frames and the Trailer is never delivered, the browser will keep the connection open (at least while it has enough memory :-).

The Python server creates the animated GIF header (Header, Logical Screen Descriptor, Application Extension) based on the first frame. For all the subsequent frames, it removes the Header, and transform the Global Color Table into a Local Color Table.

GIF file

A good explanation of the GIF spec can be found here: http://www.matthewflickinger.com/lab/whatsinagif/bits_and_bytes.asp

Enjoy!

More Repositories

1

live_thumb

Live thumbnail using MJPEG and nginx_push_stream
Python
100
star
2

lua-resty-cassandra

Pure Lua Cassandra client using CQL binary protocol
Lua
67
star
3

hls-loop

Infinite HLS live loop server
TypeScript
49
star
4

cep

Biblioteca em Python para consulta de CEPs via site dos correios
Python
37
star
5

facts

Matrix Factorization based recsys in Golang. Because facts are more important than ever
Go
33
star
6

bullock

Distributed lock for Python using Redis
Python
31
star
7

bazinga

Bazinga is an incremental test runner plugin for nose
Python
27
star
8

planets

Gravity simulation in javascript
JavaScript
25
star
9

sandals

SQL for Pandas
Python
25
star
10

vi-video

Edit videos with vi or your favorite text editor
Python
18
star
11

duelo

An incomplete node.js game
JavaScript
16
star
12

strogonoff

Steganography with Go
Go
11
star
13

hackaton_rank

Top projetos em número de commits do hackinpoa
Python
11
star
14

media-source-playground

Media source extensions playground
9
star
15

feiradetector

Feira da fruta detector
Python
7
star
16

gene

Distributed Genetic Algorithm in Clojure
Clojure
6
star
17

infraero

Biblioteca para fazer scrap do site da infraero
Python
5
star
18

lua_jit_extract_audio

Example of how to extract audio with lua jit and libavcodec (ffmpeg)
C
5
star
19

mgof

Multinomial goodness of fit in Redis for Anomaly Detection
Lua
5
star
20

python-data-science

Tutorial data science com python
4
star
21

similarnn

Similarity server using topic modelling and approximate nearest neighbours
Python
4
star
22

github-recs

GitHub repositories recommendations using Go and AppEngine
Go
4
star
23

lastfm

Python wrapper for Last.fm API
Python
4
star
24

fms

FMS (Flash Media Server) API Client
Python
3
star
25

scrum-you

Another to-do list application for Google App Engine using Flask
Python
3
star
26

freecep

Retomando posse dos dados públicos de CEP
JavaScript
3
star
27

to-a-pe

Google transit data feed website for Google App Engine
Python
2
star
28

Project-Euler

Practicing TDD, Java, and JUnit with Project Euler problems
Java
2
star
29

codejam

Google Code Jam
C
2
star
30

depoisdavirgula

Controle financeiro no Google App Engine
JavaScript
2
star
31

parallel_redis

Redis with support for concurrent scripts in Lua
C
2
star
32

lua-rpc

toy project for lua rpc
Lua
1
star
33

video-clock

Create a video with a clock
Python
1
star
34

jbochi.github.com

Ruby
1
star
35

evo

Python evostream client
Python
1
star
36

recsyschallenge2015

Visualization of recsys challenge for 2015
1
star
37

strogonoff-demo

Strogonoff demo on Google Application Engine's Go runtime
Go
1
star
38

laugh

Ruby
1
star