Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Allow mastering-display and content-light passthrough from ffmpeg #2554

Open
cdgriffith opened this issue Sep 22, 2020 · 10 comments

Comments

@cdgriffith
Copy link

cdgriffith commented Sep 22, 2020

To have better parity with the standalone encoder, it would be nice to be able to provide mastering-display and content-light through FFmpeg's rav1e-params (similar to how x265-params works)

Suggested method:

ffmpeg.exe -y -i "video.mkv" -map 0:0 -pix_fmt yuv420p10le -c:v:0 librav1e -qp 20 -color_primaries bt2020 -color_trc smpte2084  \
-rav1e-params "mastering-display=G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,1):content-light=1016,115"  "converted.mkv"

Original Issue:
Hello, I am trying to convert a 10-bit BT2020 with librav1e (compiled 2020-09-21, commit edfc865) via FFmpeg.

It works as expected using rav1e.exe itself:

ffmpeg -y -i "short.mkv" -map 0 -pix_fmt yuv420p10le raw.y4m 
rav1e.exe raw.y4m --speed 10 --quantizer 50 --tiles 8 --primaries=BT2020 --transfer=SMPTE2084 --matrix=bt2020ncl --mastering-display=G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,1) --content-light=1016,115 -o out.ivf

But using librav1e it says they are unrecognized options:

ffmpeg.exe -y -i "short.mkv" -map 0:0 -pix_fmt yuv420p10le -c:v:0 librav1e -strict experimental -speed 10 -tile-columns 8 -tile-rows 8 -tiles 8 -rav1e-params "primaries=BT2020:transfer=SMPTE2084:matrix=bt2020ncl:mastering-display=G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,1):content-light=1016,115" -qp 20    "converted.mkv"

...

 Stream #0:0 -> #0:0 (hevc (native) -> av1 (librav1e))

[librav1e @ 00000217911c6d40] Invalid value for primaries: BT2020.
[librav1e @ 00000217911c6d40] Invalid value for transfer: SMPTE2084.
[librav1e @ 00000217911c6d40] Invalid value for matrix: bt2020ncl.
[librav1e @ 00000217911c6d40] Invalid value for mastering-display: G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,1).
[librav1e @ 00000217911c6d40] Invalid value for content-light: 1016,115.

I wasn't sure if this wasn't supported yet, or I was passing the params incorrectly somehow.

Thanks!

@barrbrain
Copy link
Collaborator

The ffmpeg wrapper currently maps matrix, primaries and transfer from ffmpeg-native configuration: colorspace, color_primaries and color_trc. Mastering and content-light appear not to be mapped in ffmpeg master.

@jamrial
Copy link
Contributor

jamrial commented Sep 22, 2020

the rav1e-params ffmpeg option is mapped to the rav1e_config_parse() C API function, and none of those you listed are among the supported keys. You can see what's supported in the rav1e.h doxy (Unfortunately, there's apparently no way to print the supported keys at runtime).

@cdgriffith
Copy link
Author

@barrbrain Thanks for the quick info, color_primaries and color_trc work as expected! colorspace is giving an error of Undefined constant or missing '(' in 'bt2020' with whatever I try, unsure what options to provide that.

@jamrial Good to know! Is there already a feature request to have mastering-display and content-light added? If not could change this ticket into that.

@jamrial
Copy link
Contributor

jamrial commented Sep 22, 2020

For colorspace you need to use bt2020nc or bt2020c. See https://ffmpeg.org/ffmpeg-codecs.html

And i don't know if there's such a feature request.

@cdgriffith cdgriffith changed the title rav1e-params are not being reconized Feature Request: Allow mastering-display and content-light passthrough from ffmpeg Sep 22, 2020
@barrbrain
Copy link
Collaborator

@lu-zero Are mastering-display and content-light available through the C API yet?

@lu-zero
Copy link
Collaborator

lu-zero commented Jun 3, 2021

/**
 * Set the content light level information for HDR10 streams.
 *
 * Return a negative value on error or 0.
 */
int rav1e_config_set_content_light(RaConfig *cfg,
                                   uint16_t max_content_light_level,
                                   uint16_t max_frame_average_light_level);

/**
 * Set the mastering display information for HDR10 streams.
 *
 * primaries and white_point arguments are RaChromaticityPoint, containing 0.16 fixed point
 * values.
 * max_luminance is a 24.8 fixed point value.
 * min_luminance is a 18.14 fixed point value.
 *
 * Returns a negative value on error or 0.
 */
int rav1e_config_set_mastering_display(RaConfig *cfg,
                                       const RaChromaticityPoint primaries[3],
                                       RaChromaticityPoint white_point,
                                       uint32_t max_luminance,
                                       uint32_t min_luminance);

the C API has it since 7d679b4

@cdgriffith
Copy link
Author

Tried a custom build of FFmpeg with latest 0.5-beta and still seems to not be incorporated. At least doesn't take the arguments the same way the command line does. (Not sure what else than being in the capi is needed)

Working command line:

rav1e.exe  artist_480.y4m --primaries BT2020 --transfer SMPTE2084 --matrix BT2020NCL --mastering-display "G(0.15,0.06)B(0.68,0.32)R(0.265,0.69)WP(0.3127,0.329)L(1000,0.005)" --content-light 1000,200 --speed 10 --quantizer 50 --output artist_rav1e.ivf

Non-working ffmpeg equivalent.

ffmpeg.exe -i artist_480.y4m  -pix_fmt yuv420p10le -c:v:0 librav1e -speed 10 -qp 50 -color_primaries bt2020 -color_trc smpte2084 -colorspace bt2020nc -rav1e-params "mastering-display='G(0.15,0.06)B(0.68,0.32)R(0.265,0.69)WP(0.3127,0.329)L(1000,0.005)':content-light=1000,200"  converted.mkv

Error:

[librav1e @ 000001f2206d76c0] Invalid value for mastering-display:G(0.15,0.06)B(0.68,0.32)R(0.265,0.69)WP(0.3127,0.329)L(1000,0.005).
[librav1e @ 000001f2206d76c0] Invalid value for content-light: 1000,200.

@lu-zero
Copy link
Collaborator

lu-zero commented Aug 10, 2021

I assume the ffmpeg wrapper is not calling those functions. Can you please check what is the wrapper doing?

@cdgriffith
Copy link
Author

Oh whoops, looking back at @jamrial comment, would need to be defined https://github.com/xiph/rav1e/blob/master/src/capi.rs#L609 and is not there yet.

@lu-zero
Copy link
Collaborator

lu-zero commented Aug 10, 2021

Patch very welcome, I'll land it before cutting 0.5 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants