#!/usr/bin/env ruby if ARGV.length != 1 STDERR.puts "Usage: #{__FILE__} | command" STDERR.puts ARGV.length.to_s exit 1 end resolution = IO.popen(["ffprobe", "-v", "error", "-select_streams", "v:0", "-show_entries", "stream=width,height", "-of", "default=noprint_wrappers=1:nokey=1", ARGV[0]]).read.split.map{ |x| x.to_i } STDOUT.write(resolution.pack("L>L>")) STDOUT.flush exec("ffmpeg", "-v", "error", "-i", ARGV[0], "-f", "rawvideo", "-pix_fmt", "argb", "-")