Jump to content


Photo

FFmpeg not using NVENC

ffmpeg nvenc GTX 1050 Linux/Ubuntu(Server) 16.04

  • Please log in to reply
78 replies to this topic

#61 TehEpikDuckeh OFFLINE  

TehEpikDuckeh

    Advanced Member

  • Members
  • 94 posts
  • Local time: 12:21 PM

Posted 04 March 2017 - 12:31 AM

@Luke, can you implement a feature in the Transcoding menu where you can choose the commands used for FFmpeg? For instance: let's say I wanted to use NVENC for encoding and Quicksync for decoding (which you could implement by having the user add something to the command like "[codec]" and the software will automatically put the file's encoded codec where [codec] is), could you implement something as such?



#62 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 124161 posts
  • Local time: 04:21 PM

Posted 04 March 2017 - 01:15 AM

Yes I would like to separate encoding/decoding settings but just haven't gotten to it yet. Thanks.


  • SikSlayer, puithove and shorty1483 like this

#63 TehEpikDuckeh OFFLINE  

TehEpikDuckeh

    Advanced Member

  • Members
  • 94 posts
  • Local time: 12:21 PM

Posted 04 March 2017 - 02:05 AM

@Luke, you could add 2 drop down menus in the meantime. Theses should consist of what encoder/decoder to use and include the following options as shown below.

 

Encoding drop down menu:

  • "NVIDIA Encoder [nvenc]"
  • "Intel Quick Sync [qsv]"
  • "ARM OMX [omx]"
  • "VA API [vaapi]
  • "No Hardware Acceleration"

Decoding drop down menu:

  • "NVIDIA Decoder [cuvid]"
  • "Intel Quick Sync [qsv]"
  • "No Hardware Acceleration"

Just to make it easier for you to introduce to Emby.  :)

 

I don't know the decoder options for OMX or VA API, but if someone could chime in on that, that'd be helpful.


  • SikSlayer, puithove and shorty1483 like this

#64 Andy777 OFFLINE  

Andy777

    Advanced Member

  • Members
  • 117 posts
  • Local time: 10:21 PM

Posted 04 March 2017 - 10:02 AM

@Luke, can you implement a feature in the Transcoding menu where you can choose the commands used for FFmpeg? For instance: let's say I wanted to use NVENC for encoding and Quicksync for decoding (which you could implement by having the user add something to the command like "[codec]" and the software will automatically put the file's encoded codec where [codec] is), could you implement something as such?

 

Unfortunately this is more complicated than it first seems. There are multiple reasons:

  • The real benefits of HW transcode are only achieved, when the whole process stays end to end in the HW pipeline without copying to CPU memory. Examples of this are:
    • qsv decode + qsv encode
    • cuvid decode + nvenc encode
    • vaapi decode + vaapi encode
    • (I'm not familiar enough with openmax to comment on that)
  • Additionally, the output pixel format needs to be compatible with the input pixel format of the encoder
  • If the pixel format conversion or other filters are needed, those would need to have hardware implementations compatible with the rest of the HW pipeline to avoid the expensive memory transfer and CPU involvement.
  • Naturally any transfer from Nvidia hardware (cuvid/nvenc) to Intel hardware (qsv/vaapi) would be a transfer from one physical device to another. -> Full hardware pipeline not possible.

There is undergoing development in libav (on hopefully later in ffmpeg) where you actually can mix and match VAAPI, QSV and OPENCL while still staying fully in the same HW pipeline. Check out this patch-set (it includes examples, although it is not merged or even ready yet):

 

"More hardware frame mapping, generic hardware support in avconv, OpenCL support"

 

Don't get me wrong: I'm all for separate settings for decode and encode. For easier support case, my suggestions would be three settings:

 

1. Dropdown for the acceleration method (Vaapi,NVENC/Cuvid,OpenMax etc.)

2. Radio buttons for DECODE: (software / hardware)

3. Radio buttons for ENCODE: (software / hardware)

 

ps. Quality improvements for h.264 and low power VDENC have landed in Vaapi (intel-vaapi-driver). I don't know how long it will take when ffmpeg can fully utilize these new features and enhancements.

 

Edit: h264

 

BR,

Andy777


Edited by Andy777, 04 March 2017 - 12:54 PM.


#65 TehEpikDuckeh OFFLINE  

TehEpikDuckeh

    Advanced Member

  • Members
  • 94 posts
  • Local time: 12:21 PM

Posted 04 March 2017 - 03:44 PM

While I haven't messed with FFmpeg that much, I understand what you're talking about. But people like options as such. What if (and don't quote me on this as I doubt it as well) NVENC was better for encoding while QSV was better for decoding. For me, I want as many options as possible when it comes to testing. There should be two dropdown for encoding and decoding options for this time. What I'd prefer would actually be a way to edit the commands entirely. Just a text box where it contains all the arguments that'll be used for FFmpeg would be great for testing or advanced users. Two dropdown would be a nicer interface for most users. Maybe we could have an "Advanced Options" check box? Just remember, even if things don't work properly with two drop downs, the user still wants options as such.

#66 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 124161 posts
  • Local time: 04:21 PM

Posted 04 March 2017 - 03:57 PM

yea that is much better as the first way will just create many unnecessary troubleshooting scenarios for us.



#67 TehEpikDuckeh OFFLINE  

TehEpikDuckeh

    Advanced Member

  • Members
  • 94 posts
  • Local time: 12:21 PM

Posted 04 March 2017 - 10:53 PM

So I just bought the GTX 1050 again because now I know about CUVID, but having an issue w/ FFmpeg taking HEVC down to H264 w/ hardware acceleration (CUVID & NVENC). I get the following error: "Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height". Any ideas? Works if I use CUVID and no NVENC on HEVC. Works great on H264 to H264, but not HEVC.



#68 Andy777 OFFLINE  

Andy777

    Advanced Member

  • Members
  • 117 posts
  • Local time: 10:21 PM

Posted 05 March 2017 - 04:57 AM

So I just bought the GTX 1050 again because now I know about CUVID, but having an issue w/ FFmpeg taking HEVC down to H264 w/ hardware acceleration (CUVID & NVENC). I get the following error: "Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height". Any ideas? Works if I use CUVID and no NVENC on HEVC. Works great on H264 to H264, but not HEVC.

 

Best place for that kind of questions would be the ffmpeg-user mailing list where the developers also answer. BtBn (Timo Rothenpieler) has been the maintainer around Cuvid/NVENC lately.

 

My guess would be that input-output pixel formats don't match and hardware conversion filter should be applied (that is pure speculation).



#69 puithove OFFLINE  

puithove

    Advanced Member

  • Alpha Testers
  • 721 posts
  • Local time: 04:21 PM

Posted 05 March 2017 - 07:36 AM

There should be a more detailed error message if you look further back in the output.



#70 TehEpikDuckeh OFFLINE  

TehEpikDuckeh

    Advanced Member

  • Members
  • 94 posts
  • Local time: 12:21 PM

Posted 05 March 2017 - 03:49 PM

The following is my FFmpeg log, but it says "No NVENC capable devices found"... It works just fine w/ H264 to H265 but not vice versa.

 

ffmpeg version 3.2.git Copyright © 2000-2017 the FFmpeg developers
  built with gcc 4.9.2 (Debian 4.9.2-10)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --enable-gray --enable-libmp3lame --enable-libopenjpeg --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --disable-shared --enable-nvenc --enable-hwaccels
  libavutil      55. 47.100 / 55. 47.100
  libavcodec     57. 80.101 / 57. 80.101
  libavformat    57. 66.102 / 57. 66.102
  libavdevice    57.  2.100 / 57.  2.100
  libavfilter     6. 73.100 /  6. 73.100
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
Input #0, matroska,webm, from '/media/HDD/Movies/Whiplash.mkv':
  Metadata:
    encoder         : libebml v1.3.1 + libmatroska v1.4.2
    creation_time   : 2015-05-31T13:31:29.000000Z
  Duration: 01:46:45.43, start: 0.000000, bitrate: 1680 kb/s
    Chapter #0:0: start 0.000000, end 411.828000
    Metadata:
      title           : 00:00:00.000
    Chapter #0:1: start 411.828000, end 874.457000
    Metadata:
      title           : 00:06:51.828
    Chapter #0:2: start 874.457000, end 1466.382000
    Metadata:
      title           : 00:14:34.457
    Chapter #0:3: start 1466.382000, end 1806.096000
    Metadata:
      title           : 00:24:26.382
    Chapter #0:4: start 1806.096000, end 2143.975000
    Metadata:
      title           : 00:30:06.096
    Chapter #0:5: start 2143.975000, end 2611.359000
    Metadata:
      title           : 00:35:43.975
    Chapter #0:6: start 2611.359000, end 2815.312000
    Metadata:
      title           : 00:43:31.359
    Chapter #0:7: start 2815.312000, end 3192.481000
    Metadata:
      title           : 00:46:55.312
    Chapter #0:8: start 3192.481000, end 3757.504000
    Metadata:
      title           : 00:53:12.481
    Chapter #0:9: start 3757.504000, end 4230.560000
    Metadata:
      title           : 01:02:37.504
    Chapter #0:10: start 4230.560000, end 4443.606000
    Metadata:
      title           : 01:10:30.560
    Chapter #0:11: start 4443.606000, end 4668.789000
    Metadata:
      title           : 01:14:03.606
    Chapter #0:12: start 4668.789000, end 4986.106000
    Metadata:
      title           : 01:17:48.789
    Chapter #0:13: start 4986.106000, end 5128.290000
    Metadata:
      title           : 01:23:06.106
    Chapter #0:14: start 5128.290000, end 5516.219000
    Metadata:
      title           : 01:25:28.290
    Chapter #0:15: start 5516.219000, end 6405.428000
    Metadata:
      title           : 01:31:56.219
    Stream #0:0(eng): Video: hevc (Main 10), yuv420p10le(tv), 1920x800, SAR 1:1 DAR 12:5, 23.98 fps, 23.98 tbr, 1k tbn, 23.98 tbc (default)
    Metadata:
      BPS             : 1460418
      BPS-eng         : 1460418
      DURATION        : 01:46:45.316000000
      DURATION-eng    : 01:46:45.316000000
      NUMBER_OF_FRAMES: 153574
      NUMBER_OF_FRAMES-eng: 153574
      NUMBER_OF_BYTES : 1169305100
      NUMBER_OF_BYTES-eng: 1169305100
      _STATISTICS_WRITING_APP: mkvmerge v7.8.0 ('River Man') 32bit built on Mar 27 2015 16:18:02
      _STATISTICS_WRITING_APP-eng: mkvmerge v7.8.0 ('River Man') 32bit built on Mar 27 2015 16:18:02
      _STATISTICS_WRITING_DATE_UTC: 2015-05-31 13:31:29
      _STATISTICS_WRITING_DATE_UTC-eng: 2015-05-31 13:31:29
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:1(eng): Audio: aac (LC), 48000 Hz, 5.1, fltp (default)
    Metadata:
      BPS             : 218057
      BPS-eng         : 218057
      DURATION        : 01:46:45.419000000
      DURATION-eng    : 01:46:45.419000000
      NUMBER_OF_FRAMES: 300254
      NUMBER_OF_FRAMES-eng: 300254
      NUMBER_OF_BYTES : 174593403
      NUMBER_OF_BYTES-eng: 174593403
      _STATISTICS_WRITING_APP: mkvmerge v7.8.0 ('River Man') 32bit built on Mar 27 2015 16:18:02
      _STATISTICS_WRITING_APP-eng: mkvmerge v7.8.0 ('River Man') 32bit built on Mar 27 2015 16:18:02
      _STATISTICS_WRITING_DATE_UTC: 2015-05-31 13:31:29
      _STATISTICS_WRITING_DATE_UTC-eng: 2015-05-31 13:31:29
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
File 'test.mkv' already exists. Overwrite ? [y/N] y
[h264_nvenc @ 0x39d9500] No NVENC capable devices found
Stream mapping:
  Stream #0:0 -> #0:0 (hevc (hevc_cuvid) -> h264 (h264_nvenc))
  Stream #0:1 -> #0:1 (copy)
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height


#71 puithove OFFLINE  

puithove

    Advanced Member

  • Alpha Testers
  • 721 posts
  • Local time: 04:21 PM

Posted 06 March 2017 - 07:40 AM

Hmmmm.... not able to help you there since I'm running a 980ti so not able to open a hw decode of hevc.

 

I might be inclined to lean towards what Andy777 said about pixel format considering that it's saying it can't open the ENCODER side of things.  You didn't have any other NVENC sessions open at the time right?

 

You'd probably get more help on that from the ffmpeg guys.



#72 TehEpikDuckeh OFFLINE  

TehEpikDuckeh

    Advanced Member

  • Members
  • 94 posts
  • Local time: 12:21 PM

Posted 06 March 2017 - 06:35 PM

Actually, I think your card is supported. I'm saying this because it can encode HEVC content just fine according to this. Try decoding HEVC (hevc_cuvid) and use software encoding to H264 (h264) to see if it'll work, or vice versa being software decode (h264), hardware encode (hevc_nvenc). You'll have to have 2 files (1x H264, 1x HEVC) in order to do that, but you'd then know if it was possible.

 

I will contact FFmpeg's IRC to see if anyone could help out. If those on the IRC don't have an idea about it, then I'll contact the mailing list. Haven't had time to contact them before, but thanks to those who suggested contacting their team.



#73 thejacer87 OFFLINE  

thejacer87

    Advanced Member

  • Members
  • 132 posts
  • Local time: 12:21 PM
  • LocationKelowna, BC

Posted 29 April 2017 - 01:52 AM

so my 6pin to molex adapter just arrived today after 8 weeks!...

 

so i powered up the gpu, installed the drivers. turned on hardware acceleration and... dissappointment :( 

 

i didnt get any playback on my big bluray file.

 

so i tried my best for the log files to match up time wise. here's what i did for each one and the results:

 

web player - no logs - playback fine (no transcoding is needed i guess?)

 

ipad - log.txt, transcode.txt, remux.txt - no playback (tried interstellar blu ray, and seinfeld episode). and no controls on screen to go back, so i had to close the app.

 

android - log2, transcode2, remux2 - seinfeld fine, interstellar no/choppy playback

 

web player with subtitles turned on - log3, trans3, remux3 - no playback

 

 

so obviously not ideal, any suggestions? :)

 

 

5904277e99900_Screenshotfrom201704282240

$ ffmpeg -version
ffmpeg version 3.3-static http://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 5.4.1 (Debian 5.4.1-8) 20170304
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-5 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg
libavutil      55. 58.100 / 55. 58.100
libavcodec     57. 89.100 / 57. 89.100
libavformat    57. 71.100 / 57. 71.100
libavdevice    57.  6.100 / 57.  6.100
libavfilter     6. 82.100 /  6. 82.100
libswscale      4.  6.100 /  4.  6.100
libswresample   2.  7.100 /  2.  7.100
libpostproc    54.  5.100 / 54.  5.100

Attached Files



#74 shorty1483 OFFLINE  

shorty1483

    Advanced Member

  • Members
  • 1373 posts
  • Local time: 09:21 PM
  • LocationGermany

Posted 29 April 2017 - 04:24 AM

Hmmmm.... not able to help you there since I'm running a 980ti so not able to open a hw decode of hevc.

 

I might be inclined to lean towards what Andy777 said about pixel format considering that it's saying it can't open the ENCODER side of things.  You didn't have any other NVENC sessions open at the time right?

 

You'd probably get more help on that from the ffmpeg guys.

 

 

Actually, I think your card is supported. I'm saying this because it can encode HEVC content just fine according to this. Try decoding HEVC (hevc_cuvid) and use software encoding to H264 (h264) to see if it'll work, or vice versa being software decode (h264), hardware encode (hevc_nvenc). You'll have to have 2 files (1x H264, 1x HEVC) in order to do that, but you'd then know if it was possible.

 

I will contact FFmpeg's IRC to see if anyone could help out. If those on the IRC don't have an idea about it, then I'll contact the mailing list. Haven't had time to contact them before, but thanks to those who suggested contacting their team.

 

Actually @Waldonnis is reviewing the code when he has time because of this error. Reported it in the other thread ( https://emby.media/c...a-nvenc/page-54 ) and we had a personal conv. and I tested some things. When I run the Emby ffmpeg command line with this error inside an own ffmpeg cmd line in windows, there is no error. Also we checked with several tools, that dxva2 is supported on the card. Should be the same with yours. So in my understanding ffmpeg cannot be the culprit. Last statement from Waldonnis to me:

 

 

Huh  :wacko:   Guess I better look at the Emby code to see how it's wrapping/starting the ffmpeg process.  If running it by hand with the same command line works without the error message, then it's the only variable left to look at.  I guess it's possible that .NET's sandboxing may be limiting D3D/DS/DXVA2 access, but I'd have to look at it.  I never had to call external executables from my .NET projects, so I'll have to see how it's all handled and what the limitations may be.

 

As much as I have always liked C# and .NET, it always seems to find new ways of irritating me in practice   :P  


Edited by shorty1483, 29 April 2017 - 04:29 AM.


#75 RanmaCanada OFFLINE  

RanmaCanada

    Advanced Member

  • Members
  • 259 posts
  • Local time: 04:21 PM

Posted 07 May 2017 - 12:42 PM

For those of you wondering what speeds different quadro cards get, I found this nice little page

https://forums.vmix....g=posts&m=33469

 

Remember, only quadros can do more than 2 nvenc sessions per computer.  There might be a hacked driver out there or license or something, I don't know.  But this will give you an idea of the potential that Nvidia has squandered to us.



#76 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 124161 posts
  • Local time: 04:21 PM

Posted 07 May 2017 - 02:33 PM

Thanks for the info !



#77 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 124161 posts
  • Local time: 04:21 PM

Posted 30 March 2018 - 01:31 PM

The next release of Emby Server for Linux x64 will include NVENC support out of the box so all you need to do is enable it. 

 

Nvidia Cuda and OpenCL drivers will need to be installed first. These cannot be freely distributed by us so you will need to refer to your respective distro to learn how to install them.

 

Thanks !



#78 TehEpikDuckeh OFFLINE  

TehEpikDuckeh

    Advanced Member

  • Members
  • 94 posts
  • Local time: 12:21 PM

Posted 30 March 2018 - 01:35 PM

@Luke
Perfect timing, I redid my server and have been having issues compiling ffmpeg with support for NVENC & CUDA/CUVID. Is CUDA/CUVID going to be enabled as well? Is this currently in the beta channel of Emby server?

#79 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 124161 posts
  • Local time: 04:21 PM

Posted 30 March 2018 - 01:38 PM

Yes some enhancements to encoding and decoding are already in the beta, but the included nvenc software is not yet. it will be in the next beta. 







Also tagged with one or more of these keywords: ffmpeg, nvenc, GTX 1050, Linux/Ubuntu(Server) 16.04

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users