Discussion:
[Oiio-dev] oiiotool stdout pipe
Jed Smith
2018-12-02 19:05:41 UTC
Permalink
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
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
____________
Troy Sobotka
2018-12-02 19:38:11 UTC
Permalink
Post by Jed Smith
I am using ffmpeg for quicktime generation.
Call me skeptical.

The reason is that FFMPEG's colour handling was pretty horrible last
time I looked. This is legacy historical code issues, but they have
prevailed up until recently. There are a few issues on the FFMPEG
tracker regarding the colour handling.

I'd be interested to see if gamuts other than REC.709 based are:
1. Correctly encoded to the stream.
2. Correctly decoded from the stream.

The only workaround I was able to achieve was to manually handle the
transform from the RGB encoding to the YCbCr domain, then manually
encoding that. Even after all of that, the tagging wasn't handled
correctly on FFMPEG's side IIRC.

Wise folks like Kevin Wheatley can probably offer a little more
insight here, given I believe he has mucked with the transfer function
/ coefficients nightmare in FFMPEG previously.

With respect,
TJS
Larry Gritz
2018-12-02 20:44:05 UTC
Permalink
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.
Post by Jed Smith
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.
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
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
--
Larry Gritz
***@larrygritz.com

Loading...