Skip to content

Instantly share code, notes, and snippets.

@selvan
selvan / go_build_cgo_ldflags
Last active April 9, 2023 06:33
GO build with cgo ldflags
go clean -cache
CGO_LDFLAGS="-L/usr/local/Cellar/x264/r3095/lib" go build
@selvan
selvan / mask_pil.py
Created July 22, 2021 17:40
Mask image generation python
## Rectangle mask
size = (1280, 720)
first_half = (size[0]/2, size[1])
second_half = (first_size_half[0]+1, size[1])
mask = Image.new("L", size, 255)
draw = ImageDraw.Draw(mask)
draw.rectangle((second_half[0], 0, size[0], size[1]), fill=0)
mask.save("/tmp/mask.jpg")
@selvan
selvan / VideoEncoder.java
Created March 20, 2021 01:38
rtmppublisher - Drain encoder via call back + Set bitrate on the fly
package com.takusemba.rtmppublisher;
import android.media.MediaCodec;
import android.media.MediaCodecInfo;
import android.media.MediaFormat;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.support.annotation.RequiresApi;
@selvan
selvan / CameraFragment.kt
Created March 20, 2021 01:36
Camera2Video - https://github.com/android/camera-samples.git - Draw to OffscreenSurface (eglCreatePbufferSurface)
/*
* Copyright 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@selvan
selvan / ContinuousCapture.java
Created March 20, 2021 01:30
Grafika - Experiment on replacing WindowSurface (eglCreateWindowSurface) with OffscreenSurface (eglCreatePbufferSurface)
/*
* Copyright 2014 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@selvan
selvan / nvm.md
Created February 8, 2021 07:40
Installing, Configuring and Using NVM

Install:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash

Configuration: add below to .bashrc .bash_profile

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
@selvan
selvan / mobile.md
Last active August 20, 2020 16:46
Mobile Course

Mobile

Fundamentals

Login/Registration

Layout

Navigation

Data fetching & management (Redux etc)

Push Notification

Deep linking

Print load path

lua -e "print(package.path)"

@selvan
selvan / domain_socket.dart
Created June 9, 2020 16:31
Dart - Unix Domain Socket
// Based on https://dart-review.googlesource.com/c/sdk/+/125932/34/tests/standalone_2/io/unix_socket_test.dart
import 'dart:async';
import 'dart:io';
Future<void> main() async {
var address = InternetAddress('/tmp/socket', type: InternetAddressType.unix);
var server = await ServerSocket.bind(address, 0, shared: true);
server.listen((client) async {
client.listen((data) {