Browse Source

chroma

master
artemis 2 years ago
parent
commit
a4d439922f
  1. 13
      bin/from-chroma
  2. 16
      bin/to-chroma
  3. 11
      spec

13
bin/from-chroma

@ -0,0 +1,13 @@
#!/usr/bin/env ruby
if ARGV.length < 1
STDERR.puts "Usage: #{__FILE__} [ffmpeg_args] <output> < 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)

16
bin/to-chroma

@ -0,0 +1,16 @@
#!/usr/bin/env ruby
if ARGV.length != 1
STDERR.puts "Usage: #{__FILE__} <input> | 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", "-")

11
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.
Loading…
Cancel
Save