What exactly is it you want to go to stdout? The fully encoded tiff file,
byte-for-byte as if it had gone to a disk file, but to stdout instead?
It's possible to do this, the basics are in place, but making it work
specifically with TIFF and from Python will take some work.
OIIO 2.0 has in filesystem.h an abstract class called IOProxy, that presents an
interface akin to a file -- read, write, seek, size, etc., and a concrete
subclass called IOFile, which can be initialized to send its output to an
actual file. (Other subclasses provided will write to a std::vector<unsigned
char>, or will read from a memory buffer.)
From an OIIO-using app's perspective, you can ask if an ImageOutput
supports("ioproxy"), and if it does, then you can do the "open with config" and
pass configuration hint named "oiio:ioproxy", having type TypeDesc::PTR, and
value of a pointer to a created IOProxy. For example, it could be a pointer to
an IOFile, which was created to use stdout as the file it outputs to.
But support for this is only implemented for a couple formats so far. OpenEXR
is one. If you look at exroutput.cpp, you can see that we've allowed exr writes
to use an IOProxy. This leverages the way that the libIlmImf interface for
writing exr files allows you to substitute an Imf::Ostream that abstracts
stream output, and you can see that we make one whose implementation in turn
leverages the IOProxy.
We have not yet added such a feature to the TIFF output, but it could be done.
You'd want to change the TIFFOpen call to TIFFClientOpen, which takes pointers
to custom functions for read, write, seek, size, etc. (wound familiar?) and
create functions that implement themselves as wrappers around the IOProxy.
Hmmm... then we'd need to find a way for Python calls to be able to pass a hint
for an IOProxy. That will probably take a little head scratching.
It may be more straightforward to do the somewhat lesser amount of work to
simply do the right thing if the file name to open is "stdout", with any
proxies happening underneath without the app needing to juggle it.
> On Dec 2, 2018, at 11:05 AM, Jed Smith <[email protected]> wrote:
>
> Greetings!
> I'm working on a tool to generate 10 bit quicktimes from openexr images. The
> exr needs a lut applied with an ocio color transform, and the image needs to
> be cropped and resized. I am using ffmpeg for quicktime generation.
>
> I want to avoid intermediate files, so transcoding the exrs to 16bit int tiff
> files and then using those as a source is not an option.
>
> After a lot of troubleshooting I have found a solution that reads the exr
> images with openimageio in python, does the transforms, and then pipes the
> raw UINT16 pixel bytestream to ffmpeg, with something like this:
>
> ImageBuf.get_pixels(oiio.UINT16).tofile(ffmpeg_process.stdin)
>
> Needless to say this is rather involved and complex, and not very flexible.
>
> My question is, would it be possible to add an option to oiiotool that
> allowed you to output to stdout? I know the output format is determined by
> the output file extension, but maybe an option could be added to explicitly
> set the output format?
>
> Just a thought!
>
> Thanks for your help!
>
> --
> Jed Smith
> ____________
> _______________________________________________
> Oiio-dev mailing list
> [email protected]
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
--
Larry Gritz
[email protected]
_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org