Raw RGB48 piped to IM -> Export 16bit Image Seq's tiff exr
Raw RGB48 piped to IM -> Export 16bit Image Seq's tiff exr
Hi
Can IM except Raw RGB48 data piped from avs2yuv and export 16bit image sequences in either .tif or .exr preferably.
Can IM except Raw RGB48 data piped from avs2yuv and export 16bit image sequences in either .tif or .exr preferably.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Raw RGB48 piped to IM -> Export 16bit Image Seq's tiff e
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.
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
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:
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.
I'm using Avisynth to generate the raw data using Dither 1.9. From the Dither plugin info:
I'm not sure that helps any.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 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.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Raw RGB48 piped to IM -> Export 16bit Image Seq's tiff e
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
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
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Raw RGB48 piped to IM -> Export 16bit Image Seq's tiff e
this should do it...yellow wrote:Hi
Can IM except Raw RGB48 data piped from avs2yuv and export 16bit image sequences in either .tif or .exr preferably.
Code: Select all
convert -depth 16 -size 100x200 rgb48_image_data.rgb image.tif
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
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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Raw RGB48 piped to IM -> Export 16bit Image Seq's tiff e
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:
I'm then using:
When I try this:
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.
fmw42, thanks for the hdri info more reading for me to do there as well.
However at the moment it's a two stage process as I can't get the pipe to work. So currently I'm using:
Which sets avisynth running serving the raw 16bit rgb into a single file.avs2yuv.exe -raw dithertest.avs -o dithertest.rgb
I'm then using:
What I'd really like to get working is not creating the intermediate .rgb file but piping from .avs to .tif.convert.exe -depth 16 -size 1920x1088 dithertest.rgb dithertest_%d.tif
When I try this:
I get an IM error about a missing file name.avs2yuv.exe -raw dithertest.avs -o dithertest.rgb | convert.exe -depth 16 -size 1920x1088 dithertest.rgb dithertest_%d.tif
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.
Just syntax problems for me I think not knowing how to use the pipe correctly.avs2yuv.exe -raw dithertest.avs -o - | convert.exe -depth 16 -size 1920x1088 - dithertest_%d.tif
fmw42, thanks for the hdri info more reading for me to do there as well.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Raw RGB48 piped to IM -> Export 16bit Image Seq's tiff e
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?avs2yuv.exe -raw dithertest.avs -o - | convert.exe -depth 16 -size 1920x1088 - dithertest_%d.tif
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
haha you beauty
SoWith IM and piping, you can use
convert image someprocessing PNG:- | convert - somemoreprocessing output
Does the trick, many thanks.avs2yuv.exe -raw dithertest.avs -o - | convert.exe -depth 16 -size 1920x1088 rgb:- dithertest_%d.tif
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Raw RGB48 piped to IM -> Export 16bit Image Seq's tiff e
glad you worked it out.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Raw RGB48 piped to IM -> Export 16bit Image Seq's tiff e
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
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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Raw RGB48 piped to IM -> Export 16bit Image Seq's tiff e
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.anthony wrote:Also glad that avs2yuv.exe can write to a '-' as meaning standard output.
Re: Raw RGB48 piped to IM -> Export 16bit Image Seq's tiff e
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.
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
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.
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
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
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?
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