Discussion:
[FFmpeg-user] xyz to rgb conversion
betonpfeiler
2013-09-07 21:28:17 UTC
Permalink
Hello Everyone!

I just found out, that FFmpeg is now capable of converting Videofiles
from xyz to rgb colorspace (
http://www.belle-nuit.com/open-source-dcp-player-proof-of-concept).
First of all: Thanks for that great feature!!

I just tried it and it works automaticly when encoding xyz-jpeg2000
files. The Results are also very pleasing, but still I have some questions:

1. Is it possible to switch the colorconversion off ?(Sometimes we need
to quickly export reference files, in that case we don't care for messed
up colors)

2. What Matrix does FFmpeg uses for the conversion?

Thanks for your help!

Jan
Carl Eugen Hoyos
2013-09-08 20:32:03 UTC
Permalink
Post by betonpfeiler
I just found out, that FFmpeg is now capable of
converting Videofiles from xyz to rgb colorspace
(Since four months.)

[...]
Post by betonpfeiler
1. Is it possible to switch the colorconversion off ?
This is actually the default, colour space conversion
only happens if you request it (or if your command line
requires it), since you did not provide a command line
(including complete, uncut console output) the question
is difficult to answer.
Post by betonpfeiler
2. What Matrix does FFmpeg uses for the conversion?
Maybe the commit answers your question:
http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=0c47c90

Carl Eugen
betonpfeiler
2013-09-09 23:02:31 UTC
Permalink
Post by Carl Eugen Hoyos
Post by betonpfeiler
I just found out, that FFmpeg is now capable of
converting Videofiles from xyz to rgb colorspace
(Since four months.)
[...]
yeah, I kind of wasn't up to date on this one...
Post by Carl Eugen Hoyos
Post by betonpfeiler
1. Is it possible to switch the colorconversion off ?
This is actually the default, colour space conversion
only happens if you request it (or if your command line
requires it), since you did not provide a command line
(including complete, uncut console output) the question
is difficult to answer.
Sorry for that, I don't have any testfiles at hand right now (I'm on a
two week holiday...) but will provide a command line + output as soon as
I'm back at work.
I was converting xyz j2k's without any special options (something like:
ffmpeg -r 24 -i <insequence.j2c> -vcodec prores -profile:v 3 -an
<out.mov>) and it seems ffmpeg recognized the xyz-colorspace out of the
metadata and automaticly used the convesion.

Is there any documentation? I couldn't find anything, which parameter is
used to turn the conversion on/off...
Post by Carl Eugen Hoyos
Post by betonpfeiler
2. What Matrix does FFmpeg uses for the conversion?
http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=0c47c90
Thanks for the Link! I found what I needed, at least I think so... Still
trying to understand the code... very dense ;)

Thanks for your help!!
Carl Eugen Hoyos
2013-09-09 23:15:50 UTC
Permalink
Post by betonpfeiler
Is there any documentation? I couldn't find anything,
which parameter is used to turn the conversion on/off...
Sorry if my original answer was unclear:
You cannot turn the conversion on/off.
By default, FFmpeg does no colour space
conversion if not told so.
If you have xyz input, and you tell ffmpeg
to encode prores, a conversion will be
done (automatically) because prores does
not support xyz.

As said, since I don't understand your
usecase (you simply cannot use xyz as
input for prores), I have difficulties
answering your original question.

Carl Eugen
betonpfeiler
2013-09-10 15:48:31 UTC
Permalink
Post by Carl Eugen Hoyos
Post by betonpfeiler
Is there any documentation? I couldn't find anything,
which parameter is used to turn the conversion on/off...
You cannot turn the conversion on/off.
By default, FFmpeg does no colour space
conversion if not told so.
If you have xyz input, and you tell ffmpeg
to encode prores, a conversion will be
done (automatically) because prores does
not support xyz.
As said, since I don't understand your
usecase (you simply cannot use xyz as
input for prores), I have difficulties
answering your original question.
Carl Eugen
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Sometimes we want to make a quick reference movie, for subtitling for
example. The fastest way is to use the j2ks from the MXF Container as
source. I know, that the 12bit DCI XYZ can't be mapped in the 8-bit RGB
colorspace, so the direct mapped result becomes a little pale and
greenish. Also you loose some colorinformation, which are outside the
RGB colorspace, but for subtitling or audiomixes the colors are not so
important, even an b/w video would be enough. (I know, that the easyDCP
Player can export a 8-bit ProRes without colorconversion, it looks
greenish and has some artifacts, but it's totaly fine for my usecase).

And how does ffmpeg recognize the XYZ colorspace? I haven't found a tool
yet, which can guess the right colorspace of an image file (e.g. 16bit
TIFF). I always assumed, that the colorspace is only given in the
Metadata, am I wrong?
Does anybody have some good literature tips regarding colorcoding in
video? I searched the web and found a lot of Blogentrys and so on, but
it seems to be a topic where many things are unclear/many people have
different opinions... As it's a hughe topic, I'm looking for a good entry.

Thanks!
Carl Eugen Hoyos
2013-09-10 21:28:07 UTC
Permalink
Post by betonpfeiler
Sometimes we want to make a quick reference movie, for
subtitling for example. The fastest way is to use the
j2ks from the MXF Container as source. I know, that
the 12bit DCI XYZ can't be mapped in the 8-bit RGB
colorspace, so the direct mapped result becomes a
little pale and greenish. Also you loose some
colorinformation, which are outside the RGB colorspace,
but for subtitling or audiomixes the colors are not so
important, even an b/w video would be enough.
You misunderstand:
The FFmpeg prores encoder does not care about
colourinformation, RGB colourspace or bits.
It needs input data in YUVx4xxP10 (pix_fmts defined
within FFmpeg), nothing else can be read. If your
input data is in another format, ffmpeg (the
application) will automatically insert a conversion
filter (the scale filter).

If you have a xyz sample that does not get detected
correctly by FFmpeg (tiff or other), please provide it!

Carl Eugen
SK Cinema
2013-09-27 09:11:38 UTC
Permalink
Post by Carl Eugen Hoyos
The FFmpeg prores encoder does not care about
colourinformation, RGB colourspace or bits.
It needs input data in YUVx4xxP10 (pix_fmts defined
within FFmpeg), nothing else can be read. If your
input data is in another format, ffmpeg (the
application) will automatically insert a conversion
filter (the scale filter).
I too am in need of raw XYZ output from a DCI MXF and I tested output to a
TIFF file since that would allow for XYZ colour space without the need to
convert to Rec.709 RGB. However, the output TIF seems to always be RGB
Rec.709.

Is there any way to disable the automatic conversion from XYZ to RGB when
decoding JPEG2000?

The command line I used was:
ffmpeg -i videofile.MXF -pix_fmt xyz12le -f image2 -vframes 1 output.tiff

The output.tiff is in RGB Rec.709.

I used the Sep 18 ffmpeg build.

Thanks anyone that can help!




--
View this message in context: http://ffmpeg-users.933282.n4.nabble.com/xyz-to-rgb-conversion-tp4661196p4661479.html
Sent from the FFmpeg-users mailing list archive at Nabble.com.
SK Cinema
2013-10-03 12:19:37 UTC
Permalink
Post by Carl Eugen Hoyos
The FFmpeg prores encoder does not care about
colourinformation, RGB colourspace or bits.
It needs input data in YUVx4xxP10 (pix_fmts defined
within FFmpeg), nothing else can be read. If your
input data is in another format, ffmpeg (the
application) will automatically insert a conversion
filter (the scale filter).
I too am in need of raw XYZ output from a DCI MXF and I tested output to a
TIFF file since that would allow for XYZ colour space without the need to
convert to Rec.709 RGB. However, the output TIF seems to always be RGB
Rec.709.

Is there any way to disable the automatic conversion from XYZ to RGB when
decoding JPEG2000?

The command line I used was:
ffmpeg -i videofile.MXF -pix_fmt xyz12le -f image2 -vframes 1 output.tiff

The output.tiff is in RGB Rec.709.

I used the Sep 18 ffmpeg build.

Thanks anyone that can help!



--
View this message in context: http://ffmpeg-users.933282.n4.nabble.com/xyz-to-rgb-conversion-tp4661196p4661599.html
Sent from the FFmpeg-users mailing list archive at Nabble.com.
Carl Eugen Hoyos
2013-10-03 22:14:48 UTC
Permalink
Post by SK Cinema
Is there any way to disable the automatic conversion from
XYZ to RGB when decoding JPEG2000?
Please allow me to repeat that there is NO automatic conversion
(every time) when you decode xyz jpeg2000.

Or to say it differently:
The automatic conversion that happens has nothing to do with
jpeg2000 (but only with the used encoder).
Post by SK Cinema
ffmpeg -i videofile.MXF -pix_fmt xyz12le -f image2
-vframes 1 output.tiff
(The tiff encoder currently does not accept xyz.)
Please provide a tiff sample containing xyz.

Carl Eugen
SK Cinema
2013-10-04 09:32:59 UTC
Permalink
(The tiff encoder currently does not accept xyz.)
Please provide a tiff sample containing xyz.

Here's a sample of a tiff containing X'Y'Z'. Google Viewer seems unable to
display this tiff correctly so please download and view locally.
https://docs.google.com/file/d/0B1U1rZVj1f7pbXdlZkFucjhTQk0/edit?usp=sharing

Ironically, I made this tiff with an older ffmpeg build (2013-04-18) which
did not yet have the XYZ-RGB conversion! In my understanding, any output
that supports RGB 4:4:4 will be perfectly capable of supporting XYZ because
XYZ is really just a much wider gamut version of RGB where the color
primaries are the absolute values based on which RGB primaries for color
spaces such as Rec.709 are defined.

I also tried to use a custom 3D LUT using the following option:
-vf lut3d=XYZ-sRGB.3dl

But again, this is defeated by the XYZ-RGB conversion happening prior to the
3D LUT being applied, which is not the desired result.

Thanks for looking into this!




--
View this message in context: http://ffmpeg-users.933282.n4.nabble.com/xyz-to-rgb-conversion-tp4661196p4661619.html
Sent from the FFmpeg-users mailing list archive at Nabble.com.
Andreas Gumm
2013-10-04 10:18:40 UTC
Permalink
May I'm wrong with the idea, but is it not good enough to simply unwrap the
JPEG2000 stream to image sequence?

Andreas

Andreas Gumm
______________________________________
metakraft ® - DVD CD und Web-Produktion Berlin
Kiefholzstr. 19 2HH 4OG
12435 Berlin

www.metakraft.de
***@metakraft.de
Mobil: +49 177 / 6 444 754

Tel.: +49 30 / 48 49 29 -39
Fax : +49 30 / 48 49 29 -40


Geschäftsinhaber: Leander v. Kraft

Diese Nachricht ist ausschließlich für den im Adressfeld ausgewiesenen
Empfänger bestimmt. Sollten Sie nicht der vorgesehene Adressat sein, so
bitten wir um eine kurze Nachricht. Jede unbefugte Weiterleitung oder
Fertigung einer Kopie dieser Mitteilung ist unzulässig.
Post by Carl Eugen Hoyos
(The tiff encoder currently does not accept xyz.)
Please provide a tiff sample containing xyz.
Here's a sample of a tiff containing X'Y'Z'. Google Viewer seems unable to
display this tiff correctly so please download and view locally.
https://docs.google.com/file/d/0B1U1rZVj1f7pbXdlZkFucjhTQk0/edit?usp=sharing
Ironically, I made this tiff with an older ffmpeg build (2013-04-18) which
did not yet have the XYZ-RGB conversion! In my understanding, any output
that supports RGB 4:4:4 will be perfectly capable of supporting XYZ because
XYZ is really just a much wider gamut version of RGB where the color
primaries are the absolute values based on which RGB primaries for color
spaces such as Rec.709 are defined.
-vf lut3d=XYZ-sRGB.3dl
But again, this is defeated by the XYZ-RGB conversion happening prior to the
3D LUT being applied, which is not the desired result.
Thanks for looking into this!
--
http://ffmpeg-users.933282.n4.nabble.com/xyz-to-rgb-conversion-tp4661196p4661619.html
Sent from the FFmpeg-users mailing list archive at Nabble.com.
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Carl Eugen Hoyos
2013-10-06 22:21:43 UTC
Permalink
Post by SK Cinema
Post by Carl Eugen Hoyos
Please provide a tiff sample containing xyz.
Here's a sample of a tiff containing X'Y'Z'. Google
Viewer seems unable to display this tiff correctly so
please download and view locally.
https://docs.google.com/file/d/0B1U1rZVj1f7pbXdlZkFucjhTQk0/edit?usp=sharing
Ironically, I made this tiff with an older ffmpeg build
(2013-04-18) which did not yet have the XYZ-RGB conversion!
I may misunderstand but this sounds to me as if no software
would be able to recognize this file as XYZ or do I miss
something?

[...]

As said elsewhere, please try to explain what is wrong with
the conversion by FFmpeg? I suspect (maybe I am wrong) that
no developer know why other coefficients may be needed.
(In the sense of: Which usecases need other coefficients
and which ones.)
Post by SK Cinema
But again, this is defeated by the XYZ-RGB conversion
happening prior to the 3D LUT being applied, which is
not the desired result.
This sounds as if it could be fixed but it would need (for
me, probably not for other developers) a proper report.

Please fix your quoting, Carl Eugen
SK Cinema
2013-10-08 12:22:24 UTC
Permalink
Post by Carl Eugen Hoyos
I may misunderstand but this sounds to me as if no software
would be able to recognize this file as XYZ or do I miss
something?
Yes, that's correct.
Post by Carl Eugen Hoyos
As said elsewhere, please try to explain what is wrong with
the conversion by FFmpeg? I suspect (maybe I am wrong) that
no developer know why other coefficients may be needed.
(In the sense of: Which usecases need other coefficients
and which ones.)
The current ffmpeg conversion would use matrix coefficients for XYZ to
Rec.709 conversion and assume specific gamma values for the source X'Y'Z'
image and the target Rec.709 RGB image. A possible alternative requirement
would be for converting to the DCI P3 colour space rather than Rec.709.
Also, one might wish to use different gamma values.

Also, XYZ is the color space with the widest gamut one would encounter.
There would likely be material that is out of gamut in Rec.709 and this can
produce nasty artifacts. Using a 3D LUT that is built to gently handle such
out of gamut issues would often be preferable to a matrix color space
conversion.

For reference, here's the command line I'd like to use:
ffmpeg -i video-source.mxf -vf
scale=1920:808,lut3d=XYZ-sRGB.3dl,pad=width=1920:height=1080:x=0:y=136
-codec prores output.mov





--
View this message in context: http://ffmpeg-users.933282.n4.nabble.com/xyz-to-rgb-conversion-tp4661196p4661664.html
Sent from the FFmpeg-users mailing list archive at Nabble.com.

Continue reading on narkive:
Search results for '[FFmpeg-user] xyz to rgb conversion' (Questions and Answers)
5
replies
How to convert L*a*b value to RGB value?
started 2008-06-11 06:30:14 UTC
programming & design
Loading...