Skip to content

Instantly share code, notes, and snippets.

@misaelnieto
misaelnieto / live-mjpeg-stream.py
Last active June 26, 2024 10:08
Streaming MJPEG over HTTP with gstreamr and python - WSGI version
#!/usr/bin/python
#based on the ideas from http://synack.me/blog/implementing-http-live-streaming
# Updates:
# - 2024-04-24: Apply suggestions from @Pin80
# Run this script and then launch the following pipeline:
# gst-launch videotestsrc pattern=ball ! video/x-raw-rgb, framerate=15/1, width=640, height=480 ! jpegenc ! multipartmux boundary=spionisto ! tcpclientsink port=9999
#updated command line
#gst-launch-1.0 videotestsrc pattern=ball ! videoconvert ! video/x-raw, framerate=15/1, width=640, height=480 ! jpegenc ! multipartmux boundary=spionisto ! #tcpclientsink port=9999
from multiprocessing import Queue
@austinmarton
austinmarton / recvRawEth.c
Created June 3, 2012 07:55
Receive raw Ethernet frames in Linux
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
#include <arpa/inet.h>
#include <linux/if_packet.h>
#include <linux/ip.h>
@austinmarton
austinmarton / linux_timerfd_example.c
Created July 13, 2012 09:23
Linux file descriptor timers example
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
@waveform80
waveform80 / gist:3390484
Created August 19, 2012 00:12
GStreamer 1 image overlay on video
# Working (overlays image on videotestsrc)
gst-launch-1.0 videomixer name=mix ! videoconvert ! xvimagesink multifilesrc location="test.png" caps="image/png,framerate=0/1" ! pngdec ! imagefreeze ! alpha method=0 alpha=0.5 ! mix. videotestsrc ! "video/x-raw,format=AYUV,framerate=25/1,width=320,height=240" ! mix.
# Fails (attempts to overlay image on webcam source)
gst-launch-1.0 videomixer name=mix ! videoconvert ! xvimagesink multifilesrc location="test.png" caps="image/png,framerate=0/1" ! pngdec ! imagefreeze ! alpha method=0 alpha=0.5 ! mix. v4l2src device=/dev/video0 ! "video/x-raw,format=YUY2,width=320,height=240" ! videoconvert ! mix.
# Output of failing command:
cat << EOF
Setting pipeline to PAUSED ...
/*
* TOTP: Time-Based One-Time Password Algorithm
* Copyright (c) 2015, David M. Syzdek <david@syzdek.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* 1. Redistributions of source code must retain the above copyright
@maddouri
maddouri / build-static-python.sh
Created December 6, 2015 22:42
A simple script that builds static versions of Python and LibPython using musl-libc
#!/bin/bash
# set -eux
# This a simple script that builds static versions of Python and LibPython using musl-libc
# Find the associated article at: http://general-purpose.io/2015/12/06/compiling-python-and-libpython-statically-using-musl-libc/
WORKING_DIR="/code/static-python"
MUSL_PREFIX="/code/static-python/musl"
PY_PREFIX="/code/static-python/python"
@engelmarkus
engelmarkus / gtkmm-example.cpp
Created May 18, 2016 22:31
Creating a window with gtkmm 3 and a glade description.
// g++ -std=c++14 -o gtkmm-example gtkmm-example.cpp `pkg-config --cflags --libs gtkmm-3.0`
#include <memory>
#include <gtkmm.h>
class MainWindow : public Gtk::ApplicationWindow {
public:
MainWindow(BaseObjectType* obj, Glib::RefPtr<Gtk::Builder> const& builder)
: Gtk::ApplicationWindow(obj)
, builder{builder}
@fortizc
fortizc / print_tst.py
Last active April 27, 2023 19:25
A very simple gst plugin in python
#!/usr/local/bin/python3
# -*- Mode: Python -*-
# vi:si:et:sw=4:sts=4:ts=4
# This is a modified version of https://github.com/GStreamer/gst-python/blob/master/examples/plugins/python/identity.py
import gi
gi.require_version("Gst", "1.0")
gi.require_version('GstBase', '1.0')
from gi.repository import Gst, GObject, GstBase
@reinzor
reinzor / stream_example.md
Last active July 2, 2024 19:46
GStreamer UDP stream examples

MJPEG

Server (Ubuntu 16.04)

gst-launch-1.0 -v filesrc location= /home/rein/Videos/big_buck_bunny_720p_30mb_0_0.mp4 ! decodebin ! videoconvert ! jpegenc ! rtpjpegpay ! udpsink host=localhost port=5000

Client (Ubuntu 16.04)

@suyashdamle
suyashdamle / client.py
Created April 22, 2019 15:40
Joint UDP-TCP client-server programs in Python using Socket Programming
import socket
HOST = 'localhost' # The server's hostname or IP address
PORT = 64532 # The port used by the server
use_tcp = False
if not use_tcp:
################# UDP CLIENT ####################