Skip to content

Instantly share code, notes, and snippets.

@suzumura-ss
suzumura-ss / JPEGLoader.cs
Last active September 20, 2018 06:41
Unity/Android環境向けに1個のJPEGを2個のRGBバイト列に分割ロードするローダー / 幅4K〜8KのEqui画像をロードする想定
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_ANDROID
#else
// PCではopenCVSharpを利用
using System.Runtime.InteropServices;
using OpenCvSharp;
#endif
@suzumura-ss
suzumura-ss / Shaders.metal
Last active July 21, 2022 12:37
Offscreen Metal rendering
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
typedef struct
{
float4 position [[position]];
float2 texCoord;
} Vertex;
@suzumura-ss
suzumura-ss / rawvideo-pipe.rb
Created January 15, 2018 14:58
raw-YUV to MP4 with pipe
command = "ffmpeg -f rawvideo -pix_fmt yuv444p -color_range 2 -s:v 160x120 -r 30 -i pipe:0 "
+ "-c:v libx264 -profile:v baseline -pix_fmt yuv420p -y output.mp4"
IO.popen(command, "r+"){|io|
io.close_read
100.times do
(0..255).map{|y|
image = ([y].pack("C")) * 160 * 120
image += ([127].pack("C")) * 160 * 120
image += ([127].pack("C")) * 160 * 120
15.times do
@suzumura-ss
suzumura-ss / rawvideo.rb
Created January 15, 2018 14:26
raw-YUV to MP4
# ruby rawvideo.rb &
# ffmpeg -f rawvideo -pix_fmt yuv444p -color_range 2 -s:v 160x120 -r 30 -i tcp://127.0.0.1:8888 \
# -c:v libx264 -profile:v baseline -pix_fmt yuv420p -y output.mp4
require 'socket'
server = TCPServer.new("127.0.0.1", 8888)
sock = server.accept
(0..255).map{|y|
image = ([y].pack("C")) * 160 * 120
image += ([127].pack("C")) * 160 * 120
@suzumura-ss
suzumura-ss / mjpeg.rb
Last active January 15, 2018 14:27
MotionJPEG to MP4
# ruby mjpeg.rb &
# ffmpeg -f mjpeg -r 30 -i tcp://127.0.0.1:8888 \
# -c:v libx264 -profile:v baseline -pix_fmt yuv420p -y output.mp4
require 'socket'
image = File.open('image.jpg', 'rb'){|fd| fd.read}
server = TCPServer.new("127.0.0.1", 8888)
sock = server.accept
(30*600).times do
sock.write image
@suzumura-ss
suzumura-ss / opencv_video_io.cpp
Created January 12, 2018 16:40
openCV video i/o example
#include <opencv2/opencv.hpp>
#include <opencv2/video.hpp>
#pragma comment(lib, "opencv_core320.lib")
#pragma comment(lib, "opencv_videoio320.lib")
int main(int argc, const char* argv[])
{
if (argc != 3) {
@suzumura-ss
suzumura-ss / Trac-Dockerfile
Last active November 2, 2018 00:54
trac with Docker
FROM ubuntu
WORKDIR /root
ENV TZ=JST-9
RUN apt-get update -y
RUN apt-get upgrade -y
RUN apt-get -y install trac
RUN mkdir ./Main
RUN echo "main\n\n" |trac-admin ./Main initenv
@suzumura-ss
suzumura-ss / fuse-cloudwatchlogfs.rb
Last active December 23, 2015 15:38
fuse-cloudwatchlogfs - Send to AWS-CloudWatchLog
#!/usr/bin/env ruby
=begin
* install
$ yum -y install fuse fuse-devel
$ gem install rfusefs
* mount
$ mkdir group_name
$ ruby cloudwatchlogfs.rb group_name
#=> log-group name is 'group_name'
@suzumura-ss
suzumura-ss / config.ru
Last active December 22, 2015 17:10
nginx-lua: upload request-body to AWS-S3
require 'grape'
require 'uuid'
require 'aws-sdk'
class Hello < Grape::API
HTTP_PROXY = ENV['HTTP_PROXY'] || ENV['HTTPS_PROXY']
AWS_REGION = ENV['AWS_REGION'] || 'ap-northeast-1'
module Logic
@suzumura-ss
suzumura-ss / build-ngx_openresty-with-passenger.rb
Last active December 22, 2015 20:34
build ngx_openresty with passenger
#!/usr/bin/env ruby
=begin
sudo yum -y install gcc openssl-devel zlib-devel pcre-devel lua lua-devel
sudo yum -y install ruby-devel curl-devel gcc-c++
wget https://openresty.org/download/ngx_openresty-1.9.3.2.tar.gz
tar xf ngx_openresty-1.9.3.2.tar.gz
gem install passenger
ruby build.rb
=end