1

Given master video in mov rle:

Video: qtrle (rle / 0x20656C72), rgb24(progressive) 

Converted the video to a serie of single .bmp frames.

ffmpeg -i source.mov $FRAMES/f%03d.bmp 

Frames from unchanged parts I recompiled to mpeg ts intermediate files:

ffmpeg \ -framerate 25 \ -start_number $i \ -i "$FRAMES/f%03d.bmp" \ -vframes $n \ -c:v libx264rgb \ # libx264 -preset slow \ -tune animation \ -crf 20 \ -pix_fmt rgb24 \ # yuv420p -bsf:v h264_mp4toannexb \ -f mpegts \ -y -an -hide_banner \ "$FOLDER_TS/_${i}_${o}.ts" 

To other part of the clip I applied filters like pad, zoompan, format. Overlaid PNG with transparency, animated. Output to the same format h264 .ts

Concat the .ts parts to mp4 movie file.

Color seems to have changed a little. Can be noticed when joining source movie with the processed one.

What stage of the process could affect the slight changes in colors?

Is it the pixel format conversion or BMP format usage?

How to convert movie file to sinlge frame images preserving exact color?

5
  • other part of the clip I applied filters --> what exactly? Commented Mar 27, 2019 at 17:01
  • Clip length is 10s @ 25fps = 250 frames. Frames 1–50 and 208-250 are kept as is, I render them directly to .ts Over middle frames I overlay PNG with padding and use zoompan to scale/position. All parts joined together looks consistently in color. The slight color difference occurs compared to the original master video. Commented Mar 27, 2019 at 17:10
  • 1
    You can’t convert between RGB and YUV perfectly. It’s a lossy conversion. Commented Mar 28, 2019 at 1:33
  • Thanks @SlimSCSI, after posting the question I figured that too. I tried changing libx264 to libx264rgb and yuv420p to rgb24. That reduced color difference but it's still in place. What else could possibly go wrong? Is BMP format with its bgr24 a good option for intermediate images? Commented Mar 28, 2019 at 7:57
  • Updated code in question with codecs and pixel pformats I tried. Commented Mar 28, 2019 at 8:07

1 Answer 1

1

Solved the problem by setting colormatrix conversion using swscale lib. Added to my filter chain:

scale=in_color_matrix=bt601:out_color_matrix=bt709 

and

-colorspace bt709 

to the output.


References

  1. ffmpeg scale filter
  2. ffmpeg colormatrix filter
  3. colorspace on ffmpeg wiki
  4. question on video.stackexchange

Credits

Found the advice on VideoHelp forum reply from 2017, which in turn references the question on this video.stackexchange. Thanks again, Gyan!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.