]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
libav: transcode in HEVC
authorlekma <lekmalek@gmail.com>
Tue, 29 Sep 2015 13:49:06 +0000 (15:49 +0200)
committerJaroslav Kysela <perex@perex.cz>
Tue, 29 Sep 2015 14:26:06 +0000 (16:26 +0200)
- add HEVC to the set of working encoders
- add default options
- copy over extradata

src/plumbing/transcoding.c

index 18e77ed4d597533f19f73a412c850fa5a48488fb..aa401774bc76122e7a9ac5df63e93065e5cf50ac 100644 (file)
@@ -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;
     }