obs-ffmpeg: Improve color space handling

Add support for VIDEO_CS_SRGB.

Use SMPTE 170M for 601 instead of undef/BT470BG. This is the
American/Chromium way of handling 601.

Add color metadata to the container file as well via ffmpeg-mux.
This commit is contained in:
jpark37
2020-01-25 10:29:38 -08:00
parent a69151e204
commit 37f01b35f6
6 changed files with 129 additions and 21 deletions

View File

@@ -79,6 +79,10 @@ struct main_params {
int height;
int fps_num;
int fps_den;
int color_primaries;
int color_trc;
int colorspace;
int color_range;
char *acodec;
char *muxer_settings;
};
@@ -249,6 +253,18 @@ static bool init_params(int *argc, char ***argv, struct main_params *params,
return false;
if (!get_opt_int(argc, argv, &params->height, "video height"))
return false;
if (!get_opt_int(argc, argv, &params->color_primaries,
"video color primaries"))
return false;
if (!get_opt_int(argc, argv, &params->color_trc,
"video color trc"))
return false;
if (!get_opt_int(argc, argv, &params->colorspace,
"video colorspace"))
return false;
if (!get_opt_int(argc, argv, &params->color_range,
"video color range"))
return false;
if (!get_opt_int(argc, argv, &params->fps_num, "video fps num"))
return false;
if (!get_opt_int(argc, argv, &params->fps_den, "video fps den"))
@@ -327,6 +343,10 @@ static void create_video_stream(struct ffmpeg_mux *ffm)
context->height = ffm->params.height;
context->coded_width = ffm->params.width;
context->coded_height = ffm->params.height;
context->color_primaries = ffm->params.color_primaries;
context->color_trc = ffm->params.color_trc;
context->colorspace = ffm->params.colorspace;
context->color_range = ffm->params.color_range;
context->extradata = extradata;
context->extradata_size = ffm->video_header.size;
context->time_base =