Page 1 of 2
Raw RGB48 piped to IM -> Export 16bit Image Seq's tiff exr
Posted: 2011-06-15T14:07:36-07:00
by yellow
Hi
Can IM except Raw RGB48 data piped from avs2yuv and export 16bit image sequences in either .tif or .exr preferably.
Re: Raw RGB48 piped to IM -> Export 16bit Image Seq's tiff e
Posted: 2011-06-15T15:07:06-07:00
by fmw42
I have never worked with such data, so cannot answer directly. But see
http://www.imagemagick.org/Usage/formats/#rgb
You might post a link to a small image in your RGB48 format so that others who are more familiar with RGB format data can test with it for you, if you do not already have IM installed.
Re: Raw RGB48 piped to IM -> Export 16bit Image Seq's tiff e
Posted: 2011-06-15T15:46:27-07:00
by yellow
I'd like to offer an image / raw video but unsure how to due to the raw nature of the file. It's HD (1920x1088) but coming out of Avisynth it's actually 3840x4352 and 32mb a frame.
I'm using Avisynth to generate the raw data using Dither 1.9. From the Dither plugin info:
Dither_convey_rgb48_on_yv12
Dither_convey_rgb48_on_yv12: clip r, clip g, clip b, bool bigendian (false)
This function provides the same kind of functionality as Dither_convey_yuv4xxp16_on_yvxx, but spits RGB48 pixels instead of YUV.
At the time these lines are written, it's difficult to find applications reading raw RGB48 pixels without truncating the LSB. This code should work when FFmpeg will be able to save 48-bit PNGs after processing data at such a bit depth (currently it converts the pictures to 24-bits):
avs2yuv -raw "script.avs" -o - | ffmpeg -f rawvideo -vcodec rawvideo -pix_fmt rgb48le -s 1280x720 -aspect 1:1 -y -i - -f image2 "out-%06d.png"
r, g, b: Three YUV stack16 clips containing the red, green and blue channels in their luma plane.
bigendian: indicates that MSB must be stored before the LSB (rgb48be instead of rgb48le).
This function works only on 16-bit stacked clips.
I'm not sure that helps any.
I'm trying things like:
avs2yuv.exe -raw dither16avs.avs -o - | c:\Apps\IM\convert.exe -size 1920x1088 -depth 16 raw:image test_%d.tif
But as you can see unfamilar with piping or IM's CLI.
Log space 10bit DPX would be another useful format to write to if possible. I'm currently able to encode to lossless 10bit h264 using avs2yuv but not image sequences.
Re: Raw RGB48 piped to IM -> Export 16bit Image Seq's tiff e
Posted: 2011-06-15T16:40:22-07:00
by fmw42
I cannot help much. It would have been nice if you could create a small test image and post it somewhere, then link to it here. But read the section about reading RGB images in the link I sent above, where it talks about using floating point values and -define. Here is a copy. Perhaps Anthony can comment further as that is his web site.
You can also read (and write) RGB using normalized floating point numbers.
This however requires the use of special coder -define settings.
See HDRI floating point file formats
http://www.imagemagick.org/Usage/basics/#hdri_formats
RGB floating point Image generated using C Code (HDRI)...
float red = 1.0f;
float green = 1.0f; /* appropriate data */
float blue = 1.0f;
/* for exach pixel in image... */
fwrite (&red, sizeof(float), 1, file);
fwrite (&green, sizeof(float), 1, file);
fwrite (&blue, sizeof(float), 1, file);
Reading Options....
convert -size 200x100 -depth 32 -define quantum:format=floating-point
-define quantum:scale=65536.0 -endian lsb input.rgb
output.png
The quantum:format defines to read floating point numbers from the file.
While the -depth defines the floating point size (32 = floats, 64 = doubles).
The quantum:scale defines how to scale the floating point numbers from
normalized 0.0 to 1.0 values to the in-memory 16bit Quality levels needed
by my Q16 version of IM.
Also see about DPX images at
http://www.imagemagick.org/Usage/formats/#dpx
Re: Raw RGB48 piped to IM -> Export 16bit Image Seq's tiff e
Posted: 2011-06-15T19:28:23-07:00
by anthony
yellow wrote:Hi
Can IM except Raw RGB48 data piped from avs2yuv and export 16bit image sequences in either .tif or .exr preferably.
this should do it...
Code: Select all
convert -depth 16 -size 100x200 rgb48_image_data.rgb image.tif
If it looks random try setting a
-enden setting as well
Also one method you may not have considered is that RGB48 data is almost identical to A raw PPM image with 16 bit data. The only difference is that there some extra ASCII lines pre-pended to the binary data detailing the data that follows.
As such this should work...
Code: Select all
( echo "P6 100 200 65535"
cat rgb48_image_data.rgb
) | convert - image.tiff
The numbers are 'ppm format identifier', width, height, maximum value. The single newline output by the 'echo' is required. read the ppm manpage for more information of the data format.
Prepending the line to the raw data file, may be a good idea for lond term storage as you then store the data format with the binary data.
Code: Select all
( echo "P6 100 200 65536"
cat rgb48_image_data.rgb
) > image_data.ppm
Re: Raw RGB48 piped to IM -> Export 16bit Image Seq's tiff e
Posted: 2011-06-16T13:48:40-07:00
by yellow
fmw42 & anthony many thanks, I'm successfully writing 16bit image sequences.
However at the moment it's a two stage process as I can't get the pipe to work. So currently I'm using:
avs2yuv.exe -raw dithertest.avs -o dithertest.rgb
Which sets avisynth running serving the raw 16bit rgb into a single file.
I'm then using:
convert.exe -depth 16 -size 1920x1088 dithertest.rgb dithertest_%d.tif
What I'd really like to get working is not creating the intermediate .rgb file but piping from .avs to .tif.
When I try this:
avs2yuv.exe -raw dithertest.avs -o dithertest.rgb | convert.exe -depth 16 -size 1920x1088 dithertest.rgb dithertest_%d.tif
I get an IM error about a missing file name.
Trying it without naming an intermediate file but using a hyphen in each case works for encoding to h264 or encoding using ffmpeg but fails with IM.
avs2yuv.exe -raw dithertest.avs -o - | convert.exe -depth 16 -size 1920x1088 - dithertest_%d.tif
Just syntax problems for me I think not knowing how to use the pipe correctly.
fmw42, thanks for the hdri info more reading for me to do there as well.
Re: Raw RGB48 piped to IM -> Export 16bit Image Seq's tiff e
Posted: 2011-06-16T14:47:45-07:00
by fmw42
avs2yuv.exe -raw dithertest.avs -o - | convert.exe -depth 16 -size 1920x1088 - dithertest_%d.tif
I am no expert but I am not sure you can just use - for output from avs2yuv.exe. You somehow need to tell it an image format?
With IM and piping, you can use
convert image someprocessing PNG:- | convert - somemoreprocessing output
But I am not sure how your avs2yuv handles standard out.
Re: Raw RGB48 piped to IM -> Export 16bit Image Seq's tiff e
Posted: 2011-06-16T15:53:05-07:00
by yellow
haha you beauty
With IM and piping, you can use
convert image someprocessing PNG:- | convert - somemoreprocessing output
So
avs2yuv.exe -raw dithertest.avs -o - | convert.exe -depth 16 -size 1920x1088 rgb:- dithertest_%d.tif
Does the trick, many thanks.
Re: Raw RGB48 piped to IM -> Export 16bit Image Seq's tiff e
Posted: 2011-06-16T16:02:11-07:00
by fmw42
glad you worked it out.
Re: Raw RGB48 piped to IM -> Export 16bit Image Seq's tiff e
Posted: 2011-06-16T16:44:06-07:00
by anthony
Also glad that avs2yuv.exe can write to a '-' as meaning standard output. Some programs do not understand that syntax, and it is a pain when that happens. However there are a couple of ways around the programs that do not allow '-' for filenames.
As you found out when reading raw data from a pipe the 'file format' specification rgb:- is important, Not only to say what is being read (as the file has no internal identification) but also the data order. EG: rgb vs bgr
Re: Raw RGB48 piped to IM -> Export 16bit Image Seq's tiff e
Posted: 2011-06-18T01:43:24-07:00
by yellow
anthony wrote:Also glad that avs2yuv.exe can write to a '-' as meaning standard output.
I'm pleased to have found it to work, hopefully others will too and although I came here to solve a specific problem and probably not here for sometime again, this site and it's members are a great resource.
Re: Raw RGB48 piped to IM -> Export 16bit Image Seq's tiff e
Posted: 2011-08-15T13:34:05-07:00
by yellow
Having succeeded in getting my YCbCr sources piped out of Avisynth as 48bit RGB, when writing them to .exr via Avs2yuv I need to linearise them, as EXR's should really be linear not gamma encoded.
My understanding is that the YCbCr sources were gamma encoded with a Rec709 Transfer Curve, but although they are now RGB data, they are not strictly sRGB gamma encoded, handling them as such in the linear conversion I believe will produce incorrect results, a Rec709 transfer curve being a little different to an sRGB one (a linear portion near it's base), ie: not Scene referred and as a result shadow detail in that region will be crushed a little.
To clarify, this is with regard to intermediate files, the application I'm using to import the EXR's expects them to be linear and applies an sRGB 2.2 gamma conversion to previews for display but all ops are done on linear data.
So I'm unsure how to add the linear conversion into the previous piping via Avs2yuv.
Re: Raw RGB48 piped to IM -> Export 16bit Image Seq's tiff e
Posted: 2011-10-11T02:51:50-07:00
by yellow
I've been using Avisynth -> AVS2yuv -> Imagemagick for sometime but having problems piping larger video files due to memory errors, running out of memory before the image writing starts.
Is there anyway to get IM to start processing and writing files, clearing memory whilst the pipe from AVS2yuv is still open, seems that IM only starts after AVS2yuv has finished piping.
I could subdivide a video in Avisynth to individual scripts for frame sequences and batching writing to IM but it's a painful approach.
Re: Raw RGB48 piped to IM -> Export 16bit Image Seq's tiff e
Posted: 2011-10-11T13:24:03-07:00
by yellow
Ok, reading the documentation on memory usage and really big files, adding -limit memory 500MiB -limit map 1GiB appears to be helping, good approach or better one available? Does require h/d space for temporary storage of files but doesn't appear to slow the process down too much.
Re: Raw RGB48 piped to IM -> Export 16bit Image Seq's tiff e
Posted: 2012-07-04T15:00:01-07:00
by yellow
Back again.
I have a query regarding the positioning of the RGB48 data into 32bit hdr format float EXR's based on fmw42's post below. Is it possible to position the RGB48 linear light data piped from Avisynth and center it in the larger 32bit range of levels to leave head and foot room for processing?
fmw42 wrote:I cannot help much. It would have been nice if you could create a small test image and post it somewhere, then link to it here. But read the section about reading RGB images in the link I sent above, where it talks about using floating point values and -define. Here is a copy. Perhaps Anthony can comment further as that is his web site.
You can also read (and write) RGB using normalized floating point numbers.
This however requires the use of special coder -define settings.
See HDRI floating point file formats
http://www.imagemagick.org/Usage/basics/#hdri_formats
RGB floating point Image generated using C Code (HDRI)...
float red = 1.0f;
float green = 1.0f; /* appropriate data */
float blue = 1.0f;
/* for exach pixel in image... */
fwrite (&red, sizeof(float), 1, file);
fwrite (&green, sizeof(float), 1, file);
fwrite (&blue, sizeof(float), 1, file);
Reading Options....
convert -size 200x100 -depth 32 -define quantum:format=floating-point
-define quantum:scale=65536.0 -endian lsb input.rgb
output.png
The quantum:format defines to read floating point numbers from the file.
While the -depth defines the floating point size (32 = floats, 64 = doubles).
The quantum:scale defines how to scale the floating point numbers from
normalized 0.0 to 1.0 values to the in-memory 16bit Quality levels needed
by my Q16 version of IM.
Also see about DPX images at
http://www.imagemagick.org/Usage/formats/#dpx