From 0785258d22f4d86ed9d685c3e9fd1b78c32e5bcb Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Wed, 4 Nov 2015 21:42:25 +0100 Subject: [PATCH] transcoding: added patch from lekma to do proper pixel format support for nvenc and intel's qsv --- src/plumbing/transcoding.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/plumbing/transcoding.c b/src/plumbing/transcoding.c index 55c0f9259..922adbe35 100644 --- a/src/plumbing/transcoding.c +++ b/src/plumbing/transcoding.c @@ -1250,7 +1250,11 @@ transcoder_stream_video(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt) switch (ts->ts_type) { case SCT_MPEG2VIDEO: - octx->pix_fmt = AV_PIX_FMT_YUV420P; + if (!strcmp(ocodec->name, "nvenc") || !strcmp(ocodec->name, "mpeg2_qsv")) + octx->pix_fmt = AV_PIX_FMT_NV12; + else + octx->pix_fmt = AV_PIX_FMT_YUV420P; + octx->flags |= CODEC_FLAG_GLOBAL_HEADER; if (t->t_props.tp_vbitrate < 64) { @@ -1297,11 +1301,20 @@ transcoder_stream_video(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt) break; case SCT_H264: - octx->pix_fmt = AV_PIX_FMT_YUV420P; + if (!strcmp(ocodec->name, "nvenc") || !strcmp(ocodec->name, "h264_qsv")) + octx->pix_fmt = AV_PIX_FMT_NV12; + else + octx->pix_fmt = AV_PIX_FMT_YUV420P; + octx->flags |= CODEC_FLAG_GLOBAL_HEADER; // Default = "medium". We gain more encoding speed compared to the loss of quality when lowering it _slightly_. - av_dict_set(&opts, "preset", "faster", 0); + if (!strcmp(ocodec->name, "nvenc")) + av_dict_set(&opts, "preset", "hq", 0); + else if (!strcmp(ocodec->name, "h264_qsv")) + av_dict_set(&opts, "preset", "medium", 0); + else + av_dict_set(&opts, "preset", "faster", 0); // All modern devices should support "high" profile av_dict_set(&opts, "profile", "high", 0); -- 2.47.3