How to get out manipulated frames lossless?

It’s not long that I came to OpenCV so my experience
is quite limited.
Recently I had the task of analysing/ manipulation
video material where OpenCV’s algs do fit very well.
But first of all I checked if there are no problems
reading in a video and writing it out losslessly right away.
I wasn’t successful with it, no matter what I tried:

I read a video (YUV4.2.1) from file by VideoCapture,
get the frames into Mat structure
and write them back by a VideoWriter.
But the existing lossless codecs (FFV1 and HFYU) produce
all a bit darker than the original (as they are converted to RGBA?).

So my question:
How do I get out video material lossless?
(Somewhere I read to use ffmpeg directly…
Does this mean I should write a VideoCapture on my own?)

Actually I cannot understand how this could be a problem
as I’m at v.3.4.10, and not 0.4beta… :slight_smile:

Thank you for hints.

Addendum:
Can anybody please confirm or disconfirm that?
BTW Not only that the specifications of FFV1 and HFYU do not allow RGB(A).
Also VideoWriter’s AVC1 output is bad and wrong.
Will this do in v.4.8?

no. it is perfectly fine. you might have to adjust bitrate or quality level.

use a lossless codec and it can be. do you think you used lossless codecs?

apart from compression, there’s the matter of color spaces.

that might be best. use ffmpeg’s libraries directly.

there are ways to disable some of the processing that opencv performs on decoded video frames. I can’t tell if that will satisfy you.

best to write your own.

Thanks for your reply :slight_smile:
Still…

  1. There is no way to adjust bitrate level. Just the quality level. And setting this has NO effect at all. The default value (which?) produces bad and wrong result filtes. Did you checked it by yourself? I did.
  2. As I wrote opencv only offers only FFV1 and HFYU for lossless encoding. And VideoWrite always writes them as RGB(A) (as mentioned which doesn’t exist by specification).
  3. What do you mean by “use ffmepeg’s libraries directly”? Write my own VideoWriter?
  4. Again: Does v.4.8. works correctly (not in theory but in practise)?

provide a MRE and I might.

there is. just undocumented.