From: lekma Date: Tue, 29 Sep 2015 13:49:06 +0000 (+0200) Subject: libav: transcode in HEVC X-Git-Tag: v4.2.1~2027 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5fd66bf60f375f1d47e6f89fa6b35dd80dca0956;p=thirdparty%2Ftvheadend.git libav: transcode in HEVC - add HEVC to the set of working encoders - add default options - copy over extradata --- diff --git a/src/plumbing/transcoding.c b/src/plumbing/transcoding.c index 18e77ed4d..aa401774b 100644 --- a/src/plumbing/transcoding.c +++ b/src/plumbing/transcoding.c @@ -132,7 +132,7 @@ typedef struct transcoder { #define WORKING_ENCODER(x) \ ((x) == AV_CODEC_ID_H264 || (x) == AV_CODEC_ID_MPEG2VIDEO || \ (x) == AV_CODEC_ID_VP8 || /* (x) == AV_CODEC_ID_VP9 || */ \ - (x) == AV_CODEC_ID_AAC || \ + (x) == AV_CODEC_ID_HEVC || (x) == AV_CODEC_ID_AAC || \ (x) == AV_CODEC_ID_MP2 || (x) == AV_CODEC_ID_VORBIS) /** @@ -939,7 +939,8 @@ send_video_packet(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt, if (!octx->coded_frame) return; - if (ts->ts_type == SCT_H264 && octx->extradata_size && + if ((ts->ts_type == SCT_H264 || ts->ts_type == SCT_HEVC) && + octx->extradata_size && (ts->ts_first || octx->coded_frame->pict_type == AV_PICTURE_TYPE_I)) { n = pkt_alloc(NULL, octx->extradata_size + epkt->size, epkt->pts, epkt->dts); memcpy(pktbuf_ptr(n->pkt_payload), octx->extradata, octx->extradata_size); @@ -1199,6 +1200,20 @@ transcoder_stream_video(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt) break; + case SCT_HEVC: + octx->pix_fmt = PIX_FMT_YUV420P; + octx->flags |= CODEC_FLAG_GLOBAL_HEADER; + + av_dict_set(&opts, "preset", "superfast", 0); + av_dict_set(&opts, "tune", "fastdecode", 0); + av_dict_set(&opts, "crf", "18", 0); + // decrease latency as much as possible + av_dict_set(&opts, "x265_opts", "bframes=0", 0); + av_dict_set(&opts, "x265_opts", ":rc-lookahead=0", AV_DICT_APPEND); + av_dict_set(&opts, "x265_opts", ":scenecut=0", AV_DICT_APPEND); + + break; + default: break; }