Skip to content

Instantly share code, notes, and snippets.

View philhartung's full-sized avatar

Philipp Hartung philhartung

View GitHub Profile
@philhartung
philhartung / rtp-to-speaker.js
Last active June 11, 2020 20:41
Play raw audio from RTP stream
View rtp-to-speaker.js
const Speaker = require('speaker');
const dgram = require('dgram');
const client = dgram.createSocket('udp4');
var speaker = new Speaker({
channels: 2,
bitDepth: 16,
sampleRate: 48000
})
@philhartung
philhartung / aes67_relay.sh
Last active July 9, 2020 12:30
Relay AES67 RTP Stream. SDP/SAP is not implement here.
View aes67_relay.sh
#!/bin/sh
gst-launch-1.0 udpsrc address=239.69.161.58 port=5004 multicast-iface=eth0 !\
udpsink host=239.69.0.119 port=5004 qos=true qos-dscp=34 multicast-iface=eth1
View gst_rtp_test.sh
#!/bin/sh
gst-launch-1.0 audiotestsrc freq=880 !\
audioconvert !\
audio/x-raw, format=S24BE, channels=2, rate=48000 !\
rtpL24pay !\
application/x-rtp, clock-rate=48000, channels=2 !\
udpsink host=239.69.0.119 port=5004 qos=true qos-dscp=34 multicast-iface=en5
View monitor.sh
#!/bin/sh
ffplay -fs -f v4l2 -i /dev/video2 -input_format mjpeg -video_size 1920x1080 -framerate 60.0 -vf "format=yuv444p,split=4[a][b][c][d];\
[a]histogram=c=1,scale=w=-1:h=1080,pad=1920:ih:(ow-iw)/2[aa];\
[b]scale=1920x1080[bb];\
[c]waveform=scale=ire,scale=1920x1080,\
drawbox=0:85:1920:3:GreenYellow:fill,\
drawtext=text=100:x=0:y=50:fontsize=35:fontcolor=GreenYellow,\
drawbox=0:317:1920:3:GreenYellow:fill,\
drawtext=text=75:x=0:y=282:fontsize=35:fontcolor=GreenYellow,\
drawbox=0:546:1920:3:GreenYellow:fill,\
@philhartung
philhartung / sine.js
Last active June 9, 2021 21:56
Generate sine wave audio and output it to default audiodevice
View sine.js
const { RtAudio, RtAudioFormat } = require('audify');
const rtAudio = new RtAudio();
// constants
const samplerate = 48000;
const ffp = 48;
// audio device
let audioOutput = {
deviceId: rtAudio.getDefaultOutputDevice(),
@philhartung
philhartung / ptpanalyzer.js
Last active February 13, 2022 06:56
First draft of AES67 RTP timestamp analyzer tool. Prints RTP to PTP timestamp difference min/avg/max in console
View ptpanalyzer.js
const dgram = require('dgram');
const chalk = require('chalk');
const ptpv2 = require('ptpv2');
let interface = '10.0.0.12';
//let multicastAddr = '239.69.161.58';
let multicastAddr = '239.69.80.114';
let samplerate = 48000;
let client = dgram.createSocket({ type: 'udp4', reuseAddr: true });
@philhartung
philhartung / ptp.js
Last active March 8, 2022 16:46
PTPv2 client and RTP relay with timestamping for AES67. Also includes SAP/SDP.
View ptp.js
var sdp = require('./sdp');
//SDP Stuff
var samplerate = 48000;
var channels = 2;
var multicastAddr = '239.69.0.111';
var addr = '192.168.1.1';
var encoding = 'L24';
var name = 'RPi 4';
var sessID = Math.floor(Date.now() / 1000);
@philhartung
philhartung / aes67-multiply.js
Last active August 23, 2022 12:32
Easily multiply an AES67 Stream for load testing. SDP has to be adjusted accordingly
View aes67-multiply.js
const dgram = require('dgram');
const process = require('process');
const sdp = require('./sdp');
let client = dgram.createSocket({ type: 'udp4', reuseAddr: true });
let clients = [];
if(!process.argv[2] || !(parseInt(process.argv[2]) > 0)){
console.log('$ node multiply 12');
@philhartung
philhartung / histogram.bat
Last active November 28, 2022 23:19
ffmpeg scripts for OBS on Windows
View histogram.bat
ffplay.exe -f dshow -i video="OBS Virtual Camera" -vf "format=yuva444p,split=2[a][b];[a]histogram=c=7:fgopacity=0.9[aa];[b][aa]overlay"
@philhartung
philhartung / aes67_icecast.sh
Last active December 7, 2022 14:20
AES67 <> Icecast relay with gstreamer
View aes67_icecast.sh
#!/bin/sh
gst-launch-1.0 udpsrc address=239.69.161.58 port=5004 multicast-iface=eth0 !\
application/x-rtp, clock-rate=48000, channels=2 !\
rtpjitterbuffer !\
rtpL24depay !\
audioconvert !\
lamemp3enc !\
shout2send mount=/test.mp3 port=8000 username=source password=XXX ip=10.10.0.100