Video UHD H265 HEVC or VP9 transcoding params

Hi,

I have a 2160p UHD HEVC video and want to transcode it to the same or to VP9 and lower the bitrate a bit.
These kind of flavors are not present in KMC.

So I added it in the admin pannel->developer->Flavor Params

First try was H265 in an MP4 container
second try VP9 in WebM container

They both failed and displayed error when transcoding.

This is the log

2016-11-09 09:26:45 [0.000224] [127.0.0.1] [1219425556] [46] [API] [kFlowHelper::handleConvertFailed] ERR: exception ‘Exception’ with message ‘Saving conversion log: key [object_type:[4], object_id:[0_v9aouw9b], version:[102], object_sub_type[2], partner_id[102]] already exists’ in /opt/kaltura/app/infra/log/KalturaLog.php:83
Stack trace:
#0 /opt/kaltura/app/alpha/apps/kaltura/lib/batch2/kFlowHelper.php(1160): KalturaLog::err(‘Saving conversi…’)

Jean.

Hi @jeansalim83,

I need more info… specifically:

mysql> select * from flavor_params where ID=$YOUR_FLAV_ID\G
and the contents of the conversion log, which should be under /opt/kaltura/web/content/entry/data/ with the pattern $ENTRY_ID_$FLAVOR_ID*.conv.log

Hello, @jess

mysql> select * from flavor_params where ID=42\G
*************************** 1. row ***************************
id: 42
version: 0
partner_id: 102
name: UHD/2160 - WEB (H265/12000)
system_name: UHD/2160 - WEB (H265/12000)
tags: NULL
description: UHD/2160 - WEB (H265/12000)
ready_behavior: 0
created_at: 2016-11-04 18:40:29
updated_at: 2016-11-04 18:40:29
deleted_at: NULL
is_default: 1
format: mp4
video_codec: h265
video_bitrate: 12288
audio_codec: aac
audio_bitrate: 128
audio_channels: 0
audio_sample_rate: 0
audio_resolution: 0
width: 0
height: 2160
frame_rate: 0
gop_size: 0
two_pass: 1
conversion_engines: 2,99,3
conversion_engines_extra_params: -flags +loop+mv4 -cmp 256 -partitions +parti4x4+partp8x8+partb8x8 -trellis 1 -refs 1 -me_range 16 -keyint_min 20 -sc_threshold 40 -i_qfactor 0.71 -bt 100k -maxrate 400k -bufsize 1200k -rc_eq ‘blurCplx^(1-qComp)’ -level 30 -async 2 -vsync 1 -threads 4 | -flags +loop+mv4 -cmp 256 -partitions +parti4x4+partp8x8+partb8x8 -trellis 1 -refs 1 -me_range 16 -keyint_min 20 -sc_threshold 40 -i_qfactor 0.71 -bt 100k -maxrate 400k -bufsize 1200k -rc_eq ‘blurCplx^(1-qComp)’ -level 30 -async 2 -vsync 1 | -x264encopts qcomp=0.6:qpmin=10:qpmax=50:qpstep=4:frameref=1:bframes=0:threads=auto:level_idc=30:global_header:partitions=i4x4+p8x8+b8x8:trellis=1:me_range=16:keyint_min=20:scenecut=40:ipratio=0.71:ratetol=20:vbv-maxrate=400:vbv-bufsize=1200
custom_data: a:6:{s:16:“FlavorVideoCodec”;s:4:“h265”;s:18:“FlavorVideoBitrate”;i:12288;s:16:“FlavorAudioCodec”;s:3:“aac”;s:18:“FlavorAudioBitrate”;i:128;s:13:“FlavorTwoPass”;b:1;s:19:“requiredPermissions”;a:0:{}}
view_order: 0
bypass_by_extension: NULL
creation_mode: 1
deinterlice: 0
rotate: 0
operators: NULL
engine_version: NULL
type: 1
1 row in set (0.00 sec)

mysql> select * from flavor_params where ID=43\G
*************************** 1. row ***************************
id: 43
version: 0
partner_id: 102
name: UHD/2160 - WEB (VP9/12000)
system_name: UHD/2160 - WEB (VP9/12000)
tags: NULL
description: UHD/2160 - WEB (VP9/12000)
ready_behavior: 0
created_at: 2016-11-08 10:29:08
updated_at: 2016-11-08 10:29:08
deleted_at: NULL
is_default: 1
format: webm
video_codec: vp9
video_bitrate: 12288
audio_codec: aac
audio_bitrate: 1024
audio_channels: 0
audio_sample_rate: 0
audio_resolution: 0
width: 0
height: 2160
frame_rate: 0
gop_size: 0
two_pass: 1
conversion_engines: 2,99,3
conversion_engines_extra_params: -flags +loop+mv4 -cmp 256 -partitions +parti4x4+partp8x8+partb8x8 -trellis 1 -refs 1 -me_range 16 -keyint_min 20 -sc_threshold 40 -i_qfactor 0.71 -bt 100k -maxrate 400k -bufsize 1200k -rc_eq ‘blurCplx^(1-qComp)’ -level 30 -async 2 -vsync 1 -threads 4 | -flags +loop+mv4 -cmp 256 -partitions +parti4x4+partp8x8+partb8x8 -trellis 1 -refs 1 -me_range 16 -keyint_min 20 -sc_threshold 40 -i_qfactor 0.71 -bt 100k -maxrate 400k -bufsize 1200k -rc_eq ‘blurCplx^(1-qComp)’ -level 30 -async 2 -vsync 1 | -x264encopts qcomp=0.6:qpmin=10:qpmax=50:qpstep=4:frameref=1:bframes=0:threads=auto:level_idc=30:global_header:partitions=i4x4+p8x8+b8x8:trellis=1:me_range=16:keyint_min=20:scenecut=40:ipratio=0.71:ratetol=20:vbv-maxrate=400:vbv-bufsize=1200
custom_data: a:6:{s:16:“FlavorVideoCodec”;s:3:“vp9”;s:18:“FlavorVideoBitrate”;i:12288;s:16:“FlavorAudioCodec”;s:3:“aac”;s:18:“FlavorAudioBitrate”;i:1024;s:13:“FlavorTwoPass”;b:1;s:19:“requiredPermissions”;a:0:{}}
view_order: 0
bypass_by_extension: NULL
creation_mode: 1
deinterlice: 0
rotate: 0
operators: NULL
engine_version: NULL
type: 1
1 row in set (0.00 sec)

[root@backend1 1]# cat 0_nafs3ucf_0_v9aouw9b_42.conv.log


Executed by [ffmpeg] flavor params id [43]


ffmpeg-experim -i /opt/kaltura/web//content/entry/data/0/1/0_nafs3ucf_0_ustp70k6_2.mkv -c:v libvpx-vp9 -b:v 12288k -s 3840x2160 -r 23.976 -g 48 -c:a aac -filter_complex ‘aresample=async=1:min_hard_comp=0.100000:first_pts=0’ -strict -2 -b:a 1024k -ar 44100 -f webm -sn -flags +loop+mv4 -cmp 256 -partitions +parti4x4+partp8x8+partb8x8 -trellis 1 -refs 1 -me_range 16 -keyint_min 20 -sc_threshold 40 -i_qfactor 0.71 -bt 100k -maxrate 400k -bufsize 1200k -rc_eq ‘blurCplx^(1-qComp)’ -level 30 -vsync 1 -threads 4 -an -passlogfile /opt/kaltura/tmp/convert/convert_0_nafs3ucf_50e80.2pass.log -pass 1 -fastfirstpass 1 -y /dev/null && /opt/kaltura/bin/ffmpeg -i /opt/kaltura/web//content/entry/data/0/1/0_nafs3ucf_0_ustp70k6_2.mkv -c:v libvpx-vp9 -b:v 12288k -s 3840x2160 -r 23.976 -g 48 -c:a aac -filter_complex ‘aresample=async=1:min_hard_comp=0.100000:first_pts=0’ -strict -2 -b:a 1024k -ar 44100 -f webm -sn -flags +loop+mv4 -cmp 256 -partitions +parti4x4+partp8x8+partb8x8 -trellis 1 -refs 1 -me_range 16 -keyint_min 20 -sc_threshold 40 -i_qfactor 0.71 -bt 100k -maxrate 400k -bufsize 1200k -rc_eq ‘blurCplx^(1-qComp)’ -level 30 -vsync 1 -threads 4 -passlogfile /opt/kaltura/tmp/convert/convert_0_nafs3ucf_50e80.2pass.log -pass 2 -y /opt/kaltura/tmp/convert/convert_0_nafs3ucf_50e80 >> “/opt/kaltura/tmp/convert/convert_0_nafs3ucf_50e80.log” 2>&1


-i inFileName -c:v libvpx-vp9 -b:v 12288k -s 3840x2160 -r 23.976 -g 48 -c:a aac -filter_complex ‘aresample=async=1:min_hard_comp=0.100000:first_pts=0’ -strict -2 -b:a 1024k -ar 44100 -f webm -sn -flags +loop+mv4 -cmp 256 -partitions +parti4x4+partp8x8+partb8x8 -trellis 1 -refs 1 -me_range 16 -keyint_min 20 -sc_threshold 40 -i_qfactor 0.71 -bt 100k -maxrate 400k -bufsize 1200k -rc_eq ‘blurCplx^(1-qComp)’ -level 30 -vsync 1 -threads 4 -an -passlogfile outFileName.2pass.log -pass 1 -fastfirstpass 1 -y /dev/null && binaryName -i inFileName -c:v libvpx-vp9 -b:v 12288k -s 3840x2160 -r 23.976 -g 48 -c:a aac -filter_complex ‘aresample=async=1:min_hard_comp=0.100000:first_pts=0’ -strict -2 -b:a 1024k -ar 44100 -f webm -sn -flags +loop+mv4 -cmp 256 -partitions +parti4x4+partp8x8+partb8x8 -trellis 1 -refs 1 -me_range 16 -keyint_min 20 -sc_threshold 40 -i_qfactor 0.71 -bt 100k -maxrate 400k -bufsize 1200k -rc_eq ‘blurCplx^(1-qComp)’ -level 30 -vsync 1 -threads 4 -passlogfile outFileName.2pass.log -pass 2 -y outFileName



[root@backend1 1]# cat 0_nafs3ucf_0_sm1y1i5v_42.conv.log


Executed by [mencoder] flavor params id [42]


/opt/kaltura/bin/mencoder /opt/kaltura/web//content/entry/data/0/1/0_nafs3ucf_0_ustp70k6_2.mkv -of lavf -lavfopts format=mp4 -ofps 23.976:keyint=48 -vf harddup,scale=3840:2160 -oac faac -faacopts mpeg=4:object=2:tns:raw:br=128 -srate 44100 -x264encopts qcomp=0.6:qpmin=10:qpmax=50:qpstep=4:frameref=1:bframes=0:threads=auto:level_idc=30:global_header:partitions=i4x4+p8x8+b8x8:trellis=1:me_range=16:keyint_min=20:scenecut=40:ipratio=0.71:ratetol=20:vbv-maxrate=400:vbv-bufsize=1200 -o /opt/kaltura/tmp/convert/tmp_convert_58218a813315a >> “/opt/kaltura/tmp/convert/convert_0_nafs3ucf_32a74.log” 2>&1


inFileName -of lavf -lavfopts format=mp4 -ofps 23.976:keyint=48 -vf harddup,scale=3840:2160 -oac faac -faacopts mpeg=4:object=2:tns:raw:br=128 -srate 44100 -x264encopts qcomp=0.6:qpmin=10:qpmax=50:qpstep=4:frameref=1:bframes=0:threads=auto:level_idc=30:global_header:partitions=i4x4+p8x8+b8x8:trellis=1:me_range=16:keyint_min=20:scenecut=40:ipratio=0.71:ratetol=20:vbv-maxrate=400:vbv-bufsize=1200 -o outFileName

MEncoder SVN-r29408-snapshot-3.4.6 © 2000-2009 MPlayer Team
The ofps option must be a floating point number or a ratio (numerator[:/]denominator): 23.976:keyint=48
Error parsing option on the command line: -ofps

Exiting… (error parsing command line)

I tampered a bit with the parameters, but still got an error. But this time it seems ffmpeg still has wrong parameters for transcoding

[root@backend1 /]# cat /opt/kaltura/web/content/entry/data/0/1/0_so0loooy_0_hrtim162_22.conv.log


Executed by [ffmpeg_aux] flavor params id [44]


/opt/kaltura/bin/ffmpeg-aux -i /opt/kaltura/web//content/entry/data/0/1/0_so0loooy_0_zvcsncwg_12.mp4 -c:v -pix_fmt yuv420p -b:v 2090k -s 3840x2160 -r 24 -g 48 -aspect 3840:2160 -an -f matroska -sn -flags +loop+mv4 -cmp 256 -partitions +parti4x4+partp8x8+partb8x8 -trellis 1 -refs 1 -me_range 16 -keyint_min 20 -sc_threshold 40 -i_qfactor 0.71 -bt 100k -maxrate 400k -bufsize 1200k -rc_eq ‘blurCplx^(1-qComp)’ -level 30 -async 2 -vsync 1 -y /opt/kaltura/tmp/convert/convert_0_so0loooy_82f08 >> “/opt/kaltura/tmp/convert/convert_0_so0loooy_82f08.log” 2>&1


-i inFileName -c:v -pix_fmt yuv420p -b:v 2090k -s 3840x2160 -r 24 -g 48 -aspect 3840:2160 -an -f matroska -sn -flags +loop+mv4 -cmp 256 -partitions +parti4x4+partp8x8+partb8x8 -trellis 1 -refs 1 -me_range 16 -keyint_min 20 -sc_threshold 40 -i_qfactor 0.71 -bt 100k -maxrate 400k -bufsize 1200k -rc_eq ‘blurCplx^(1-qComp)’ -level 30 -async 2 -vsync 1 -y outFileName

ffmpeg version 2.1.3 Copyright © 2000-2013 the FFmpeg developers
built on Oct 15 2015 09:28:48 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-11)
configuration: --prefix=/opt/kaltura/ffmpeg-2.1.3 --libdir=/opt/kaltura/ffmpeg-2.1.3/lib --shlibdir=/opt/kaltura/ffmpeg-2.1.3/lib --extra-cflags=’-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC’ --extra-cflags=’-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC -I/opt/kaltura/include’ --extra-ldflags=-L/opt/kaltura/lib --disable-devices --enable-bzlib --enable-libgsm --enable-libmp3lame --enable-libschroedinger --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-filter=movie --enable-avfilter --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libvpx --enable-libspeex --enable-libass --enable-postproc --enable-pthreads --enable-static --enable-shared --enable-gpl --disable-debug --disable-optimizations --enable-gpl --enable-pthreads --enable-swscale --enable-vdpau --enable-bzlib --disable-devices --enable-filter=movie --enable-version3 --enable-indev=lavfi --enable-x11grab
libavutil 52. 48.101 / 52. 48.101
libavcodec 55. 39.101 / 55. 39.101
libavformat 55. 19.104 / 55. 19.104
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 90.100 / 3. 90.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from ‘/opt/kaltura/web//content/entry/data/0/1/0_so0loooy_0_zvcsncwg_12.mp4’:
Metadata:
major_brand : iso4
minor_version : 1
compatible_brands: iso4hvc1
creation_time : 2014-08-25 21:13:56
Duration: 00:00:10.00, start: 0.083333, bitrate: 2013 kb/s
Stream #0:0(und): Video: hevc (hvc1 / 0x31637668), yuv420p, 3840x2160, 2010 kb/s, 24 fps, 24 tbr, 24k tbn, 24k tbc (default)
Metadata:
creation_time : 2014-08-25 21:13:56
handler_name : hevc:fps=24@GPAC0.5.1-DEV-rev4807
[NULL @ 0x1732ae0] Unable to find a suitable output format for ‘yuv420p’

I tampered a bit with the ffmpeg command generated because it didn’t include -c:v libx265
so I added it as below but I’m getting an error: Unknown encoder ‘libx265’

command:
/opt/kaltura/bin/ffmpeg-aux -i /opt/kaltura/web//content/entry/data/0/1/0_so0loooy_0_zvcsncwg_12.mp4 -c:v libx265 -pix_fmt yuv420p -b:v 1500k -s 3840x2160 -r 24 -g 48 -aspect 3840:2160 -an -f mp4 -flags +loop+mv4 -cmp 256 -partitions +parti4x4+partp8x8+partb8x8 -trellis 1 -refs 1 -me_range 16 -keyint_min 20 -sc_threshold 40 -i_qfactor 0.71 -bt 100k -maxrate 400k -bufsize 1200k -rc_eq ‘blurCplx^(1-qComp)’ -level 30 -async 2 -vsync 1 -y /opt/kaltura/tmp/convert/convert_0_so0loooy_b0a92 >> “/opt/kaltura/tmp/convert/convert_0_so0loooy_b0a92.log” -loglevel debug

Hello Jess, did you find what could be the reason behind that? It seems ffmpeg isn’t even compiled with libx265.

Jean.

Hello Jean,

Yes, the current ffmpeg version does not feature X265 support. We plan to include it in the next ffmpeg release we make, along with updating to version to ffmpeg 3.2.n. I can give you a link to a test build if you’d like to try it. It will also require a new Nginx package since our nginx depends on ffmpeg for some of the vod module functions.

Thanks Jess, I’ll just wait to the next release.

Hello Jean,

12.7.0 was just released. That includes kaltura-ffmpeg 3.2 with support for x265.
See: Kaltura CE 12.7.0 released

Thanks,