From 37ae3935e9e58a1b8c2beac797f54e8e2bf053e1 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Tue, 31 Oct 2023 10:48:13 +0100 Subject: [PATCH] to_lavc_vid_conv: set AVFrame CS and range Some encoders use `colorspace` and `color_range` from AVFrame, eg. _hevc_videotoolbox_: uv -t testcard -c libavcodec:encoder=hevc_videotoolbox (defaults to bgra, because other foramts don't keep 4:2:2 subsampling, supported at the time: videotoolbox_vld nv12 yuv420p bgra p010le). Fixed error was producing this message: ```` [lavc hevc_videotoolbox @ 0x12fc04190] Could not get pixel format for color format 'bgra' range 'unknown'. [lavc hevc_videotoolbox @ 0x12fc04190] Error: Cannot convert format 28 color_range 0: -22 ``` --- src/libavcodec/to_lavc_vid_conv.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libavcodec/to_lavc_vid_conv.c b/src/libavcodec/to_lavc_vid_conv.c index 08069283e..d26561e2e 100644 --- a/src/libavcodec/to_lavc_vid_conv.c +++ b/src/libavcodec/to_lavc_vid_conv.c @@ -1618,6 +1618,11 @@ struct to_lavc_vid_conv *to_lavc_vid_conv_init(codec_t in_pixfmt, int width, int s->tmp_frame->width = s->out_frame->width = width; s->tmp_frame->height =s->out_frame->height = height; + get_av_pixfmt_details(out_pixfmt, &s->out_frame->colorspace, + &s->out_frame->color_range); + get_av_pixfmt_details(out_pixfmt, &s->tmp_frame->colorspace, + &s->tmp_frame->color_range); + ret = av_frame_get_buffer(s->out_frame, 0); if (ret < 0) { log_msg(LOG_LEVEL_ERROR, "Could not allocate raw picture buffer\n");