Skip to content

Instantly share code, notes, and snippets.

@suzumura-ss
Created January 15, 2018 14:58
Show Gist options
  • Save suzumura-ss/6f06ed0ad5b34ac257aaff36f0094a17 to your computer and use it in GitHub Desktop.
Save suzumura-ss/6f06ed0ad5b34ac257aaff36f0094a17 to your computer and use it in GitHub Desktop.
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
io.write image
end
}
end
io.close
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment