Page MenuHome

FFmpeg: Fix H264 lossless render not lossless
ClosedPublic

Authored by Richard Antalik (ISS) on Jun 2 2021, 2:04 AM.

Details

Summary

While encoder parameters for lossless encoding are set correctly,
output is not lossless due to pixel format being set to
AV_PIX_FMT_YUV420P which is inherently lossy due to chroma subsampling.

This was reported in T61569 and was merged to T57397, but there were
2 bugs - one for encoding and one for decoding.

Set pixel format to AV_PIX_FMT_YUV444P when rendering lossless H264
files. This format isn't available in codec->pix_fmts[0] and it looks,
that it has to be hard-coded.

Diff Detail

Repository
rB Blender
Branch
master
Build Status
Buildable 14887
Build 14887: arc lint + arc unit

Event Timeline

Richard Antalik (ISS) requested review of this revision.Jun 2 2021, 2:04 AM
Richard Antalik (ISS) created this revision.
This revision is now accepted and ready to land.Jun 2 2021, 9:31 AM

Hmm, isn't this true for VP9 as well?
Wouldn't you want to do this for other codecs besides H264?

Hmm, isn't this true for VP9 as well?
Wouldn't you want to do this for other codecs besides H264?

Will check this

Right so this was true for VP9 too. I was thinking if there is a better way to express this in more universal way, but I am not sure. Worst case would be that unsupported pixel format would be set.
Also VP9 doesn't have rd->ffcodecdata.flags & FFMPEG_LOSSLESS_OUTPUT set, so I have used context->ffmpeg_crf == 0 now which isn't quite readable.

Will check if this can be fixed easily.

  • Apply same logic for VP9 codec