How to preserve colorspace in ffmpeg
This command preserved the colorspace and also video didnt get darker after transcoding
ffmpeg -i input.mp4 -color_primaries smpte170m -color_trc smpte170m -colorspace smpte170m -r 25 -crf 18 output.mp4

source: https://kdenlive.org/en/project/color-hell-ffmpeg-transcoding-and-preserving-bt-601/
more about colorspace: https://trac.ffmpeg.org/wiki/colorspace