Skip to content

Instantly share code, notes, and snippets.

@shivasiddharth
shivasiddharth / ffmpeg-rtmp-streaming
Created June 21, 2020 13:53
Sample commands to stream Pi webcam video to RTMP sink
# Command for streaming USB Webcam to RTMP sink without audio
/usr/bin/ffmpeg -y -f v4l2 -video_size 640x480 -framerate 25 -i /dev/video0 -vcodec h264_omx -f flv rtmp://localhost/show/stream
# Command for streaming USB Webcam to RTMP sink with audio
/usr/bin/ffmpeg -y -f v4l2 -video_size 640x480 -framerate 25 -i /dev/video0 -vcodec h264_omx -c:a aac -b:a 160k -ar 44100 -f flv rtmp://localhost/show/stream
@shivasiddharth
shivasiddharth / nginx-rtmp-compiler.sh
Created June 21, 2020 13:41
Script to compile Nginx with RTMP module
#!/bin/bash
git clone https://github.com/sergey-dryabzhinsky/nginx-rtmp-module.git
sudo apt-get -y install build-essential libpcre3 libpcre3-dev libssl-dev
wget http://nginx.org/download/nginx-1.18.0.tar.gz
tar -xf nginx-1.18.0.tar.gz
cd nginx-1.18.0
./configure --with-http_ssl_module --add-module=../nginx-rtmp-module
make -j 1
sudo make install
@shivasiddharth
shivasiddharth / nginx-dash.conf
Created June 21, 2020 13:39
Sample Nginx conf file for Dash streaming
worker_processes auto;
events {
worker_connections 1024;
}
# RTMP configuration
rtmp {
server {
listen 1935;
chunk_size 4000;
@shivasiddharth
shivasiddharth / nginx-hls-dash.conf
Created June 21, 2020 13:37
Sample Nginx conf file for HLS and Dash streaming
worker_processes auto;
events {
worker_connections 1024;
}
# RTMP configuration
rtmp {
server {
listen 1935;
chunk_size 4000;
@shivasiddharth
shivasiddharth / nginx-hls.conf
Created June 21, 2020 13:36
Sample Nginx conf file for HLS streaming
worker_processes auto;
events {
worker_connections 1024;
}
# RTMP configuration
rtmp {
server {
listen 1935;
chunk_size 4000;
@shivasiddharth
shivasiddharth / piffmpegcompiler.sh
Last active June 21, 2020 16:58
Script to compile FFMPEG on Raspberry Pi for OMX acceleration
#!/bin/bash
echo "Compiling FFMPEG.........."
echo ""
sudo apt-get -y install autoconf automake build-essential cmake doxygen git graphviz imagemagick libasound2-dev libass-dev libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev libfreetype6-dev libgmp-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libopus-dev librtmp-dev libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-net-dev libsdl2-ttf-dev libsnappy-dev libsoxr-dev libssh-dev libssl-dev libtool libv4l-dev libva-dev libvdpau-dev libvo-amrwbenc-dev libvorbis-dev libwebp-dev libx264-dev libx265-dev libxcb-shape0-dev libxcb-shm0-dev libxcb-xfixes0-dev libxcb1-dev libxml2-dev lzma-dev meson nasm pkg-config python3-dev python3-pip texinfo wget yasm zlib1g-dev libgmp3-dev libgmp-dev libdrm-dev
cd /home/pi/
if [ ! -d ffmpeg/ffmpeg-libraries ]
then
mkdir -p ~/ffmpeg/ffmpeg-libraries
@shivasiddharth
shivasiddharth / swappartitioncreator.sh
Last active June 21, 2020 15:28
Script to create swap partition on Pi
#!/bin/bash
#Creates swap partition on boards with lesser than 3.5GB Memory/RAM
echo ""
echo "Checking memory size.........."
Totalmem=$(cat /proc/meminfo|grep MemTotal|grep -o '[0-9]*')
if (($Totalmem > 3500000)); then
echo ""
echo "You have got enough memory. No need for a swap partition.........."
@shivasiddharth
shivasiddharth / chatbotserver.py
Last active June 10, 2020 10:16
Python script for Raspberry Pi chatbot server
#!/usr/bin/env python3
import socket
import sys
import RPi.GPIO as GPIO
import _thread
import datetime
import random
import requests
import os
@shivasiddharth
shivasiddharth / Breaks_At_Set_Intervals.xspf
Created June 1, 2020 16:16
VLC playlist sample files that simulate adverts playback during movies or videos
<?xml version="1.0" encoding="UTF-8"?>
<playlist xmlns="http://xspf.org/ns/0/" xmlns:vlc="http://www.videolan.org/vlc/playlist/ns/0/" version="1">
<title>Playlist</title>
<trackList>
<track>
<location>file://192.168.1.4/shivasiddharth/20180905/SIDDHY%20GENERAL/Movies/2%20States%20(2014).mp4</location>
<extension application="http://www.videolan.org/vlc/playlist/0">
<vlc:id>0</vlc:id>
<vlc:option>file-caching=1000</vlc:option>
<vlc:option>stop-time=1800.000</vlc:option>
@shivasiddharth
shivasiddharth / nginx-installer.sh
Last active June 2, 2020 11:40
Nginx installer script
#!/bin/bash
sudo apt-get update
sudo apt-get install nginx
sudo apt-get install libnginx-mod-rtmp
cat << EOF >> /etc/nginx/nginx.conf
rtmp {
server {
listen 1935;
chunk_size 4096;