Created
January 15, 2018 14:26
-
-
Save suzumura-ss/39a2fb04d0795d71512e7ee14790b66a to your computer and use it in GitHub Desktop.
raw-YUV to MP4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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