Skip to content

Instantly share code, notes, and snippets.

View chptx's full-sized avatar

HM. Yen chptx

  • Earth
View GitHub Profile
@chptx
chptx / simple_mjpeg_streamer_http_server
Created November 4, 2021 05:58 — forked from n3wtron/simple_mjpeg_streamer_http_server
Simple Python Motion Jpeg (mjpeg server) from webcam. Using: OpenCV,BaseHTTPServer
#!/usr/bin/python
'''
Author: Igor Maculan - n3wtron@gmail.com
A Simple mjpg stream http server
'''
import cv2
import Image
import threading
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
from SocketServer import ThreadingMixIn
Hey! Relatively seasoned JS dev.
I'm mostly working on larger projects with a large system of other dependencies.
I love p5.js, but I'm not sure I would use p5 in one of my own projects unless it was a site really based around the canvas. p5 is hard to shim in with other dependencies and seems really designed to be used as an "all in one" package.
I play around with it as a sketch pad, but if I wanted to fit in a canvas element as part of a larger scope, I would probably use something else. p5 is huge, as far as downloads go, and I would be concerned about the extra latency if I'm already loading a large amount of JS into a project.
That being said, it does what it says on the box incredibly well. It abstracts away the web APIs and makes them understandable and quick to work with. Graphics and audio programming is difficult by its nature, and there's a long valley between the inception of a visual idea and its creation. For someone who likes art but doesn't code, it's great.
@chptx
chptx / latency.txt
Last active January 23, 2018 03:55
raspberry pi streaming low latency links
http://www.wumpus-cave.net/2015/11/06/low-latency-fpv-streaming-with-the-raspberry-pi/
https://wiki.jmk.hu/wiki/Live_Video_Streaming_with_Raspberry_Pi_camera_module
https://blog.tkjelectronics.dk/2013/06/how-to-stream-video-and-audio-from-a-raspberry-pi-with-no-latency/
https://www.raspberrypi.org/documentation/raspbian/applications/camera.md
https://gstreamer.freedesktop.org/documentation/tutorials/basic/toolkit-integration.html

Try adding the following line at the bottom of the file /etc/modules and rebooting your Raspberry Pi.

bcm2835-v4l2 Mine now looks like this in toto:

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
@chptx
chptx / ffmpeg.md
Created January 23, 2018 02:41
use extpipe with ffmpeg
use_extpipe on
extpipe ffmpeg -y -f rawvideo -pix_fmt yuv420p -video_size %wx%h -framerate %fps -i pipe:0 -c:v h264_omx -profile:v high -b:v 3000000 -f mp4 %f.mp4

from motioneye-project/motioneyeos#365

Issue: FFMPEG GPU/Hardware acceleration is not enabled on RPI. FFPlay is jittery, patchy and takes close to 100% CPU.

Description: The video streaming of mpeg4 files is very slow ( the video streaming is playing like a slide show) as well as consumes between 95% and 97%. The CPU consumption increases with increase in screen size. Other tools on RPI such as built in Webbrowser shows the same MPEG4 files smooth, infact the Webbrowser shows HD (720p) quality video well and with about 30-35% CPU. Environment: RPI3, FFMPEG. FFMEG is compiled with MMAL decoder enabled and confirmed. Steps from Johnanath https://john.ly/rpi-h264-hw-acceleration/#comment-723" are used.

Rationale: The reason need to speed up FFMEG MMAL decoder on RPI 3 is that we are using PJSIP video call. PJSIP uses FFMPEG and is too is slow s(we believe for same reason FFMEG is slow) for a video call.

Setup and Tests As per johnathan comments, I have enabled h264_mmal and h264_omx for decoding and encoding video respectively while configuring ff

#!/usr/bin/env python3
"""
If set_window_handle on line 93 is commented out works, otherwise gets a SIGSEGV
Run under gdb:
$ gdb -ex r --args python glsink.py
Program received signal SIGSEGV, Segmentation fault.
@chptx
chptx / build.gradle
Last active January 29, 2016 06:34
create android gradle project
println GradleVersion.current().prettyPrint()
assert gradle.gradleVersion >= "1.10" // android plugin 0.10 requires Gradle 1.10, 1.11, 1.12
// after `gradle wrapper` it is possible to use './gradlew build' with Gradle version specified
task wrapper(type: Wrapper) {
gradleVersion = '1.12'
}
//{ "boilerplate part", possible extensions are commented
buildscript {
repositories {