Skip to content

Instantly share code, notes, and snippets.

@suzumura-ss
Created January 15, 2018 14:26
Show Gist options
  • Save suzumura-ss/39a2fb04d0795d71512e7ee14790b66a to your computer and use it in GitHub Desktop.
Save suzumura-ss/39a2fb04d0795d71512e7ee14790b66a to your computer and use it in GitHub Desktop.
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
image += ([127].pack("C")) * 160 * 120
15.times do
sock.write image
end
}
sock.close
server.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment