xyz to rgb conversion

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

xyz to rgb conversion

betonpfeiler
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




_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: xyz to rgb conversion

Carl Eugen Hoyos
betonpfeiler <betonpfeiler <at> googlemail.com> writes:

> I just found out, that FFmpeg is now capable of
> converting Videofiles from xyz to rgb colorspace

(Since four months.)

[...]

> 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.

> 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

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: xyz to rgb conversion

betonpfeiler
Am 08.09.2013 22:32, schrieb Carl Eugen Hoyos:
> betonpfeiler <betonpfeiler <at> googlemail.com> writes:
>
>> 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...
>> 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...

>> 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
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!!

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: xyz to rgb conversion

Carl Eugen Hoyos
betonpfeiler <betonpfeiler <at> googlemail.com> writes:

> 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

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: xyz to rgb conversion

betonpfeiler
Am 10.09.2013 01:15, schrieb Carl Eugen Hoyos:

> betonpfeiler <betonpfeiler <at> googlemail.com> writes:
>
>> 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
>
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> 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!

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: xyz to rgb conversion

Carl Eugen Hoyos
betonpfeiler <betonpfeiler <at> googlemail.com> writes:

> 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

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: xyz to rgb conversion

SK Cinema
>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).

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!
Reply | Threaded
Open this post in threaded view
|

Re: xyz to rgb conversion

SK Cinema
In reply to this 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!
Reply | Threaded
Open this post in threaded view
|

Re: xyz to rgb conversion

Carl Eugen Hoyos
SK Cinema <senthil <at> real-image.com> writes:

> 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).

> The command line I used was:
> 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

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: xyz to rgb conversion

SK Cinema
<quote author="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.

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!
Reply | Threaded
Open this post in threaded view
|

Re: xyz to rgb conversion

Andreas Gumm-2
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
[hidden email]
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.


2013/10/4 SK Cinema <[hidden email]>

>
> (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.
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: xyz to rgb conversion

Carl Eugen Hoyos
In reply to this post by SK Cinema
SK Cinema <senthil <at> real-image.com> writes:

> > 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.)

> 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

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: xyz to rgb conversion

SK Cinema
Carl Eugen Hoyos said:
>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.

>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