blind
blind copied to clipboard
Blind And ImageMagick
Hello, is possible to add command blind-imagemagick
for run convert imagemagick for each frames.
for example :::::::::::
blind-imagemagick -colorspace gray
for each frames is :::::::: convert framesSTDIn -colorspace gray frameSTDOut
You can already accomplish this using a loop and already provided tools, and you can use any external command and easily create pipelines. I don't like having commands that are specific to specific external commands, if a tool for running an external command would be added, and I currently don't thing it is a good idea, it should allow you to specify the external command.
You could implement blind-imagemagick
as (with reservations for errors):
#!/bin/bash -e
# ksh may also work
read nframes width height pixfmt < <(blind-read-head)
blind-write-head $nframes $width $height $pixfmt
while { set +e; blind-next-frame $width $height $pixfmt;
status=$?;
set -e; } | \
blind-to-image | \
imagemagick "$@" | \
blind-from-image -h -p; \
test $status = 0; do
:;
done # (-p for `blind-from-image` is optional)
test $status = 1
Thanks, I just modify convert pam:- $@ pam:-
In Line 9
But Show Two Error ::::::::::
blind-imagemagick: ligne 11 : test: = : opérateur unaire attendu
blind-imagemagick: ligne 14 : test: = : opérateur unaire attendu
Ok, new attempt:
#!/bin/bash -e
# ksh does not work
read nframes width height pixfmt < <(blind-read-head)
blind-write-head $nframes $width $height $pixfmt
while blind-next-frame $width $height $pixfmt | \
blind-to-image | \
convert pam:- "$@" pam:- | \
blind-from-image -h -p; \
status=( ${PIPESTATUS[@]} );
test ${status[0]} = 0; do
test ${status[1]} = 0;
test ${status[2]} = 0;
test ${status[3]} = 0;
test ${status[4]} = 0;
done # (-p for `blind-from-image` is optional)
test ${status[0]} = 1
A cosmetic imperfection here is that the commands will fail when blind-next-frame
says that there are no more frames. This can be solved if you have an implementation of ifne
that can peeks the input file (uses tee
for pipes, MSG_PEEK
for sockets, stat
/pread
for regular files):
#!/bin/bash -e
# ksh also works
set -o pipefail
read nframes width height pixfmt < <(blind-read-head)
blind-write-head $nframes $width $height $pixfmt
while ifne -n false; do
blind-next-frame $width $height $pixfmt | \
blind-to-image | \
convert pam:- "$@" pam:- | \
blind-from-image -h -p # (-p is optional)
test $? = 0 # not needed if using bash
done
(It is not possible to just run the loop $nframes
times, as $nframes
may be 0. Tools should not depend on the value unless absolutely necessary, as it is not always set because it can be too costly.)
I A Problem! I Good You Post My Script But ::::::::::::::
blind-from-video
without -L Option Input And Output Dont Out The Header File, So The Command blind-read-head
Show An Error