diff --git a/bin/from-chroma b/bin/from-chroma new file mode 100755 index 0000000..92dd3de --- /dev/null +++ b/bin/from-chroma @@ -0,0 +1,13 @@ +#!/usr/bin/env ruby + +if ARGV.length < 1 + STDERR.puts "Usage: #{__FILE__} [ffmpeg_args] < command" + STDERR.puts ARGV.length.to_s + exit 1 +end + +resolution = STDIN.read(8).unpack("L>L>") +width = resolution[0] +height = resolution[1] + +exec("ffmpeg", "-v", "error", "-f", "rawvideo", "-pix_fmt", "argb", "-s", "#{width}x#{height}", "-i", "-", *ARGV) diff --git a/bin/to-chroma b/bin/to-chroma new file mode 100755 index 0000000..f4e8da5 --- /dev/null +++ b/bin/to-chroma @@ -0,0 +1,16 @@ +#!/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", "-") diff --git a/spec b/spec new file mode 100644 index 0000000..9571769 --- /dev/null +++ b/spec @@ -0,0 +1,11 @@ +filters and generator should accept and produce sequences of images. Each sequence has the following format: + +width unsigned 4 bytes big-endian +height unsigned 4 bytes big-endian + +followed by one or more arrays of pixels: + +pixels array of 4 byte big-endian ARGB pixels, width * height in length + pixel_index(x, y) = x + y * width + +if a filter does not use alpha in any way it's best practice to copy the input alpha to the output.