[FFmpeg-devel] prores_ks: use CodecContext for color information if specified

Martin Vignali martin.vignali at gmail.com
Mon Oct 15 14:08:26 EEST 2018


Le lun. 15 oct. 2018 à 11:24, Marc-Antoine ARNAUD <
arnaud.marcantoine at gmail.com> a écrit :

> Hi Martin,
>
> For my point of view, the AVFrame contains the colorspace for each frame,
> which can be different (maybe not volunteer..).
> The colorspace in AVCodecContext is the "pre-computed" colorspace, used to
> generate the output file, as header/footer of wrappers can require
> colorspace informations (like in MXF, MOV, etc.).
>
> So for me, the AVCodecContext is required and needed to be pre-processed to
> wrote the header, and no AVFrame are processed at this stage.
> The AVFrame colorspace is required to maybe change graph properties in
> real-time (like a colorspace conversion can be set to convert the output
> from different colorspace inputs).
>
> So both are differents, but on my point of view, regarding comments, I
> purpose:
> - AVCodecContext will overwrite the output colorspace (if present)
> - AVFrame can be use in video encoder to setup frame headers packets (like
> in Mpeg2, H.264, H.265, ProRes etc.) if no AVCodecContext is configured.
> - a warning needs to be logged if:
>     - AVCodecContext colorspace don't match to the AVFrame colorspace
>
> Remark: colorspace mean here variables for colorspace, color primaries and
> color transfer.
>
> So maybe for that, as Paul mentionned, it may require to patch that at an
> upper level than encoder to be sure all works similary. But I don't know
> where to be honest.
>
>
Hello Marc,

>From a user point of view :

- if i encode a prores file from a prores file which have different
colorspace in each frame
i expected to have the input colorspace of each frame in the target file.
(So software which use this information will display original and reencode
prores in the same way)
Not sure it's correctly works right now (at least for the prores decoder
part)
In that case colorspace for the muxer, will not be the same than colorspace
for the frame.

- If i would like to set each frame to the right colorspace in a prores
file without reencoding
a bsf (Bitstream filter), can be use to set this info without
decode/reencode
==> Probably not a lot of work, to add this kind of filter

- If i would like to reencode a file, and fix this information at the same
time,
a filter which set the property without converting colorspace can be use
(maybe with a special case to set it only if AVFrame have an unspecifed
colorspace)
(probably need to write one for this)

- If i would like to convert the colorspace of each frame to be sure all
the frames of a file are for example in Rec709
a filter can be use, to convert frame which have another colorspace, and
bypass the frame which already have the right colorspace

For the two last case, i don't know enough libavfilter, to know which is
possible using existing filter,
and what to be add.


For your proposition, i'm not sure auto switching from one way to take
colorspace to another silently
(use AVCodecContext, if AVFrame don't have Colorspace information,  for the
frame header, is a good idea)
Depending of the input file (have information or not for all frames), the
behaviour will be different, probably little hard to use in practice

For the warning if codec context doesn't match AVFrame colorspace,
i agree in theory, but in practice, it can make one warning per frame, and
make ffmpeg log unreadable.


Martin


More information about the ffmpeg-devel mailing list