Cant't transcode with NVENC
Added by Andre-Guy Otis almost 4 years ago
Hello,
I tried to compile tvheadend from git but I can't get the NVENC transcoder working. I configure the build with --enable-nvenc
I was able to compile without error but once I tried to use the H264_NVENC, I got this error:
2021-01-28 19:48:48.248 transcode: 0001: 01:H264: [mpeg2video => h264_nvenc]: encode failed
I also tried the latest stable release for Debian Stretch TVH 4.2.8 and that one is working correctly. One thing I noticed is from the codec profile tab, the H264_NVENC preset is not present. However, this preset is available on TVH 4.2.8 version, see images in attachment.
I'm sure there is something wrong when I compile TVH from git but I don't know what I'm doing wrong. Can you guys give me an hint about this?
TVH GIT.PNG (13.2 KB) TVH GIT.PNG | |||
TVH 4.2.8.PNG (16 KB) TVH 4.2.8.PNG |
Replies (92)
RE: Cant't transcode with NVENC - Added by Lukas G over 3 years ago
KODI uses an HTSP (basic, advanced - no) stream, but you can use an htsp or pass streaming profile, or transcoded. In my case, nvenc.
RE: Cant't transcode with NVENC - Added by Andre-Guy Otis over 3 years ago
Kiril St. wrote:
Lukas G wrote:
I found that the memory is freed when playing via VLC player. If I use KODI, each program switch will increase the allocated GPU memory.
Good observation, thanks! I also confimed that behaivour! In kodi 19, tvheadend addon have option: "use http for streaming channels" .When use this option, and channel stops, vram is flushed! When is disabled, vram increase! Maybe this will help for developers to identify problem... Im not use nvidia card, but situation is exactly the same, with AMD GPU!
I also try this and it work but can't use timeshift with http and this is something that I rely on.
Flole Systems wrote:
In kodi there used to be a warning if a non-HTSP profile was specified. If someone removed that warning I don't understand why that was done. That explains why you might think that it's supported to configure it this way.
Some people apparently forced a user to a streaming profile and then used that for kodi transcoding, that's what I meant with "some hack". It seemed to work to some extend but obviously not completely. There is a reason why the HTSP profile exists and why it doesn't offer transcoding (because it's not properly implementer).
I use a streaming profile with kodi for years, since early 4.2 release and it always working fine until now. I don't remember to see such warning about the non-HTSP profile under Kodi.
RE: Cant't transcode with NVENC - Added by Lukas G over 3 years ago
That's right, in version 4.2 transcoding works properly. Each GPU-accelerated transcoding is correctly released in memory. This does not happen after upgrading to 4.3.
Now I've tested the downgrade to 4.2 from 4.3 and the transcoding works.
RE: Cant't transcode with NVENC - Added by Flole Systems over 3 years ago
I just checked and in the latest version of kodi that warning is indeed gone. Also I was able to reproduce this issue.
I submitted a PR for this and it seems to fix it but I have no idea if this is a proper fix so I won't merge it until either Jaroslav approves it or someone can explain to me why this is the proper way of doing it.
RE: Cant't transcode with NVENC - Added by Kiril St. over 3 years ago
Flole Systems, fix work perfect! Thanks!
RE: Cant't transcode with NVENC - Added by dorin ilut over 3 years ago
Kiril St. wrote:
Flole Systems, fix work perfect! Thanks!
indeed. thank you. it works perfect. closes the session after each channel change. now only the nvidia hardware transcoding :).
RE: Cant't transcode with NVENC - Added by Lukas G over 3 years ago
I tried the last 4.3.0 ~ pre + 202103120326-0 ~ built202103120420. And the problem is still the same. nvenc does not free memory when playing via htsp.
RE: Cant't transcode with NVENC - Added by Andre-Guy Otis over 3 years ago
Lukas G wrote:
I tried the last 4.3.0 ~ pre + 202103120326-0 ~ built202103120420. And the problem is still the same. nvenc does not free memory when playing via htsp.
Flole must check with Jaroslav before the fix get merge.
Flole Systems wrote:
I just checked and in the latest version of kodi that warning is indeed gone. Also I was able to reproduce this issue.
I submitted a PR for this and it seems to fix it but I have no idea if this is a proper fix so I won't merge it until either Jaroslav approves it or someone can explain to me why this is the proper way of doing it.
Flole, can we get an update regarding this fix?
RE: Cant't transcode with NVENC - Added by Flole Systems over 3 years ago
As you can see on GitHub in the PR it is not a proper fix. It causes crashes so it can not be merged and further investigating the issue is necessary.
RE: Cant't transcode with NVENC - Added by Kiril St. over 3 years ago
I did some experiments. Replace all code in function profile_sharer_destoy from stable 4.2.8. Now htsp with transcoding work without any problems, but http with transcoding cause tvheadend to crash...
RE: Cant't transcode with NVENC - Added by Kiril St. over 3 years ago
@ Flole Systems, I investigate a little more, and found that commit be37f9d (profile: reshuffle code in sharer destroy) is caused this problems! Im not familiar with github pull request features, so i provide working code in text file. Please check, and review. Tested wit http and htsp user on same channel, also 2 htsp users on same channel, work without problems!
RE: Cant't transcode with NVENC - Added by Flole Systems over 3 years ago
Kiril St. wrote:
@ Flole Systems, I investigate a little more, and found that commit be37f9d (profile: reshuffle code in sharer destroy) is caused this problems! Im not fimilar with github pull request features, so i provide working code in text file. Please check, and review. Tested wit http and htsp user on same channel, also 2 htsp users on same channel, work without problems!
Thank you so much for identifying this. This should make fixing it a lot easier.
RE: Cant't transcode with NVENC - Added by Flole Systems over 3 years ago
And I just saw that you provided a fix aswell! Thanks, I will check it out!
RE: Cant't transcode with NVENC - Added by Ronny M. over 3 years ago
Kiril St. wrote:
@ Flole Systems, I investigate a little more, and found that commit be37f9d (profile: reshuffle code in sharer destroy) is caused this problems! Im not familiar with github pull request features, so i provide working code in text file. Please check, and review. Tested wit http and htsp user on same channel, also 2 htsp users on same channel, work without problems!
First, Many many thanks for this work! Now it Working correctly!
i make a Notic in my Bug Ticket https://tvheadend.org/issues/5417
Second, I make many Tests with Spawn + FFmpeg (from git)
-> Result, with HW Decode and HW Filter and other Options is the Performance very nice...
now i Tihnk two Parts open for NVIDIA Transcode (with Decode and HW full offload)
- HW NV Decode
- update Profile and Presets + HW Filter and Scale and RAM usage (but Filter and Scale is Differnt with new "vulkan" Version)
-> and i think we need a Sub-Option for HW Decode Config ->> Use Filter, use Scaler, ...
@ Flole Systems,
have you Preview for NV_Decode?
h264_NVENC.txt (9.03 KB) h264_NVENC.txt | NVIDIA NVENC h264 encoder Options | ||
hevc_NVENC.txt (8.46 KB) hevc_NVENC.txt | NVIDIA NVENC hevc encoder Options | ||
SPAWN_FFmpeg_NVENC_example.txt (1.37 KB) SPAWN_FFmpeg_NVENC_example.txt | Two Spawn Example with Cuda / Cuda Vulkan |
RE: Cant't transcode with NVENC - Added by Flole Systems over 3 years ago
I have nvdec working, but I need to test with the latest ffmpeg version to see if it actually works correctly now.
Also the fix on GitHub is not correct yet, it has at least one issue that needs addressing before it can be merged.
RE: Cant't transcode with NVENC - Added by Ronny M. over 3 years ago
Flole Systems wrote:
I have nvdec working, but I need to test with the latest ffmpeg version to see if it actually works correctly now.
Also the fix on GitHub is not correct yet, it has at least one issue that needs addressing before it can be merged.
With or whithout HW filter (yadif_Cuda, hwupload)?
And can you please send me the Changes i will test this...
RE: Cant't transcode with NVENC - Added by Flole Systems over 3 years ago
Without hw filter for now.
With the current ffmpeg version things don't work properly yet, so there's no point in sending you the changes. I'll test with the latest ffmpeg and then merge it if it's working.
RE: Cant't transcode with NVENC - Added by Kiril St. over 3 years ago
Flole Systems wrote:
Also the fix on GitHub is not correct yet, it has at least one issue that needs addressing before it can be merged.
What do you mean with this? It cause some problems? I dont see any problems so far...just curious...
RE: Cant't transcode with NVENC - Added by Flole Systems over 3 years ago
It could cause issues, yes. The bottom part is not correct, it has potential issues when multiple threads are executing the code.
RE: Cant't transcode with NVENC - Added by Lukas G over 3 years ago
Memory is not freed even when using "webtv-h264 (WEBTV codec H264)" CPU encoding.
Each time you switch programs, RAM increases and the number of processes increases.
I have to restart the tvheadend process often.
RE: Cant't transcode with NVENC - Added by Flole Systems over 3 years ago
Did you compile in the fix from GitHub? Otherwise it's no surprise and nothing new.
RE: Cant't transcode with NVENC - Added by saen acro over 3 years ago
Flole Systems wrote:
Did you compile in the fix from GitHub? Otherwise it's no surprise and nothing new.
I have this problem on CentOS
make -f Makefile.webui LANGUAGES="ach ady ar bg cs da de en_US en_GB es et fa fi fr he hr hu it ko lv lt nl no pl pt ro ru sl sk sq sv tr uk zh zh-Hans" all
make[1]: Entering directory `/opt/tvheadend'
make -f Makefile.webui WEBUI=std compile-std
CC src/main.o
CC src/tvhlog.o
make[2]: Entering directory `/opt/tvheadend'
WEBUI std finished
make[2]: Leaving directory `/opt/tvheadend'
make -f Makefile.webui WEBUI=debug compile-debug
make[2]: Entering directory `/opt/tvheadend'
WEBUI debug finished
make[2]: Leaving directory `/opt/tvheadend'
make[1]: Leaving directory `/opt/tvheadend'
CC src/profile.o
CC src/libav.o
CC src/muxer/muxer_libav.o
CC src/api/api_codec.o
CC src/input/mpegts/iptv/iptv_libav.o
CC src/transcoding/memutils.o
In file included from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/avutil.h:296:0,
from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/samplefmt.h:24,
from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavcodec/avcodec.h:31,
from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavformat/avformat.h:312,
from src/libav.h:26,
from src/tvhlog.c:35:
/opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/common.h: In function ‘av_sat_add64_c’:
/opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/common.h:380:20: error: suggest parentheses around arithmetic in operand of ‘|’ [-Werror=parentheses]
if ((int64_t)(a^b | ~s^b) >= 0)
^
src/tvhlog.c: At top level:
cc1: error: unrecognized command line option "-Wno-stringop-overflow" [-Werror]
cc1: error: unrecognized command line option "-Wno-stringop-truncation" [-Werror]
cc1: all warnings being treated as errors
make: *** [/opt/tvheadend/build.linux/src/tvhlog.o] Error 1
make: *** Waiting for unfinished jobs....
In file included from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/avutil.h:296:0,
from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/mem.h:35,
from src/transcoding/memutils.c:23:
/opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/common.h: In function ‘av_sat_add64_c’:
/opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/common.h:380:20: error: suggest parentheses around arithmetic in operand of ‘|’ [-Werror=parentheses]
if ((int64_t)(a^b | ~s^b) >= 0)
^
src/transcoding/memutils.c: At top level:
cc1: error: unrecognized command line option "-Wno-stringop-overflow" [-Werror]
cc1: error: unrecognized command line option "-Wno-stringop-truncation" [-Werror]
cc1: all warnings being treated as errors
make: *** [/opt/tvheadend/build.linux/src/transcoding/memutils.o] Error 1
In file included from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/avutil.h:296:0,
from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/samplefmt.h:24,
from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavcodec/avcodec.h:31,
from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavformat/avformat.h:312,
from src/libav.h:26,
from src/libav.c:2:
/opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/common.h: In function ‘av_sat_add64_c’:
/opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/common.h:380:20: error: suggest parentheses around arithmetic in operand of ‘|’ [-Werror=parentheses]
if ((int64_t)(a^b | ~s^b) >= 0)
^
src/libav.c: At top level:
cc1: error: unrecognized command line option "-Wno-stringop-overflow" [-Werror]
cc1: error: unrecognized command line option "-Wno-stringop-truncation" [-Werror]
cc1: all warnings being treated as errors
make: *** [/opt/tvheadend/build.linux/src/libav.o] Error 1
In file included from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/avutil.h:296:0,
from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/samplefmt.h:24,
from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavcodec/avcodec.h:31,
from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavformat/avformat.h:312,
from /opt/tvheadend/src/libav.h:26,
from /opt/tvheadend/src/transcoding/codec.h:31,
from src/api/api_codec.c:25:
/opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/common.h: In function ‘av_sat_add64_c’:
/opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/common.h:380:20: error: suggest parentheses around arithmetic in operand of ‘|’ [-Werror=parentheses]
if ((int64_t)(a^b | ~s^b) >= 0)
^
src/api/api_codec.c: At top level:
cc1: error: unrecognized command line option "-Wno-stringop-overflow" [-Werror]
cc1: error: unrecognized command line option "-Wno-stringop-truncation" [-Werror]
cc1: all warnings being treated as errors
make: *** [/opt/tvheadend/build.linux/src/api/api_codec.o] Error 1
In file included from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/avutil.h:296:0,
from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/samplefmt.h:24,
from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavcodec/avcodec.h:31,
from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavformat/avformat.h:312,
from src/muxer/muxer_libav.c:22:
/opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/common.h: In function ‘av_sat_add64_c’:
/opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/common.h:380:20: error: suggest parentheses around arithmetic in operand of ‘|’ [-Werror=parentheses]
if ((int64_t)(a^b | ~s^b) >= 0)
^
src/muxer/muxer_libav.c: At top level:
cc1: error: unrecognized command line option "-Wno-stringop-overflow" [-Werror]
cc1: error: unrecognized command line option "-Wno-stringop-truncation" [-Werror]
cc1: all warnings being treated as errors
make: *** [/opt/tvheadend/build.linux/src/muxer/muxer_libav.o] Error 1
In file included from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/avutil.h:296:0,
from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/samplefmt.h:24,
from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavcodec/avcodec.h:31,
from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavformat/avformat.h:312,
from /opt/tvheadend/src/libav.h:26,
from src/input/mpegts/iptv/iptv_libav.c:22:
/opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/common.h: In function ‘av_sat_add64_c’:
/opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/common.h:380:20: error: suggest parentheses around arithmetic in operand of ‘|’ [-Werror=parentheses]
if ((int64_t)(a^b | ~s^b) >= 0)
^
src/input/mpegts/iptv/iptv_libav.c: At top level:
cc1: error: unrecognized command line option "-Wno-stringop-overflow" [-Werror]
cc1: error: unrecognized command line option "-Wno-stringop-truncation" [-Werror]
cc1: all warnings being treated as errors
make: *** [/opt/tvheadend/build.linux/src/input/mpegts/iptv/iptv_libav.o] Error 1
In file included from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/avutil.h:296:0,
from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/samplefmt.h:24,
from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavcodec/avcodec.h:31,
from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavformat/avformat.h:312,
from /opt/tvheadend/src/libav.h:26,
from src/transcoding/codec.h:31,
from src/profile.c:29:
/opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/common.h: In function ‘av_sat_add64_c’:
/opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/common.h:380:20: error: suggest parentheses around arithmetic in operand of ‘|’ [-Werror=parentheses]
if ((int64_t)(a^b | ~s^b) >= 0)
^
src/profile.c: At top level:
cc1: error: unrecognized command line option "-Wno-stringop-overflow" [-Werror]
cc1: error: unrecognized command line option "-Wno-stringop-truncation" [-Werror]
cc1: all warnings being treated as errors
make: *** [/opt/tvheadend/build.linux/src/profile.o] Error 1
In file included from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/avutil.h:296:0,
from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/samplefmt.h:24,
from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavcodec/avcodec.h:31,
from /opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavformat/avformat.h:312,
from src/libav.h:26,
from src/main.c:70:
/opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/common.h: In function ‘av_sat_add64_c’:
/opt/tvheadend/build.linux/ffmpeg/build/ffmpeg/include/libavutil/common.h:380:20: error: suggest parentheses around arithmetic in operand of ‘|’ [-Werror=parentheses]
if ((int64_t)(a^b | ~s^b) >= 0)
^
src/main.c: At top level:
cc1: error: unrecognized command line option "-Wno-stringop-overflow" [-Werror]
cc1: error: unrecognized command line option "-Wno-stringop-truncation" [-Werror]
cc1: all warnings being treated as errors
make: *** [/opt/tvheadend/build.linux/src/main.o] Error 1
fresh last github pull
RE: Cant't transcode with NVENC - Added by Flole Systems over 3 years ago
That's an ffmpeg issue. You need to report that to ffmpeg.
RE: Cant't transcode with NVENC - Added by saen acro over 3 years ago
Flole Systems wrote:
That's an ffmpeg issue. You need to report that to ffmpeg.
Before last commit it work
RE: Cant't transcode with NVENC - Added by Flole Systems over 3 years ago
Look what the last commit does, then you will understand why it worked before.